Moin smax,
so geht's
Delphi-Quellcode:
TfrmMAIN = class(TForm)
//...
procedure WMMoving(var msg : TMessage); message WM_MOVING;
//...
end;
//...
implementation
//...
procedure TfrmMAIN.WMMoving(var msg : TMessage);
var
rtDragRect : TRect;
begin
rtDragRect := TRect(Pointer(msg.lParam)^);
if (rtDragRect.Top < 0) then begin
rtDragRect.Top := 0;
rtDragRect.Bottom := rtDragRect.Top+self.Height;
end;
if (rtDragRect.Left < 0) then begin
rtDragRect.Left := 0;
rtDragRect.Right := rtDragRect.Left+self.Width;
end;
if (rtDragRect.Bottom > (Screen.Height-1)) then begin
rtDragRect.Bottom := Screen.Height;
rtDragRect.Top := rtDragRect.Bottom-self.Height;
end;
if (rtDragRect.Right > (Screen.Width-1)) then begin
rtDragRect.Right := Screen.Width;
rtDragRect.Left := rtDragRect.Right-self.Width;
end;
TRect(Pointer(msg.lParam)^) := rtDragRect;
end;
Wichtig:
Du musst aber auch noch absichern, dass die Formulargrösse innerhalb der Screenkoordinaten passt.
Ich weiss nicht was passiert, wenn das Formular z.b. höher ist, als der Screen.Height.