Solved

Drag and Drop Text

Posted on 2013-12-02
4
440 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now