Solved

dragging images.. example please

Posted on 1998-10-26
7
133 Views
Last Modified: 2010-04-06
I'm fairly new to delphi 3,
I want to drag the contents of a label to another.
This I can do.
But I want the image of the label to travel with the mouse
as I do so..
The built in help on this isn't clear enough... (dragimage.. imagelist...) what I really need is an example.. Anyone help?
0
Comment
Question by:blobb
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 1

Accepted Solution

by:
jecksom earned 50 total points
Comment Utility
Hi blobb!

Put Panel on Form then Label on Panel :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Panel1DragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
panel1.Align:=alClient;
panel1.OnDragOver:=Panel1DragOver;
label1.DragMode:=dmAutomatic;
end;

procedure TForm1.Panel1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
Tlabel(Source).left:=x;
Tlabel(Source).top:=y;
accept:=true;
end;

end.

I guess i've got your question , reject it if not :)

Jecksom

0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
Put an ImageList with some bitmap and a panel, and write this:

procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 ImageList1.SetDragImage(0,10,10); {hotspot at (10,10) in image }
 ImageList1.BeginDrag(Handle, panel1.left+x,panel1.top+y);
end;

procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
ImageList1.EndDrag;
end;

procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if ImageList1.Dragging then
   ImageList1.DragMove(panel1.left+x,panel1.top+y);
end;

0
 
LVL 5

Expert Comment

by:ronit051397
Comment Utility
Also set:     Panel1.DragMode:=dmManual;
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Hello guys.... Any of you know how to do the same thing in Delphi 4??? Doesn't matter if you drag a text or an image... What matters is to accomplish dragging... There are some oother parameters different then Source and Sender and so on.... It;s some kinda DragObject or something like that :-|

Regards,
Viktor Ivanov
0
 

Author Comment

by:blobb
Comment Utility
That's cool, many thanks.. I spent hours puzzling that..
does it only work within a panel? Will it work just on a form?

I guess I've some experimenting to do...

Thanks again
0
 

Author Comment

by:blobb
Comment Utility
That's cool, many thanks.. I spent hours puzzling that..
does it only work within a panel? Will it work just on a form?

I guess I've some experimenting to do...

Thanks again
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Hello blobb It will work on a form as well =)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now