Home All Groups Group Topic Archive Search About
Author
20 Aug 2010 6:03 AM
BeeJ
In a VB6 app that i am always working on, I found a strange difference
between XP and Vista (both latest SP).
I used the API to set Owner vs non-Owner.
On Vista, when set to Owned, the main form contains the child form such
that the bounds that the child form can be moved is the main form.
Maybe not the right terminology.  As i move the child form, the child
form moves freely but when moving to the right, the right edge of the
child form disapears at the right edge of the main form.  Like it is
inside the main form.
On XP there is no restriction and the child moves outside the main
form.

How is it supposed to work?

Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As
Long, ByVal hWndNewParent As Long) As Long

Author
20 Aug 2010 10:08 AM
Mike Williams
Show quote Hide quote
"BeeJ" <nospam@nospam.com> wrote in message
news:i4l5s2$o89$1@speranza.aioe.org...
> In a VB6 app that i am always working on, I found a strange
> difference  between XP and Vista (both latest SP). On Vista,
> when set to Owned, the main form contains the child form
> such that the bounds that the child form can be moved is the
> main form. Maybe not the right terminology.  As i move the
> child form, the child form moves freely but when moving to
> the right, the right edge of the child form disapears at the
> right edge of the main form.  Like it is inside the main form.
> On XP there is no restriction and the child moves outside
> the main  form. How is it supposed to work?
> Private Declare Function SetParent Lib "user32.dll" (ByVal
> hWndChild As Long, ByVal hWndNewParent As Long) ...

I'm not sure exactly what you're after, or whether you are perhaps confusing
"parent" with "owner", but you can set the owner of a Form using the
ownerform parameter of the Show method, as in:

    Form2.Show , Form1

Alternatively, you can use SetWindowLong to do it, as in:

    SetWindowLong Form2.hwnd, GWL_HWNDPARENT, Form1.hwnd

Although the constant is called GWL_HWNDPARENT it actually sets the owner
(or at least it does in my own experience).

Mike
Author
3 Sep 2010 8:25 PM
Karl E. Peterson
It happens that Mike Williams formulated :
> Although the constant is called GWL_HWNDPARENT it actually sets the owner (or
> at least it does in my own experience).

Yeah, and if that ain't the *most* perversely named constant in the
SDK... <mumble>

--
..NET: It's About Trust!
http://vfred.mvps.org
Author
20 Aug 2010 10:25 AM
David Youngblood
Show quote Hide quote
"BeeJ" <nospam@nospam.com> wrote in message
news:i4l5s2$o89$1@speranza.aioe.org...
> In a VB6 app that i am always working on, I found a strange difference
> between XP and Vista (both latest SP).
> I used the API to set Owner vs non-Owner.
> On Vista, when set to Owned, the main form contains the child form such
> that the bounds that the child form can be moved is the main form.
> Maybe not the right terminology.  As i move the child form, the child form
> moves freely but when moving to the right, the right edge of the child
> form disapears at the right edge of the main form.  Like it is inside the
> main form.
> On XP there is no restriction and the child moves outside the main form.
>
> How is it supposed to work?
>
> Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As
> Long, ByVal hWndNewParent As Long) As Long

SetParent sets the forms parent, not it's owner. Parented windows are
contained within, like controls or MDI Childs. Owned windows are on top of
their owners. To set owner you can use SetWindowLong.

hwdPreviousOwner = SetWindowLong(HwndtoUse, GWL_HWNDPARENT, HwndofOwner)

David
Author
20 Aug 2010 2:28 PM
Mike Williams
"BeeJ" <nospam@nospam.com> wrote in message
news:i4l5s2$o89$1@speranza.aioe.org...

> In a VB6 app that i am always working on, I found a
> strange difference between XP and Vista (both latest SP).

Actually, although your question has already been answered, I'm not
surprised that you found strange differences between the behaviour of
Windows XP and Windows Vista. There are also strange differences between the
behaviour of Vista and Win7 at the operating system level, odd things that
are caused by sloppy programming and that you would not expect to happen. It
seems that in Micro$oft's greedy pursuit of profits they regularly replace
one bunch of crap with another new bunch of crap, never standing still long
enough to consolidate on what they have already got and to make it work
properly.

In Win7, for example, (at least on the machines I have used) if you have a
folder full of lots other folders and if it is set to list view and if the
last visible column of folder names in the window is anything other than
fully displayed then you cannot double click on one of those folders in the
rightmost column to open it. That's because the first click causes the OS to
immediately scroll the window contents to the left, so that the rightmost
column moves left by one column width to become fully visible, which causes
a new and different column of folders to become the new rightmost column,
and then your second click of the double click operation causes that new
rightmost column in turn to move to the left. The result is that the folder
view moves two columns to the left, and your double click does not open
anything at all, and the folder you originally intended to open has often
disappeared off the window completely! In order to properly double click a
folder under such circumstances you have to mess about to make sure you
avoid those problems. I haven't yet checked whether you can cure that
problem by messing about with various other settings, but that is certainly
the default behaviour and it sucks! That is just sloppy programming! In fact
it is what I would expect if they had allowed their crazy and deranged
monkey of a CEO to write the code!

    http://www.youtube.com/watch?v=Nc4MzqBFxZE

Mike
Author
20 Aug 2010 2:38 PM
Nobody
Show quote Hide quote
"BeeJ" <nospam@nospam.com> wrote in message
news:i4l5s2$o89$1@speranza.aioe.org...
> In a VB6 app that i am always working on, I found a strange difference
> between XP and Vista (both latest SP).
> I used the API to set Owner vs non-Owner.
> On Vista, when set to Owned, the main form contains the child form such
> that the bounds that the child form can be moved is the main form.
> Maybe not the right terminology.  As i move the child form, the child form
> moves freely but when moving to the right, the right edge of the child
> form disapears at the right edge of the main form.  Like it is inside the
> main form.
> On XP there is no restriction and the child moves outside the main form.
>
> How is it supposed to work?
>
> Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As
> Long, ByVal hWndNewParent As Long) As Long

Look for ClipControls property or WS_CLIPCHILDREN style.
Author
20 Aug 2010 6:48 PM
Mike Williams
"Nobody" <nob***@nobody.com> wrote in message
news:i4m41e$ddu$1@speranza.aioe.org...
>> "BeeJ" <nospam@nospam.com> wrote in message How is it supposed to work?
>> Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild
>> As Long, ByVal hWndNewParent As Long) As Long
>
> Look for ClipControls property or WS_CLIPCHILDREN style.

Are you sure about that, Nobody? ClipControls determines how drawings are
made to the Form or PictureBox or whatever, specifically determining whether
or not VB creates a clipping region around the contained controls, and
therefore determining whether or not drawings go over the top of Controls
and are therefore visible over them. or whether they treat the control areas
as a "hole" in the drawing surface.

Mike