pcox9999
asked on
SetWindowPos causes taskbar button to flash
I need to make a form in an application always be the top z ordered form on a messy desktop, and explicitly set focus to an edit box in the form. When I call SetWindowPos it always brings the form to the topmost z position but the focus is set to the application's button on the taskbar which is flashing. I need that to stop and instead have focus appear in a waiting TEdit of the form.
Is there a work around for the behavior of SetWindowPos or another technique.
Is there a work around for the behavior of SetWindowPos or another technique.
SetWindowPos(Self.Handle,
HWND_TOPMOST,
Top,
Left,
Width,
Height,
SWP_NOMOVE + SWP_NOSIZE)
ASKER
That won't work. Focus is on the taskbar button for the app. The taskbar button is flashing. This is the behavior of Windows SetWindowsPos. I tried using Windows.SetForegroundWindo w(Self.Han dle); but that too sets the application button on the taskbar to flash. The solution seems to be outside my app and in Windows. BTW, I am using Delphi 2007 and Windows XP Pro.
This means your app isn't the active app, and a window in your app has changed focus or z-order
Do you want your app to remain inactive ?
if you change your app to active first and then change the z-order this flashing shouldn't happen
Do you want your app to remain inactive ?
if you change your app to active first and then change the z-order this flashing shouldn't happen
ASKER
Doesn't help. Maybe I'm leaving something out of my code. Here is the FormShow method that is giving me a headache. Note that the extra call to SetForegroundWindow makes no difference if it is in or commented out.
Thanks.
Thanks.
procedure TfrmPatLookup.FormShow(Sender: TObject);
begin
{set the z order for all the windows forms so this
form is the topmost}
Self.ActiveControl := Self.ePatient;
SetWindowPos(Self.Handle,
HWND_TOPMOST,
Top,
Left,
Width,
Height,
SWP_NOMOVE + SWP_NOSIZE);
SetForegroundWindow(Self.Handle);
if Self.ePatient.CanFocus then
Self.epatient.SetFocus;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
procedure TForm1.Test;
begin
Form2.ActiveControl := Form2.Edit1;
end;