RBS
SetParent() lets a window (control or form) behave like a "real" child of
another window (one of your own or even a foreign window); it is sticked to
the parent, but it is still your window: you'll get the events etc. I'm
using it to give the MS OE Toolbar a new button (a VB picturebox) for
storing a interesting newsgroup posting in a textfile.
The function
Function SetOwner&(ByVal hwndOwned&, ByVal hwndOwner&)
SetOwner = SetWindowLong(hwndOwned, GWL_HWNDPARENT, hwndOwner)
End Function
lets the hwndOwned be an owned window of hwndOwner. That's the same as
frmOwned.Show , frmOwner
frmOwned is displayed in front of frmOwner, will be invisible when frnOwner
is minimized, but will not be moved together with frmOwner.
Juergen.
First, try using "Container" Property, so VB knows which window is a child
or a parent.
Second, from SetWindowLong Remarks section: "You must not call SetWindowLong
with the GWL_HWNDPARENT index to change the parent of a child window.
Instead, use the SetParent function."
Third, if you use SetParent, make sure that you save the old parent, and
restore the parent before existing. I had once an API created control and
used SetParent to glue it to a form, and the application would crash when
exiting under Windows 98, but not under XP. The solution was to set the
parent back. Make sure that the hWnd for the parent is still the same,
perhaps by using IsWindow() and checking the class name. You can also use
SetProp() to be sure that you are dealing with the same window.
RBS
"RB Smissaert" <bartsm...@blueyonder.co.uk> wrote in message
news:Owsxqwf2...@TK2MSFTNGP06.phx.gbl...
--
Mike
"RB Smissaert" <bartsm...@blueyonder.co.uk> wrote in message news:e020z9k2...@TK2MSFTNGP03.phx.gbl...
RBS
"MikeD" <nob...@nowhere.edu> wrote in message
news:OrFmG1t2...@TK2MSFTNGP02.phx.gbl...
I was talking more about future posts. Although even in this case, the
suggestion to use the Container property was non-relevant and if you had
said VBA instead of VB6, we'd have known that. Also, it wouldn't surprise
me at all if SetParent "behaves" differently ,or doesn't work at all, with
VBA UserForms. I'm just saying that misinformation on what you're actually
using can lead to bad answers.
--
Mike
It wasn't as I use this in VB6 as well.
RBS
"MikeD" <nob...@nowhere.edu> wrote in message
news:Opl2US62...@TK2MSFTNGP06.phx.gbl...
I'm not trying to be an idiot or anything, but why then did you write:
> Can't do Container etc. as I am coding this in VBA.
I'm just trying to understand. It seems like you're saying one thing and
then in your next message, something completely different.
--
Mike
RBS
"MikeD" <nob...@nowhere.edu> wrote in message
news:eZwNnx92...@TK2MSFTNGP03.phx.gbl...