?
Solved

Drag and Drop

Posted on 2000-04-28
5
Medium Priority
?
262 Views
Last Modified: 2010-05-18
I've got a memo and an Edit control on a form. I want to select a portion of the text and drag it to the edit control so that I will not have to type it in the edit box. This is a good user interface technique, so how will i do it?
0
Comment
Question by:drnadeem
[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
5 Comments
 
LVL 10

Expert Comment

by:ECollin
ID: 2759696
Why don't you just use Copy/Paste on the tmemo and on the TEdit controls.
0
 
LVL 1

Expert Comment

by:l8knight
ID: 2759841
A better way to do it would be to set up a button to copy the selected text into the Edit box, then all you need is

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := Memo1.SelText;
end;

regards

l8knight

p.s. if you really want to drag and drop try the Drag and Drop Component Suite at http://www.melander.dk they are the best I have found.
0
 
LVL 6

Accepted Solution

by:
DrDelphi earned 120 total points
ID: 2759850
Try this out: (dragtext is a global String variable).


procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then  { drag only if left button pressed }
    with Sender as Tmemo do  { treat Sender as TFileListBox }
      begin
        if seltext<>'' then  { is there tezt selected? }
          dragtext:=seltext;
          BeginDrag(False);  { if so, drag it }
    end;

end;

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

procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
 edit1.text:=dragtext;
 dragtext:='';
end;
0
 
LVL 17

Expert Comment

by:inthe
ID: 2759927
looks good but how can you first select the text ?
0
 
LVL 1

Author Comment

by:drnadeem
ID: 2761422
instead of Button = mbLeft
use Button = mbRight
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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 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