Motaz
asked on
Check application main form focus
I want to know if my main form is focused or there is another application focused.
I tried Form's Focused property, IsWindowShowing, etc, but I didn't get any result.
Motaz
I tried Form's Focused property, IsWindowShowing, etc, but I didn't get any result.
Motaz
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, that's exactly what I want.
If GetActiveWindow = 0 then
FlashWindow(Application.Ha ndle, False);
Motaz
If GetActiveWindow = 0 then
FlashWindow(Application.Ha
Motaz
The code you've chosen doesn't guarantee you that your main form has the focus. It could be any form belonging to your app.
On the other hand, my code does.
Regards, Geo
On the other hand, my code does.
Regards, Geo
procedure TForm1.Timer1Timer(Sender:
var
h: HWND;
begin
h := GetForegroundWindow;
if IsWindow(h) then
if Application.MainForm.Handl
Label1.Caption := 'Active'
else Label1.Caption := 'Not active';
end;
Regards, Geo