nyt
asked on
GetActiveWindow
Hi,
I tried to use GetActiveWindow to get the handle of the active window, but failed. Can anyone tell me what's wrong with my code?
var
h:hwnd;
begin
h:=GetActiveWindow;
PostMessage(h,WM_CLOSE,0,0 );
end;
The above code can only close the program itself, but if the active window is, say, Notepad, it failed to do what I want.
Can anyone help me?
Thanks in advance.
I tried to use GetActiveWindow to get the handle of the active window, but failed. Can anyone tell me what's wrong with my code?
var
h:hwnd;
begin
h:=GetActiveWindow;
PostMessage(h,WM_CLOSE,0,0
end;
The above code can only close the program itself, but if the active window is, say, Notepad, it failed to do what I want.
Can anyone help me?
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ohh
meikl you are faster :)
meikl you are faster :)
ASKER
why doesn't EE allow two people to share the points...
nyt,
Meikl gave you the first correct answer, and he's deserve the points
Meikl gave you the first correct answer, and he's deserve the points
change ur code to use GetForegroundWindow API
var
h:hwnd;
begin
h:=GetForegroundWindow;
PostMessage(h,WM_CLOSE,0,0
end;
Mohammed