Results 1 to 2 of 2

Thread: close active window automatically

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Location
    fort wayne,IN, usa
    Posts
    12

    Post

    I am trying to use API DestroyWindow
    to auto close an active window.

    in a timer,
    Dim hwnd as long
    hwnd=GetforegroundWindow
    call DestroyWindow(hwnd)

    It does not work, but if use CloseWindow
    in place of DestroyEindow, it works except
    it just minimizes the wind.
    Do I miss something?
    Thanks for any help.

  2. #2
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    Use the PostMessage API... for instance:

    Code:
    Private Declare Function GetForegroundWindow Lib "user32" () As Long
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Const WM_CLOSE = &H10
    
    Private Sub Command1_Click()
    hWndForeground = GetForegroundWindow()
    Call PostMessage(hWndForeground, WM_CLOSE, 0&, 0&)
    End Sub
    ------------------
    Tom Young, 14 Year Old
    tyoung@stny.rr.com
    ICQ: 15743470
    AIM: TomY10
    PERL, JavaScript and VB Programmer

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