Discussion:
Controling Active Window Tracking
(too old to reply)
Terry von Gease
2003-10-30 18:35:14 UTC
Permalink
In a bit of VBA in Excel 2002 I'm using the SystemParametersInfo thusly:

******************
Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Any, _
ByVal fuWinIni As Long) _
As Long
. . .
dim parm as Boolean
parm=True
SystemParametersInfo 4097&, 0&, parm, 0&
*****************'

...successfully enables the great white fathers at Microsoft call "Active
Window Tracking" and what we old unreconstructed Unix folk call 'Focus
Follows Mouse".

However, once turned on, I can't seem to get it turned off. A subsequent
call looking like:

******************
. . .
dim parm as Boolean
parm=False
SystemParametersInfo 4097&, 0&, parm, 0&
******************

...does not turn off this feature. After calling with a parm set to false,
if I call with an action code of 4096, which is get the state rather than
set the state, the value returned in parm is True.

Does anyone have a cogent explanation of what is going on here and what must
I do to not only turn on active window tracking but be able to turn it off
as well.

--
Terry

"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley
Ray Mercer
2003-10-30 21:38:15 UTC
Permalink
Terry,
Post by Terry von Gease
******************
Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Any, _
ByVal fuWinIni As Long) _
As Long
. . .
dim parm as Boolean
[snip...]
Post by Terry von Gease
Does anyone have a cogent explanation of what is going on here and what must
I do to not only turn on active window tracking but be able to turn it off
as well.
I don't have VB6 instaled on this notebook and I am travelling so I can't
verify this, but I would try this:
Dim parm as Long

and instead of setting it TRUE use parm = 1&

The value of FALSE is 0 in both VB and VC but the value of TRUE is -1 in VB
this might be confusing the API function which is expecting a VC BOOL with
either 0 or 1 in it...

HTH,
Ray Mercer
Terry von Gease
2003-10-30 22:13:02 UTC
Permalink
Post by Ray Mercer
Terry,
Post by Terry von Gease
******************
Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Any, _
ByVal fuWinIni As Long) _
As Long
. . .
dim parm as Boolean
[snip...]
Post by Terry von Gease
Does anyone have a cogent explanation of what is going on here and what
must
Post by Terry von Gease
I do to not only turn on active window tracking but be able to turn it off
as well.
I don't have VB6 instaled on this notebook and I am travelling so I can't
Dim parm as Long
and instead of setting it TRUE use parm = 1&
The value of FALSE is 0 in both VB and VC but the value of TRUE is -1 in VB
this might be confusing the API function which is expecting a VC BOOL with
either 0 or 1 in it...
Tried it, no help there. It isn't the True that's not working , it's the
False.

It has no trouble turning on, I can't get it to turn off. Moreover, I don't
know about VC but in every other C on the planet 0 is false and !0 is true.

In order to get it to turn off I have to restart windows. Worse, there's a
modeless form with a listbox with its MatchEntry property set to
fmMatchEntryFirstLetter that ceases to do a first letter match when the form
loses and regains focus by passing the mouse cursor over it. What a mess.

I do admit to some confusion of the declaration of ipvParam as 'Any". What
in the hell is that? I assume that since it's by reference it's a pointer of
constant size and the procedure itself makes it whatever it wants it to be
but sometimes dealing with Microsoft crap is like Alice wrestling with the
flamingo.

--
Terry

"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley
Ray Mercer
2003-10-31 03:18:35 UTC
Permalink
Terry,
Post by Terry von Gease
Post by Ray Mercer
I don't have VB6 instaled on this notebook and I am travelling so I can't
Dim parm as Long
and instead of setting it TRUE use parm = 1&
Tried it, no help there. It isn't the True that's not working , it's the
False.
Oh. Yeah, it's the False. OK - did you try passing 0& for FALSE? Sorry if
you already did, but I have seen VB Booleans confuse API calls before...
Post by Terry von Gease
It has no trouble turning on, I can't get it to turn off. Moreover, I don't
know about VC but in every other C on the planet 0 is false and !0 is true.
That's correct - logically. But underneath the hood VB's Boolean is not the
same as VC.
Post by Terry von Gease
I do admit to some confusion of the declaration of ipvParam as 'Any". What
in the hell is that? I assume that since it's by reference it's a pointer of
constant size and the procedure itself makes it whatever it wants it to be
Yeah. As Any lets you pass a reference to any type without compiler error.
Post by Terry von Gease
but sometimes dealing with Microsoft crap is like Alice wrestling with the
flamingo.
Well, I wish I had VB installed on this PC so I could test here. It looks
like you are using SPI_SETACTIVEWINDOWTRACKING, right? One other thing I
would do is to get the return value from the function and see if it
succeeded or if there is an error message being sent - it might give you a
clue.

