bsalsa - Delphi tips, tricks, code snippets,Samples Component Search Engine.

The current search engine database includes about 5000 Delphi web sites and growing...

By pressing the button, you can add the Search engine to your iGoogle. Add to Google


Go Back   EmbeddedWB - bsalsa forum > Editors & Parsers > DHTMLEdit/Html Editor Components
FAQDonate Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-10-2006, 01:13 PM   #1
Stojo303
Junior Member
 
Join Date: Nov 2006
Posts: 19
Question Force "plain-text" when pasting text

Hello, is it possible to force text that's in the clipboard to be pasted as "plain-text" in the HTMLEditor?

The common situation is:

1) Copy text from IE/Other browser
2) The text in the clipboard is in HTML/Rich text format with formattings etc
3) When pasted in the HTML edit control, all formattings are kept, therefore the pasted result may look bad because of missing CSS etc.

Any ideas?

Thanks in advance,
Mikael
Stojo303 is offline   Reply With Quote
Old 12-10-2006, 11:06 PM   #2
Stojo303
Junior Member
 
Join Date: Nov 2006
Posts: 19
Just to clearify a bit.. The problem is that I cannot catch the OnPaste event before the actual content is pasted. If I could, I think I could "recreate" the clipboard content as text or something like that.

Regards,
Mikael
Stojo303 is offline   Reply With Quote
Old 12-15-2006, 03:09 AM   #3
SergeV
Developer
 
Join Date: Aug 2006
Posts: 140
Quote:
Originally Posted by Stojo303 View Post
Just to clearify a bit.. The problem is that I cannot catch the OnPaste event before the actual content is pasted. If I could, I think I could "recreate" the clipboard content as text or something like that.
You must implement OnFilterDataObject handler.
SergeV is offline   Reply With Quote
Old 12-16-2006, 05:11 PM   #4
Stojo303
Junior Member
 
Join Date: Nov 2006
Posts: 19
Thanks for the reply SergeV,

Any ideas where I can found documentation/examples for this?

Thanks,
Mikael
Stojo303 is offline   Reply With Quote
Old 12-17-2006, 03:38 AM   #5
SergeV
Developer
 
Join Date: Aug 2006
Posts: 140
Quote:
Originally Posted by Stojo303 View Post
Any ideas where I can found documentation/examples for this?
http://msdn.microsoft.com/library/de...dataobject.asp
SergeV is offline   Reply With Quote
Old 12-17-2006, 01:16 PM   #6
Stojo303
Junior Member
 
Join Date: Nov 2006
Posts: 19
Thanks a lot SergeV,

After a few hours struggling with the method I finally managed to solve it.

Regards,
Mikael
Stojo303 is offline   Reply With Quote
Old 12-17-2006, 07:31 PM   #7
SergeV
Developer
 
Join Date: Aug 2006
Posts: 140
Quote:
Originally Posted by Stojo303 View Post
After a few hours struggling with the method I finally managed to solve it.
My congratulations. A few hours struggling with microsoft stuff is good result.
SergeV is offline   Reply With Quote
Old 12-18-2006, 09:17 AM   #8
smot
Main Developer
 
smot's Avatar
 
Join Date: May 2006
Posts: 805
Stojo303, could you post some source code? Would help other people too.
smot is offline   Reply With Quote
Old 12-18-2006, 05:09 PM   #9
Stojo303
Junior Member
 
Join Date: Nov 2006
Posts: 19
Sure, but I can only publish the very basics of my code:

The FilterDataObject method looks like the code below.
Comments will follow after the code block:

var
Dataobject: TDOText;
Formats: IEnumFORMATETC;
TempFormat: TFormatEtc;
ss: string;
Found: boolean;
begin
Result := S_FALSE;
pDO.EnumFormatEtc(DATADIR_GET, Formats);
Found := False;
while (not Found) and (Formats.Next(1, TempFormat, nil) = S_OK) do
begin
if TempFormat.cfFormat = CF_TEXT then
begin
ss := GetTextData(pDO, TempFormat);

Dataobject :=
TDOText.Create(nil);
Dataobject.Text := ss;
ppDORet := Dataobject;

found := true;
Result := S_OK;
end;
end;
end;


The most code should be pretty straightforward.
The method "GetTextData" just extracts the textual contents for the specific format to a string.

TDOText is a class I have written which basicly just implements the IDataObject interface. (It is derived from TInterfacedObject).
I cannot publish that class since it's "owned" by my company.

Anyway, I hope the code above helps a bit.

Regards,
Mikael
Stojo303 is offline   Reply With Quote
Old 01-11-2007, 07:18 PM   #10
bsalsa
Developer
 
bsalsa's Avatar
 
Join Date: Jan 1970
Posts: 1,295
Cool
bsalsa is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT +3. The time now is 03:05 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
bsalsa@gmail.com