2017년 3월 9일 목요일

[Delphi] MDI Child Form staying on Top


Add TApplicationEvents to form that should stay on top, in design mode set FormStyle to fsNormal (not fsStayOnTop !!)
then

Form's OnActivate evet handler:

procedure TWinInfo.FormActivate(Sender: TObject);
begin
 SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
end;

ApplicationEvents' OnActivate event handler:

procedure TWinInfo.ApplicationEventsActivate(Sender: TObject);
begin
 if Visible then
   SetWindowPos(Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
end;

ApplicationEvents' OnDeActivate event handler:

procedure TWinInfo.ApplicationEventsDeactivate(Sender: TObject);
begin
 if Visible then
   SetWindowPos(Handle,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
end;

댓글 없음:

댓글 쓰기