From the MSDN docs on SystemParametersInfo -->
/*------------->
Return Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error
information, call GetLastError.
<----------------*/
Just for kicks, why don't you try calling it like this:
******************
Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Long, _
ByVal fuWinIni As Long) _
As Long
...
Dim retVal as Long 'should return 0
'on
retVal = SystemParametersInfo( SPI_SETACTIVEWINDOWTRACKING, 0&, 1&, 0& )
'off
retVal = SystemParametersInfo( SPI_SETACTIVEWINDOWTRACKING, 0&, 0&, 0& )

*****************'
Terry von Gease
2003-10-31 05:11:54 UTC
Permalink
Post by Ray Mercer
Terry,
Post by Terry von Gease
Post by Ray Mercer
I don't have VB6 instaled on this notebook and I am travelling so I
can't
Post by Terry von Gease
Post by Ray Mercer
Dim parm as Long
and instead of setting it TRUE use parm = 1&
Tried it, no help there. It isn't the True that's not working , it's the
False.
Oh. Yeah, it's the False. OK - did you try passing 0& for FALSE? Sorry if
you already did, but I have seen VB Booleans confuse API calls before...
Post by Terry von Gease
It has no trouble turning on, I can't get it to turn off. Moreover, I
don't
Post by Terry von Gease
know about VC but in every other C on the planet 0 is false and !0 is
true.
That's correct - logically. But underneath the hood VB's Boolean is not the
same as VC.
Post by Terry von Gease
I do admit to some confusion of the declaration of ipvParam as 'Any". What
in the hell is that? I assume that since it's by reference it's a
pointer
Post by Ray Mercer
of
Post by Terry von Gease
constant size and the procedure itself makes it whatever it wants it to be
Yeah. As Any lets you pass a reference to any type without compiler error.
Post by Terry von Gease
but sometimes dealing with Microsoft crap is like Alice wrestling with the
flamingo.
Well, I wish I had VB installed on this PC so I could test here. It looks
like you are using SPI_SETACTIVEWINDOWTRACKING, right? One other thing I
would do is to get the return value from the function and see if it
succeeded or if there is an error message being sent - it might give you a
clue.
Yup, 4097 is the decimal value for SPI_SETACTIVEWINDOWTRACKING.

The return value is 1 after sending either true or false or 1& or 0&. The
specs say that if it works it's supposed to return a non-zero. Which of
course is C for a true value. Very un-C-like.
Post by Ray Mercer
From the MSDN docs on SystemParametersInfo -->
/*------------->
Return Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error
information, call GetLastError.
<----------------*/
******************
Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Long, _
ByVal fuWinIni As Long) _
As Long
...
Dim retVal as Long 'should return 0
'on
retVal = SystemParametersInfo( SPI_SETACTIVEWINDOWTRACKING, 0&, 1&, 0& )
'off
retVal = SystemParametersInfo( SPI_SETACTIVEWINDOWTRACKING, 0&, 0&, 0& )
*****************'
No help. By the bye, it returns 1 when it works, 0 when it doesn't.

I think I'm going to have to abandon this whole endeavor or find another
way. The not being able to turn it off I could probably live with, maybe,
perhaps. But the screwing up of the MatchEntry on the listbox it way to much
to tolerate. I live in fear of discovering just what else has been
perverted.

I really would like to understand just what in hell is going on here whether
I end up using it or not.

--
Terry

"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley
Björn Holmgren
2003-10-31 08:54:54 UTC
Permalink
Terry,

Change the SystemParametersInfo function declaration to:

Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

It's the "ByRef lpvParam" in your declaration that's causing the problem.
You're passing a pointer to a pointer instead of a pointer to a value. Since
that pointer will always be a value greater than zero, you're in fact always
passing "TRUE".

