Das hier dauert ein paar Milisekunden:
Delphi-Quellcode:
type
TForm1 = class(TForm)
private
{ Private-Deklarationen }
procedure WMMove(var Message: TWMMove); message WM_MOVE;
public
{ Public-Deklarationen }
end;
procedure TForm1.WMMove(var Message: TWMMove);
begin
If (Message.XPos < 0) then
Left := 0;
If (Message.YPos < GetSystemMetrics(SM_CYCAPTION)) then
Top := 0;
If Assigned(Parent) then
begin
If (Message.XPos > (Parent.Width - Width)) then
Left := Parent.Width - Width;
If (Message.YPos > (Parent.Height - Height - GetSystemMetrics(SM_CYCAPTION))) then
Top := Parent.Height - Height;
end
else
begin
If (Message.XPos > (Screen.Width - Width)) then
Left := Screen.Width - Width;
If (Message.YPos > (Screen.Height - Height - GetSystemMetrics(SM_CYCAPTION))) then
Top := Screen.Height - Height - GetSystemMetrics(SM_CYCAPTION);
end;
Message.result := 0;
end;