Mep Sites - Dicas

Mep Sites: Dicas de Delphi - Não deixa arrastar sua janela para fora da tela

Impedir que o form seja arrastado para fora das margens da tela.

//Declare na seção private:
private
procedure WMMove(var Msg: TWMMove); message WM_MOVE;


//depois, na seção implementation:
implementation


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;