?
Solved

dragging images.. example please

Posted on 1998-10-26
7
Medium Priority
?
141 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 150 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

741 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