quote:
Originally posted by raceprouk
quote:
Originally posted by CookieRevised
in VB a created form in your project always exist...
You sure?
yes... although I maybe didn't explained it well...
quote:
Originally posted by raceprouk
I would have thought the form was loaded on the first .Show line.
The normal command for loading a form is "Load", but this will not show the form yet.
The "Show" method itself, also automatically loads the form if it wasn't loaded already and then shows the form. This is the same as its counterpart method "Hide", it also automatically loads the form if it wasn't loaded already and then hides the form.
But a form is not only automatically loaded when used with methods or commands, it is also loads automatically whenever you use a property of the form itself, hence when using .hWnd the forms gets loaded.
quote:
Originally posted by raceprouk
I suppose if that's the case, you can use 'Load Form1'. Probably wouldn't make any difference whether the form was loaded or not when that line is executed: it just makes certain.
in this case, yep.
you can check this yourself:
code:
'To make sure the form is "unloaded":
Unload Form1
'show the handle
MsgBox Form1.hWnd
You'll see it is a valid handle again because the form was loaded again
But note that DestroyWindow will effectivly destroy the form in memory!! After DestroyWindow you wont be able to show the form again; it's like it never existed, everything will be cleared. Hence I said in my first reply to this thread that a form always exists in memory in VB.