Articles   Members Online:
-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
Dragging non-windowed controls at run-time 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
24-Feb-04
Category
VCL-General
Language
Delphi 2.x
Views
95
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Eber Irigoyen

Someone asked how to drag a TImage for example, and just playing with code I came 
up with this quick (and dirty?) solution.

Answer:

There's an article here on how to drag windowed controls "Dragging controls and 
forms the easy way", but that code doesn't work for TImages for example 

My solution for such thing is simply put the Image inside a TPanel and from the 
Image OnMouseDown call the code of the TPanel, thus resulting in being able to move 
the image, here's the code: 

1   procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
2     Shift: TShiftState; X, Y: Integer);
3   const
4     SC_DragMove = $F012; {this is magic (undocumented)}
5   begin
6     ReleaseCapture;
7     panel1.perform(WM_SysCommand, SC_DragMove, 0);
8   end;
9   
10  procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
11    Shift: TShiftState; X, Y: Integer);
12  begin
13    panel1mousedown(Sender, Button, Shift, X, Y)
14  end;


The same would work for resizing, or all the other things that can be done changing the constant (given that the image is aligned using alClient) 

			
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