Solved

dragging images.. example please

Posted on 1998-10-26
7
135 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
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using idhttp to login to instagram 2 106
How to renew a Delphi rad-studio licence? 5 69
How to debug For loops? 3 57
CheckListBox usage 3 71
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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