Results 1 to 4 of 4

Thread: Unloading forms using hWnd

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    36

    Question Unloading forms using hWnd

    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.

  2. #2
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613
    This code will minimise the window. May be not what you want?
    Code:
    Option Explicit
    
    Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Sub Form_Load()
        CloseWindow Me.hwnd
    End Sub

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I almost forgot the declaration
    VB Code:
    1. Declare Function DestroyWindow Lib "user32" Alias "DestroyWindow" (ByVal hwnd As Long) As Long
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width