How to make the form could be dragged over any arbitrary area of the form?
- In the simplest case, process WM_NCHITTEST and return HT_CAPTION - karmadro4
|
2 answers
One of the options, the most cute to me.
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ReleaseCapture; SendMessage(Form1.Handle, WM_SYSCOMMAND, $F012, 0) ; end; - The magic number is not cute at all :( - karmadro4
- Alas,
SC_DRAGMOVEin Dephi is not defined anywhere. - Nofate ♦ - The nice thing here is that everything about everything took 2 lines and one handler. - Nofate ♦
- > Alas, SC_DRAGMOVE in Dephi is not defined anywhere. Pretty weak excuse. By the way, the method with WM_NCHITTEST will be no less concise. - karmadro4
- Nobody forbids you to write somewhere
const SC_DRAGMOVE = $F012;> By the way, the method with WM_NCHITTEST will be no less concise. I agree. But the WM_NCHITTEST method has one drawback: mouse events will no longer come to the form. - Nofate ♦ 2:29 pm
|
Add the following to the form announcement:
type TForm1 = class(TForm) ... private { Private declarations } procedure WMNCHITTEST(var Msg: TWMNCHitTest);message WM_NCHITTEST; and write the following in the code itself:
procedure TForm1.WMNCHITTEST(var Msg: TWMNCHitTest); begin Inherited; with Msg do if Result = htClient then Result := htCaption; end; |