PDA

Click to See Complete Forum and Search --> : Unloading forms using hWnd


stevemelaaron
Jul 12th, 2001, 11:47 AM
Is it possible to unload a form using its handle? That is to say, is there an equivalent WinAPI call to VB's UNLOAD method/statement? I have already tried DestroyWindow, and when I go to load the form for reuse in my program, VB gives me an 'Invalid call or procedure' error.

TheBao
Jul 12th, 2001, 04:08 PM
This code will minimise the window. May be not what you want?

Option Explicit

Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Form_Load()
CloseWindow Me.hwnd
End Sub

Vlatko
Jul 12th, 2001, 06:58 PM
CloseWindow
The CloseWindow function minimizes (but does not destroy) the specified window.

BOOL CloseWindow(
HWND hWnd // handle to window to minimize
);

Parameters
hWnd
Handle to the window to be minimized.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, callGetLastError.

Remarks
The window is minimized by reducing it to the size of an icon and moving the window to the icon area of the screen. The system displays the window's icon instead of the window and draws the window's title below the icon.

To destroy a window, an application must use the DestroyWindow function.


So use the DestroyWindow API

Vlatko
Jul 12th, 2001, 06:59 PM
I almost forgot the declaration

Declare Function DestroyWindow Lib "user32" Alias "DestroyWindow" (ByVal hwnd As Long) As Long