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
Solved

Drag and Drop Text

Posted on 2013-12-02
4
447 Views
Last Modified: 2013-12-02
hello guys

I have three objects on my form, an Image and two listbox.

There is a listbox with somewords that I'd like to drag it to my empty listbox and insert the text there, but I'd like to know how can I drag and drop the text on the image and it send the text to the listbox above it.

I am sending an example made in D7, please give me an example how to do that, drag and drop text from listbox to another and listbox to image that will send automaticly to the above listbox.

Thanks
Alex
DropImage.zip
0
Comment
Question by:hidrau
  • 2
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Thommy
ID: 39689540
I think that's it, what you are looking for...
How to Move ListBox Items with the Mouse (Drag and Drop)
0
 
LVL 1

Author Comment

by:hidrau
ID: 39689553
Hello Thommy,

From a listbox to another listbox I know how, but if I drag the text into the image, how can I send it automatically to my empty listbox? That is the problem.
0
 
LVL 19

Accepted Solution

by:
Thommy earned 500 total points
ID: 39689906
Below code adds Listbox2 drag item to Listbox1, when dropped on Image1...

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Image1: TImage;
    ListBox1: TListBox;
    ListBox2: TListBox;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Image1DragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure Image1DragOver(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
  ListBox2.DragMode := dmAutomatic;
end;

procedure TForm1.Image1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  ListBox1.Items.Add( (Source as TListBox).Items[(Source as TListBox).ItemIndex] );
end;

procedure TForm1.Image1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := Source = ListBox2;
end;

end.

Open in new window

DropImageNew.zip
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 39691343
Thanks very much for the help
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Suggested Solutions

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

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