Solved

dragging images.. example please

Posted on 1998-10-26
7
136 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
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!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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