--
Björn Holmgren
Guide Konsult AB
Post by Terry von Gease
Post by Ray Mercer
Terry,
Post by Terry von Gease
Post by Ray Mercer
I don't have VB6 instaled on this notebook and I am travelling so I
can't
Post by Terry von Gease
Post by Ray Mercer
Dim parm as Long
and instead of setting it TRUE use parm = 1&
Tried it, no help there. It isn't the True that's not working , it's the
False.
Oh. Yeah, it's the False. OK - did you try passing 0& for FALSE? Sorry
if
Post by Ray Mercer
you already did, but I have seen VB Booleans confuse API calls before...
Post by Terry von Gease
It has no trouble turning on, I can't get it to turn off. Moreover, I
don't
Post by Terry von Gease
know about VC but in every other C on the planet 0 is false and !0 is
true.
That's correct - logically. But underneath the hood VB's Boolean is not
the
Post by Ray Mercer
same as VC.
Post by Terry von Gease
I do admit to some confusion of the declaration of ipvParam as 'Any".
What
Post by Ray Mercer
Post by Terry von Gease
in the hell is that? I assume that since it's by reference it's a
pointer
Post by Ray Mercer
of
Post by Terry von Gease
constant size and the procedure itself makes it whatever it wants it
to
Post by Terry von Gease
be
Post by Ray Mercer
Yeah. As Any lets you pass a reference to any type without compiler
error.
Post by Ray Mercer
Post by Terry von Gease
but sometimes dealing with Microsoft crap is like Alice wrestling with
the
Post by Ray Mercer
Post by Terry von Gease
flamingo.
Well, I wish I had VB installed on this PC so I could test here. It looks
like you are using SPI_SETACTIVEWINDOWTRACKING, right? One other thing I
would do is to get the return value from the function and see if it
succeeded or if there is an error message being sent - it might give you a
clue.
Yup, 4097 is the decimal value for SPI_SETACTIVEWINDOWTRACKING.
The return value is 1 after sending either true or false or 1& or 0&. The
specs say that if it works it's supposed to return a non-zero. Which of
course is C for a true value. Very un-C-like.
Post by Ray Mercer
From the MSDN docs on SystemParametersInfo -->
/*------------->
Return Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error
information, call GetLastError.
<----------------*/
******************
Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Long, _
ByVal fuWinIni As Long) _
As Long
...
Dim retVal as Long 'should return 0
'on
retVal = SystemParametersInfo( SPI_SETACTIVEWINDOWTRACKING, 0&, 1&, 0& )
'off
retVal = SystemParametersInfo( SPI_SETACTIVEWINDOWTRACKING, 0&, 0&, 0& )
*****************'
No help. By the bye, it returns 1 when it works, 0 when it doesn't.
I think I'm going to have to abandon this whole endeavor or find another
way. The not being able to turn it off I could probably live with, maybe,
perhaps. But the screwing up of the MatchEntry on the listbox it way to much
to tolerate. I live in fear of discovering just what else has been
perverted.
I really would like to understand just what in hell is going on here whether
I end up using it or not.
--
Terry
"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley
Terry von Gease
2003-10-31 15:55:26 UTC
Permalink
That did the trick. Originally I just copied and pasted the declaration out
of win32api.txt, I never thought to question it.

Now that I can turn it on and off properly, do you or anyone else have any
insight into just why with the active window tracking set on deactivating
and the re-activating a form with a listbox by moving the mouse off of and
back over it should cause the MatchEntry feature of this list box to cease
working.

The listbox MatchEntry is set to fmMatchEntryFirstLetter, or 0, and
functions perfectly when the form is initially displayed with 'form.Show
0'. When the mouse leaves and re-enters the form via sliding the mouse, the
match entry feature no longer functions. The MatchEntry is still set to 0
and nothing else has changed.

If you unload the form and then bring it up again, the list works fine once
more. Until you slide the mouse off and back on the form. The match entry
ceases to function. When the mouse slides off and/or back on the form the
title bar changes as you'd expect and shows the proper gray or color but
there doesn't seem to be any event triggered.

I can dummy up the match entry with KeyPress or KeyUp or something but, not
only shouldn't I have to do so, I will always wonder just what else is
screwed up inside.

Any help would be appreciated.

--
Terry

