Во время перемещения формы по экрану мы будем обрабатывать сообщение WMWINDOWPOSCHANGING. а вот код: Code private procedure WMWINDOWPOSCHANGING (Var Msg: TWMWINDOWPOSCHANGING); message WM_WINDOWPOSCHANGING; public end; ... procedure TfrMain.WMWINDOWPOSCHANGING(var Msg: TWMWINDOWPOSCHANGING); const StickAt : Word = 10; var rWorkArea: TRect; begin SystemParametersInfo (SPI_GETWORKAREA, 0, @rWorkArea, 0); with rWorkArea, Msg.WindowPos^ do begin if x <= Left + StickAt then x := Left; if x + cx >= Right - StickAt then x := Right - cx; if y <= Top + StickAt then y := Top; if y + cy >= Bottom - StickAt then y := Bottom - cy; end; inherited; end;
|