Results 1 to 4 of 4

Thread: unload form: only knowing handle

  1. #1

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    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

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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:
    1. Option Explicit
    2.  
    3. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    4.      ByVal hwnd As Long, _
    5.      ByVal wMsg As Long, _
    6.      ByVal wParam As Long, _
    7.      ByRef lParam As Any) As Long
    8.  
    9. Private Const WM_CLOSE As Long = &H10
    10.  
    11. Private Sub Command1_Click()
    12.     SendMessage Form2.hwnd, WM_CLOSE, 0, 0
    13. End Sub
    Last edited by iPrank; Aug 7th, 2006 at 09:31 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: unload form: only knowing handle

    ... or use CloseWindows():
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
    4.  
    5. Private Sub Command1_Click()
    6.     CloseWindow SomeHWnd 'SomeHWnd must be declared as Long
    7. End Sub

  4. #4

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Re: unload form: only knowing handle

    Quote Originally Posted by RhinoBull
    ... or use CloseWindows():
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
    4.  
    5. Private Sub Command1_Click()
    6.     CloseWindow SomeHWnd 'SomeHWnd must be declared as Long
    7. End Sub
    Thanx, I'll try it... can't use unload form, because the tab control only knows the handle...

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