private
procedure FormMove(var Msg: TWMMove); message WM_MOVE;
procedure TForm1.FormMove(var Msg: TWMMove);
var
WorkArea: TRect;
begin
inherited;
if SystemParametersInfo(SPI_GETWORKAREA, 0, @WorkArea, 0) then
begin
if Left < WorkArea.Left then
Left := WorkArea.Left
else if Left + Width > WorkArea.Right then
Left := WorkArea.Right - Width;
if Top < WorkArea.Top then
Top := WorkArea.Top
else if Top + Height > WorkArea.Bottom then
Top := WorkArea.Bottom - Height;
end;
end;