Solved

dragging images.. example please

Posted on 1998-10-26
7
138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 1

Accepted Solution

by:
jecksom earned 50 total points
ID: 1344389
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
ID: 1344390
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
ID: 1344391
Also set:     Panel1.DragMode:=dmManual;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:viktornet
ID: 1344392
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
ID: 1344393
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
ID: 1344394
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
ID: 1344395
Hello blobb It will work on a form as well =)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

724 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