This site hosted by Free.ProHosting.com
Google

How can I drag a form without caption bar?

Applies To: C++Builder 1 or higher
Category: Knowledge Base

If I use a standard form, I can drag it using the caption bar. How can I drag a form without caption bar?
 
 1.
  Start a new project using File | New Application.
 
 2.
  Edit the OnMouseMove event:
 
void __fastcall TForm1::FormMouseMove(TObject *Sender,
    TShiftState Shift, int X, int Y)
{
    // If left mouse button is clicked
    if(Shift.Contains(ssLeft))
    {
        ReleaseCapture();
        Perform(WM_NCLBUTTONDOWN, HTCAPTION, NULL);
    }
}
 
Each time the left mouse button is pressed over the caption bar, the WM_NCLBUTTONDOWN message is posted. You can simulate a caption bar click by sending this message.

C++Builder Developer's Network
Copyright © Yoto Yotov