Solved

Drag and Drop Text

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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Delphi Spellcheck in Webbrowser 1 43
Delphi TcxGrid group footer summary 3 353
Broadcast a message using ICS 2 20
Firemonkey how to swip panel with finger tap 1 18
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 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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 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