"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley
Post by Ray Mercer
Terry,
Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
It's the "ByRef lpvParam" in your declaration that's causing the problem.
You're passing a pointer to a pointer instead of a pointer to a value. Since
that pointer will always be a value greater than zero, you're in fact always
passing "TRUE".
--
Björn Holmgren
Guide Konsult AB
Post by Terry von Gease
Post by Ray Mercer
Terry,
Post by Terry von Gease
Post by Ray Mercer
I don't have VB6 instaled on this notebook and I am travelling so I
can't
Post by Terry von Gease
Post by Ray Mercer
Dim parm as Long
and instead of setting it TRUE use parm = 1&
Tried it, no help there. It isn't the True that's not working , it's
the
Post by Terry von Gease
Post by Ray Mercer
Post by Terry von Gease
False.
Oh. Yeah, it's the False. OK - did you try passing 0& for FALSE?
Sorry
Post by Ray Mercer
Post by Terry von Gease
if
Post by Ray Mercer
you already did, but I have seen VB Booleans confuse API calls before...
Post by Terry von Gease
It has no trouble turning on, I can't get it to turn off. Moreover, I
don't
Post by Terry von Gease
know about VC but in every other C on the planet 0 is false and !0 is
true.
That's correct - logically. But underneath the hood VB's Boolean is not
the
Post by Ray Mercer
same as VC.
Post by Terry von Gease
I do admit to some confusion of the declaration of ipvParam as 'Any".
What
Post by Ray Mercer
Post by Terry von Gease
in the hell is that? I assume that since it's by reference it's a
pointer
Post by Ray Mercer
of
Post by Terry von Gease
constant size and the procedure itself makes it whatever it wants it
to
Post by Terry von Gease
be
Post by Ray Mercer
Yeah. As Any lets you pass a reference to any type without compiler
error.
Post by Ray Mercer
Post by Terry von Gease
but sometimes dealing with Microsoft crap is like Alice wrestling with
the
Post by Ray Mercer
Post by Terry von Gease
flamingo.
Well, I wish I had VB installed on this PC so I could test here. It
looks
Post by Terry von Gease
Post by Ray Mercer
like you are using SPI_SETACTIVEWINDOWTRACKING, right? One other
thing
Post by Ray Mercer
I
Post by Terry von Gease
Post by Ray Mercer
would do is to get the return value from the function and see if it
succeeded or if there is an error message being sent - it might give
you
Post by Ray Mercer
a
Post by Terry von Gease
Post by Ray Mercer
clue.
Yup, 4097 is the decimal value for SPI_SETACTIVEWINDOWTRACKING.
The return value is 1 after sending either true or false or 1& or 0&. The
specs say that if it works it's supposed to return a non-zero. Which of
course is C for a true value. Very un-C-like.
Post by Ray Mercer
From the MSDN docs on SystemParametersInfo -->
/*------------->
Return Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error
information, call GetLastError.
<----------------*/
******************
Declare Function SystemParametersInfo _
Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, _
ByVal uParam As Long, _
ByRef lpvParam As Long, _
ByVal fuWinIni As Long) _
As Long
...
Dim retVal as Long 'should return 0
'on
retVal = SystemParametersInfo( SPI_SETACTIVEWINDOWTRACKING, 0&, 1&, 0& )
'off
retVal = SystemParametersInfo( SPI_SETACTIVEWINDOWTRACKING, 0&, 0&, 0& )
*****************'
No help. By the bye, it returns 1 when it works, 0 when it doesn't.
I think I'm going to have to abandon this whole endeavor or find another
way. The not being able to turn it off I could probably live with, maybe,
perhaps. But the screwing up of the MatchEntry on the listbox it way to
much
Post by Terry von Gease
to tolerate. I live in fear of discovering just what else has been
perverted.
I really would like to understand just what in hell is going on here
whether
Post by Terry von Gease
I end up using it or not.
--
Terry
"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley
Ray Mercer
2003-10-31 17:13:13 UTC
Permalink
Post by Terry von Gease
That did the trick. Originally I just copied and pasted the declaration out
of win32api.txt, I never thought to question it.
Glad you got it working, but according to the docs that parameter should be
passed ByRef. It says so here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbadev/html/usingsystemparametersinfofunction.asp

and here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp?frame=true

I even looked up the method signature in WINUSER.H and it look like this:
WINUSERAPI
BOOL
WINAPI
SystemParametersInfoA(
UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni);

I searched the MS KBase and the only article I found showed the same ByRef
declare:
http://support.microsoft.com/default.aspx?scid=kb;en-us;185637

As far as I know a void pointer [in,out] value should be passed ByRef, so I
think this may be a bug related to that one flag. You may need to make an
alias declare for that one purpose???

