Einzelnen Beitrag anzeigen

Benutzerbild von Dalai
Dalai

Registriert seit: 9. Apr 2006
1.679 Beiträge
 
Delphi 5 Professional
 
#10

AW: Form wirklich oben halten, Alternative zu FormStyle fsStayOnTop

  Alt 14. Nov 2017, 00:07
Ich nutze dafür folgende Funktion
Delphi-Quellcode:
function SetWindowAlwaysOnTop(const AForm: TForm; AOnTop: Boolean): Boolean;
var
  Lattr: HWND;
begin
    if AOnTop then
        Lattr:= HWND_TOPMOST
    else
        Lattr:= HWND_NOTOPMOST;

    Result:= SetWindowPos(AForm.Handle, // handle to window
                 Lattr, // placement-order handle {*}
                 AForm.Left, // horizontal position
                 AForm.Top, // vertical position
                 AForm.Width,
                 AForm.Height,
                 // window-positioning options
                 SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
end;
Aufgerufen z.B. mit SetWindowAlwaysOnTop(Self, True); wird dieses Fenster im Vordergrund gehalten. Natürlich kann es von anderen Fenstern, die ebenfalls TOPMOST sind, überdeckt werden, aber das ist ja klar und wohl bekannt.

Grüße
Dalai
  Mit Zitat antworten Zitat