Na seção PRIVATE declare a procedure abaixo:

 

private procedure WMMove(var Msg: TWMMove);

message WM_Move;

 

Abaixo da palavra IMPLEMENTATION escreva a procedure abaixo:

 

procedure TForm1.WMMove(var Msg: TWMMove);

  begin

    if Left < 0 then

      Left := 0;

    if Top < 0 then

      Top := 0;

    if Screen.Width - (Left + Width) < 0 then

      Left := Screen.Width - Width;

    if Screen.Height - (Top + Height) < 0 then

      Top := Screen.Height - Height;

end;