Author: Jonas Bilinkevicius
I want my form to snap to the left border of the screen as soon as it gets close
(Form1.Left<=30) to it. How can I do that?
Answer:
Use the WM_WindowPosChanging message:
1 2 procedure WMWindowPosChanging(varmessage: TWMWindowPosChanging);
3 message WM_WindowPosChanging;
4 { ... }5 6 procedure TForm1.WMWindowPosChanging(varmessage: TWMWindowPosChanging);
7 begin8 inherited;
9 withmessage.WindowPos^ do10 if x < 30 then11 x := 0;
12 end;