Articles   Members Online: 3
-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
Work around for bug in RichEdit when using PasteFromClipboard, while PlainText = 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
29-Oct-02
Category
Reporting /Printing
Language
Delphi 5.x
Views
89
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Maarten de Haan

If you work with a RichEdit and you set the property PlainText to True, then you 
can get formatted text into your RichEdit when you use: 

RichEdit1.PasteFromClipboard;

Because you set PlainText to True, you are not able to "unformat" this text again. 
A work around for this problem is using the procedure below. (This is a well known 
bug! On the site of Borland you'll find another - but very complicated - work 
around at: http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=13345)

Answer:
1   
2   //----------------------------------------------------------------------
3   procedure TForm1.EditPasteClick(Sender: TObject);
4   
5   var
6     h: THandle;
7     pchP: PChar;
8     asS0: ANSIstring;
9   
10  begin
11    ClipBoard.Open;
12    try
13      h := Clipboard.GetAsHandle(CF_TEXT);
14      pchP := GlobalLock(h);
15      asS0 := StrPas(pchP);
16      GlobalUnlock(h);
17    finally
18      Clipboard.Close;
19    end;
20    if Length(asS0) > 0 then
21      RichEdit1.SelText := asS0; // Copy in where the cursor / caret is.
22  end;
23  //----------------------------------------------------------------------


			
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