Thema: Delphi Andocken an Rändern

Einzelnen Beitrag anzeigen

DieHardMan

Registriert seit: 16. Jul 2002
Ort: Stuttgart
68 Beiträge
 
  Alt 29. Aug 2002, 12:00
für den bildschirmrand

Code:
  private
    { Private declarations }
    procedure WMWindowPosChanging(var Message: TWMWINDOWPOSCHANGING);
    message WM_WINDOWPOSCHANGING;

procedure TForm1.WMWindowPosChanging(var Message: TWMWINDOWPOSCHANGING);
const
  distance = 10;
begin
  { Obere und untere Festerkante }
  if (Message.WindowPos.y <= distance) AND
    (Message.WindowPos.y >= -distance) then
      Message.WindowPos.y := 0
  else
    if (Message.WindowPos.y + Height > (Screen.WorkAreaHeight - distance)) AND
      (Message.WindowPos.y + Height < (Screen.WorkAreaHeight + distance)) then
        Message.WindowPos.y := Screen.WorkAreaHeight - Height;

  { Linke und rechte Fensterkante }
  if (Message.WindowPos.x <= distance) AND
    (Message.WindowPos.x >= -distance) then
      Message.WindowPos.x := 0
  else
    if (Message.WindowPos.x + Width > (Screen.WorkAreaWidth - distance)) AND
      (Message.WindowPos.x + Width < (Screen.WorkAreaWidth + distance)) then
        Message.WindowPos.x := Screen.WorkAreaWidth - Width;
end;
Alle meine Entchen...
  Mit Zitat antworten Zitat