vooose,
It looks strange that you want to do that, but I believe you have your
reasons.
Here how the control class do it.
1. Create a member of the form of type GCHandle. (formRef)
2. When showing the form call GCHandle.Alloc(this, GCHandleType.Normal).
Save the returned GCHandle object in the variable formRef declared in step 1
for later use.
3. When you are ready to free the form (leave it for garbage collecting)
call formRef.Free();
This works for any objects not only forms or controls.
Other solution would be to declare a static list that will keep references
to all created instances of your form. This might be feasible solution with
forms where you can add the form reference to the list on forms Show and
remove it on Close.
--
HTH
Stoitcho Goutsev (100)
"vooose" <no****@microsoft.com> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
Form form = new Form();
when you call
ShowWindow(form, SW_SHOWNOACTIVATE);
the form disappears the next time the garbage collector is called,
assuming the form variable has gone out of scope. When you call
form.Show() you don't get this behaviour. Why is this? How can you make
ShowWindow( ) behave the same way as Show(), in that the window doesnt
disappear after the Form variable's scope is lost.
Regards
--
Wal
http://www.vooose.com
*** Sent via Developersdex http://www.developersdex.com ***