Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2002, 01:56 PM
Derek Derek is offline
Senior Member
 
Join Date: Jun 2002
Posts: 559
Default Dragging a Component


Hello. What is the best way to drag a component over the screen? I can't use the onMouseMove Event because the component is too small and loses its attachment. I also just saw that using Application.OnMessage for MouseMove can make the cpu work at 100%!!!

Tx alot

[b]
Regards

Derek )
Reply With Quote
  #2  
Old 06-23-2002, 10:06 PM
DarkHorse DarkHorse is offline
Senior Member
 
Join Date: Dec 2000
Posts: 1,636
Default RE: Dragging a Component

Hi,

Try this...

procedure TForm1.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
const
SC_DragMove = $F012;
begin
Begin
ReleaseCapture;
BitBtn1.perform(WM_SysCommand, SC_DragMove, 0);
End;
end;

Good Luck.

Pls. accept if it helped.

Thanx
Tomy.
Reply With Quote
  #3  
Old 06-23-2002, 11:55 PM
extraneu extraneu is offline
Junior Member
 
Join Date: Jun 2002
Posts: 10
Default RE: Dragging a Component

I'm not sure if I understand your question. Why aren't using the integrated drag&drop features of Delphi?

Just change the DragMode of the control you want to move to dmAutomatic, or call the BeginDrag method of the control by any other way.
If you want to move the control while dragging, then put the following code in the OnDragOver handler of any control that should accept the dragged control (putting it on the form won't make a child accept it):

if Source is TControl then
begin
with TControl(Source) do
SetBounds( X, Y, Width, Height);
Accept := True;
end;


You might want to test Source = MyControl or Source is MyControlClass instead...
Reply With Quote
  #4  
Old 06-24-2002, 06:09 AM
Derek Derek is offline
Senior Member
 
Join Date: Jun 2002
Posts: 559
Default Got another way, but thank guys :-)

[b]
Got another way, but thank guys :-)

[b]
Regards

Derek )
Reply With Quote
  #5  
Old 11-28-2002, 02:43 PM
IBM IBM is offline
Senior Member
 
Join Date: Feb 2002
Posts: 178
Default RE: Dragging a Component

Why use a bit button?

what does it do that the standard button doesn't?

thanks

"Shhh!....Zog,Here Come one Now"
Reply With Quote
  #6  
Old 11-28-2002, 02:44 PM
IBM IBM is offline
Senior Member
 
Join Date: Feb 2002
Posts: 178
Default RE: Dragging a Component

so..If say I had an Text editor program I was making.
AndI wanted to allow for the user to load an image, then drag it to a position of his/her choosing...
All I have to to is on the component at design time, set the dragMode to Automatic?

thanks

"Shhh!....Zog,Here Come one Now"
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 09:03 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.