Again, I don't have VB6 available right now, but don't the other flags work
as expected with the ByRef declare?

Ray Mercer
Terry von Gease
2003-10-31 19:16:07 UTC
Permalink
For sure all of the available documentation indicates ByRef is the one true
way. That it doesn't function with ByRef and does with ByVal is a matter for
the gods of applied pragmatism.

It's a mystery. There doesn't seem to be a whole hell of a lot of
consistency in this call regarding the use of the uiParam versus the
pvParam. Lots of the SET_ functions use the uiParam for specifying a
True/False and others use the pvParam.

There doesn't seem to be any rhyme or reason as to why one or the other
parameter was used in any given case where only a single simple value is
required..

I'm reluctant to use it at all. Something that functions only when you do it
wrong is a nervous-making situation. Witness the malfunctioning modeless
form's listbox match entry feature. What other hideous things might be
living in there?

Yet another confirming instance that the apparatus at Microsoft's reach
tends to exceed its grasp.

--
Terry

"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley
Post by Ray Mercer
Post by Terry von Gease
That did the trick. Originally I just copied and pasted the declaration
out
Post by Terry von Gease
of win32api.txt, I never thought to question it.
Glad you got it working, but according to the docs that parameter should be
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbadev/ht
ml/usingsystemparametersinfofunction.asp
Post by Ray Mercer
and here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/bas
e/systemparametersinfo.asp?frame=true
Post by Ray Mercer
WINUSERAPI
BOOL
WINAPI
SystemParametersInfoA(
UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni);
I searched the MS KBase and the only article I found showed the same ByRef
http://support.microsoft.com/default.aspx?scid=kb;en-us;185637
As far as I know a void pointer [in,out] value should be passed ByRef, so I
think this may be a bug related to that one flag. You may need to make an
alias declare for that one purpose???
Again, I don't have VB6 available right now, but don't the other flags work
as expected with the ByRef declare?
Ray Mercer
Randy Birch
2003-10-31 22:51:37 UTC
Permalink
uiParam is defined as an "in" only variable; pvParam is an "in/out". So in
VB, if you expect pvParam to be filled with data from the call, you pass it
byref (unless it's a string, of course). If pvParam is being used as an In
value, as is the case with SPI_SETACTIVEWINDOWTRACKING, then it's passed
byval.
--
Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.


"Terry von Gease" <***@gv.net> wrote in message news:***@corp.supernews.com...
: For sure all of the available documentation indicates ByRef is the one
true
: way. That it doesn't function with ByRef and does with ByVal is a matter
for
: the gods of applied pragmatism.
:
: It's a mystery. There doesn't seem to be a whole hell of a lot of
: consistency in this call regarding the use of the uiParam versus the
: pvParam. Lots of the SET_ functions use the uiParam for specifying a
: True/False and others use the pvParam.
:
: There doesn't seem to be any rhyme or reason as to why one or the other
: parameter was used in any given case where only a single simple value is
: required..
:
: I'm reluctant to use it at all. Something that functions only when you do
it
: wrong is a nervous-making situation. Witness the malfunctioning modeless
: form's listbox match entry feature. What other hideous things might be
: living in there?
:
: Yet another confirming instance that the apparatus at Microsoft's reach
: tends to exceed its grasp.
:
: --
: Terry
:
: "I said I never had much use for one,
: I never said I didn't know how to use one."
: M. Quigley
:
: "Ray Mercer" <***@mvps.org> wrote in message
: news:#***@tk2msftngp13.phx.gbl...
: >
: > "Terry von Gease" <***@gv.net> wrote in message
: > news:***@corp.supernews.com...
: > > That did the trick. Originally I just copied and pasted the
declaration
: > out
: > > of win32api.txt, I never thought to question it.
: >
: > Glad you got it working, but according to the docs that parameter should
: be
: > passed ByRef. It says so here:
: >
:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbadev/ht
: ml/usingsystemparametersinfofunction.asp
: >
: > and here
: >
:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/bas
: e/systemparametersinfo.asp?frame=true
: >
: > I even looked up the method signature in WINUSER.H and it look like
this:
: > WINUSERAPI
: > BOOL
: > WINAPI
: > SystemParametersInfoA(
: > UINT uiAction,
: > UINT uiParam,
: > PVOID pvParam,
: > UINT fWinIni);
: >
: > I searched the MS KBase and the only article I found showed the same
ByRef
: > declare:
: > http://support.microsoft.com/default.aspx?scid=kb;en-us;185637
: >
: > As far as I know a void pointer [in,out] value should be passed ByRef,
so
: I
: > think this may be a bug related to that one flag. You may need to make
an
: > alias declare for that one purpose???
: >
: > Again, I don't have VB6 available right now, but don't the other flags
: work
: > as expected with the ByRef declare?
: >
: > Ray Mercer
: >
: >
:
:
Terry von Gease
2003-10-31 23:51:13 UTC
Permalink
I have no doubt that this is the case but where would one expect to find a
reasonble description of this exercise in obscurity?

If you've been following along here, what do you think about the listbox
with the malfeasant match entry feature? This manifests itself if and only
if the SPI_SETACTIVEWINDOWTRACKING is turned on.

--
Terry

"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley
Post by Randy Birch
uiParam is defined as an "in" only variable; pvParam is an "in/out". So in
VB, if you expect pvParam to be filled with data from the call, you pass it
byref (unless it's a string, of course). If pvParam is being used as an In
value, as is the case with SPI_SETACTIVEWINDOWTRACKING, then it's passed
byval.
--
Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.
: For sure all of the available documentation indicates ByRef is the one
true
: way. That it doesn't function with ByRef and does with ByVal is a matter
for
: the gods of applied pragmatism.
: It's a mystery. There doesn't seem to be a whole hell of a lot of
: consistency in this call regarding the use of the uiParam versus the
: pvParam. Lots of the SET_ functions use the uiParam for specifying a
: True/False and others use the pvParam.
: There doesn't seem to be any rhyme or reason as to why one or the other
: parameter was used in any given case where only a single simple value is
: required..
: I'm reluctant to use it at all. Something that functions only when you do
it
: wrong is a nervous-making situation. Witness the malfunctioning modeless
: form's listbox match entry feature. What other hideous things might be
: living in there?
: Yet another confirming instance that the apparatus at Microsoft's reach
: tends to exceed its grasp.
: --
: Terry
: "I said I never had much use for one,
: I never said I didn't know how to use one."
: M. Quigley
: >
: > > That did the trick. Originally I just copied and pasted the
declaration
: > out
: > > of win32api.txt, I never thought to question it.
: >
: > Glad you got it working, but according to the docs that parameter should
: be
: >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbadev/ht
Post by Randy Birch
: ml/usingsystemparametersinfofunction.asp
: >
: > and here
: >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/bas
Post by Randy Birch
: e/systemparametersinfo.asp?frame=true
: >
: > I even looked up the method signature in WINUSER.H and it look like
: > WINUSERAPI
: > BOOL
: > WINAPI
: > SystemParametersInfoA(
: > UINT uiAction,
: > UINT uiParam,
: > PVOID pvParam,
: > UINT fWinIni);
: >
: > I searched the MS KBase and the only article I found showed the same
ByRef
: > http://support.microsoft.com/default.aspx?scid=kb;en-us;185637
: >
: > As far as I know a void pointer [in,out] value should be passed ByRef,
so
: I
: > think this may be a bug related to that one flag. You may need to make
an
: > alias declare for that one purpose???
: >
: > Again, I don't have VB6 available right now, but don't the other flags
: work
: > as expected with the ByRef declare?
: >
: > Ray Mercer
: >
: >
Randy Birch
2003-11-01 00:15:45 UTC
Permalink
: I have no doubt that this is the case but where would one expect to find a
: reasonable description of this exercise in obscurity?

<g> I suspect it's buried somewhere in the msdn, in the section that
details how to call DLL functions from VB. But for me this is just ingrained
knowledge, albeit gained from experience, reading and practice.

: If you've been following along here, what do you think about the listbox
: with the malfeasant match entry feature? This manifests itself if and only
: if the SPI_SETACTIVEWINDOWTRACKING is turned on.

No idea really .. I don't know what a "MatchEntry" property or feature is.
Unless you're simply stating the list's ability to move to the next item
when a key is pressed. Testing this under XP with
SPI_SETACTIVEWINDOWTRACKING on shows that even though the form is activated,
the focus does not return to the list having focus when the form lost focus.
Clicking on the list re-enables the keyboard first-letter list selection
functionality.

Since VB forms do not intrinsically provide a method to determine when focus
was gained from another application external to the project, in which case
you could take steps to ensure focus was reset to the listbox, your only
solution is to either require the clicking of the list to explicitly give it
the focus again, or subclass your application to receive notifications when
your app was activated following another non-project app. The code for this
is located at http://www.mvps.org/vbnet/code/subclass/activation.htm
--
Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.


"Terry von Gease" <***@gv.net> wrote in message news:***@corp.supernews.com...

:
: If you've been following along here, what do you think about the listbox
: with the malfeasant match entry feature? This manifests itself if and only
: if the SPI_SETACTIVEWINDOWTRACKING is turned on.
:
: --
: Terry
:
: "I said I never had much use for one,
: I never said I didn't know how to use one."
: M. Quigley
:
: "Randy Birch" <***@mvps.org> wrote in message
: news:u$***@TK2MSFTNGP09.phx.gbl...
: > uiParam is defined as an "in" only variable; pvParam is an "in/out". So
in
: > VB, if you expect pvParam to be filled with data from the call, you pass
: it
: > byref (unless it's a string, of course). If pvParam is being used as an
In
: > value, as is the case with SPI_SETACTIVEWINDOWTRACKING, then it's passed
: > byval.
: >
: > --
: >
: > Randy Birch
: > MVP Visual Basic
: > http://www.mvps.org/vbnet/
: > Please respond only to the newsgroups so all can benefit.
: >
: >
: > "Terry von Gease" <***@gv.net> wrote in message
: > news:***@corp.supernews.com...
: > : For sure all of the available documentation indicates ByRef is the one
: > true
: > : way. That it doesn't function with ByRef and does with ByVal is a
matter
: > for
: > : the gods of applied pragmatism.
: > :
: > : It's a mystery. There doesn't seem to be a whole hell of a lot of
: > : consistency in this call regarding the use of the uiParam versus the
: > : pvParam. Lots of the SET_ functions use the uiParam for specifying a
: > : True/False and others use the pvParam.
: > :
: > : There doesn't seem to be any rhyme or reason as to why one or the
other
: > : parameter was used in any given case where only a single simple value
is
: > : required..
: > :
: > : I'm reluctant to use it at all. Something that functions only when you
: do
: > it
: > : wrong is a nervous-making situation. Witness the malfunctioning
modeless
: > : form's listbox match entry feature. What other hideous things might be
: > : living in there?
: > :
: > : Yet another confirming instance that the apparatus at Microsoft's
reach
: > : tends to exceed its grasp.
: > :
: > : --
: > : Terry
: > :
: > : "I said I never had much use for one,
: > : I never said I didn't know how to use one."
: > : M. Quigley
: > :
: > : "Ray Mercer" <***@mvps.org> wrote in message
: > : news:#***@tk2msftngp13.phx.gbl...
: > : >
: > : > "Terry von Gease" <***@gv.net> wrote in message
: > : > news:***@corp.supernews.com...
: > : > > That did the trick. Originally I just copied and pasted the
: > declaration
: > : > out
: > : > > of win32api.txt, I never thought to question it.
: > : >
: > : > Glad you got it working, but according to the docs that parameter
: should
: > : be
: > : > passed ByRef. It says so here:
: > : >
: > :
: >
:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbadev/ht
: > : ml/usingsystemparametersinfofunction.asp
: > : >
: > : > and here
: > : >
: > :
: >
:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/bas
: > : e/systemparametersinfo.asp?frame=true
: > : >
: > : > I even looked up the method signature in WINUSER.H and it look like
: > this:
: > : > WINUSERAPI
: > : > BOOL
: > : > WINAPI
: > : > SystemParametersInfoA(
: > : > UINT uiAction,
: > : > UINT uiParam,
: > : > PVOID pvParam,
: > : > UINT fWinIni);
: > : >
: > : > I searched the MS KBase and the only article I found showed the same
: > ByRef
: > : > declare:
: > : > http://support.microsoft.com/default.aspx?scid=kb;en-us;185637
: > : >
: > : > As far as I know a void pointer [in,out] value should be passed
ByRef,
: > so
: > : I
: > : > think this may be a bug related to that one flag. You may need to
: make
: > an
: > : > alias declare for that one purpose???
: > : >
: > : > Again, I don't have VB6 available right now, but don't the other
flags
: > : work
: > : > as expected with the ByRef declare?
: > : >
: > : > Ray Mercer
: > : >
: > : >
: > :
: > :
: >
: >
:
:
Loading...