Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to drag and drop text from a TRichEdit to other components Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
12-Oct-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
107
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I would like to select text in a TRichEdit control, then drag and drop the text on 
another (non TRichEdit) component (ie. TEdit or TMemo). Simulating this behavior 
would be fine. The drag- related events are not firing when I drag text, so I 
assume the drag and drop behavior is embedded in the Windows control. But I don't 
see any drag-related messages in the Windows SDK online help.

Answer:

I've got a unit "uGenDragDrop", that implements IDropTarget (amongst others), and 
allows you to easily add OLE Drag and Drop support to any Delphi component (i.e. 
allow you to drag and drop not only within a Delphi application, but also in and 
out of Delphi applications).

Here is a snippet of code that implements OLE drop support for a TMemo on a form.

1   uses
2     uGenDragDrop;
3   
4   procedure TForm1.FormCreate(Sender: TObject);
5   begin
6     DTMemo := TDropTarget.Create(Memo1);
7     DTMemo.AddFormat(CF_TEXT, [asComplete], [meGlobMemory]);
8   end;
9   
10  procedure TForm1.Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
11    State: TDragState; var Accept: Boolean);
12  begin
13    Accept := TRUE;
14  end;
15  
16  procedure TForm1.Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
17  begin
18    Memo1.Lines.Add((Source as TStorageMedium).GetText);
19  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC