Results 1 to 4 of 4

Thread: Closing Windows

  1. #1

    Thread Starter
    Fanatic Member Illspirit's Avatar
    Join Date
    Mar 2001
    Location
    Blackpool, England
    Posts
    815

    Closing Windows

    How do i close all of the active windows??? I have the code to minimise them, but ive been having problems getting it to close them.
    Illspirit - [email protected]

    SmartBarXP Lead Developer
    SmartBarXP - The leading desktop sidebar application for Microsoft Windows XP

  2. #2
    Megatron
    Guest
    Add to a Module
    Code:
    Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) 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 Const WM_QUIT = &H12
    
    Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
    PostMessage hwnd, WM_CLOSE, 0, 0
    PostMessage hwnd, WM_QUIT, 0, 0
    EnumWindowsProc = 1
    End Function
    To trigger it:
    Code:
    EnumWindows AddressOf EnumWindowsProc, 0

  3. #3
    Megatron
    Guest
    Actually, that might close your own window. Try this instead:
    Code:
    Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) 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 Const WM_QUIT = &H12
    
    Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
    If hwnd <> Form1.hWnd then
        PostMessage hwnd, WM_CLOSE, 0, 0
        PostMessage hwnd, WM_QUIT, 0, 0
        EnumWindowsProc = 1
    End If
    End Function

  4. #4

    Thread Starter
    Fanatic Member Illspirit's Avatar
    Join Date
    Mar 2001
    Location
    Blackpool, England
    Posts
    815

    dodgy!

    when i use your second code, it still closes the app window, but leaves another window open
    Illspirit - [email protected]

    SmartBarXP Lead Developer
    SmartBarXP - The leading desktop sidebar application for Microsoft Windows XP

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