PDA

Click to See Complete Forum and Search --> : close active window automatically


yifeipan
Nov 9th, 1999, 10:26 AM
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.

Compwiz
Nov 10th, 1999, 03:33 AM
Use the PostMessage API... for instance:


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