Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
how to move a form without a caption bar Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Oct-02
Category
VCL-Forms
Language
Delphi 2.x
Views
168
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I have a panel that acts as a custom title bar, i.e. the window should be dragged 
by clicking inside this panel. In this case WM_NCHITTEST is not posted to TForm 
when the mouse pointer is over TPanel.

Answer:

Solve 1:

Basically you intercept the mouse-down and convert it into the equivalent of 
choosing "Move" from the System menu. You can hook the main form and any 
container-objects such as panels to the same handler.
1   
2   procedure TMainForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
3     Shift: TShiftState; X, Y: Integer);
4   begin
5     if Button <> mbLeft then
6       Exit;
7     if Shift <> [ssLeft] then
8       Exit;
9     ReleaseCapture;
10    Perform(WM_SYSCOMMAND, SC_MOVE + 2, Integer(PointToSmallPoint(Point(X, Y))));
11  end;



Solve 2:

12  var
13    OldX, OldY: Integer;
14  
15  procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
16    Shift: TShiftState; X, Y: Integer);
17  begin
18    OldX := X;
19    OldY := Y;
20  end;
21  
22  procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: 
23  Integer);
24  begin
25    if ssLeft in Shift then
26      Form1.SetBounds(Left + (X - OldX), Top + (Y - OldY), Width, Height);
27  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC