|
-
May 22nd, 2001, 04:18 PM
#1
Thread Starter
Fanatic Member
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.
-
May 22nd, 2001, 04:24 PM
#2
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
-
May 22nd, 2001, 04:27 PM
#3
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
-
May 22nd, 2001, 05:16 PM
#4
Thread Starter
Fanatic Member
dodgy!
when i use your second code, it still closes the app window, but leaves another window open
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|