2007. augusztus 18., szombat

Move a form with the mouse in the client area


Problem/Question/Abstract:

I once saw a very short example of moving a form with the mouse. It's the same like moving the form with the mouse in the caption of the form, but now it is moveable with the mouse in the client area. Has anyone an idea how to do this?

Answer:

In the private declarations of the form add this message handler:

private
{ Private declarations }

procedure WMNCHitTest(var M: TWMNCHitTest); message WM_NCHITTEST;

Then add this procedure

procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
begin
  inherited;
  if M.Result = htClient then
  begin
    {Client area is hit - but state it is the Title Bar}
    if ((m.ypos - HelpWin.top) < HelpWin.height) then
      M.Result := htCaption;
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése