unload form: only knowing handle
Hi all,
I have a question that is likely a bit unusual: I use a given tabcontrol. I create tabs on it dynamically. A tab can host a form by its handle, so I can set an OLE_HANDLE on each of the tabs to host a form.
Now, if I close the tab, the form still keeps on living in the background, while I want to unload this form.
The question: is it possible to unload a form, only knowing its OLE_HANDLE?
Thanx in advance for the answer,
JMvV
Re: unload form: only knowing handle
Are the forms form same project ? Why you aren't trying, Unload FormName ?
If they are outside windows, how 'bout sending them WM_CLOSE message ?
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any) As Long
Private Const WM_CLOSE As Long = &H10
Private Sub Command1_Click()
SendMessage Form2.hwnd, WM_CLOSE, 0, 0
End Sub
Re: unload form: only knowing handle
... or use CloseWindows():
VB Code:
Option Explicit
Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Command1_Click()
CloseWindow SomeHWnd 'SomeHWnd must be declared as Long
End Sub
Re: unload form: only knowing handle
Quote:
Originally Posted by RhinoBull
... or use CloseWindows():
VB Code:
Option Explicit
Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Command1_Click()
CloseWindow SomeHWnd 'SomeHWnd must be declared as Long
End Sub
Thanx, I'll try it... can't use unload form, because the tab control only knows the handle...