Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DHTMLEdit problem

Posted on 2002-05-07
3
Medium Priority
?
444 Views
Last Modified: 2010-04-04
DHTMLEdit problem

I have problem with ReplaceInfo. I can not compile project.

var
HTMLDoc : IHTMLDocument2;
Selection : IHTMLSelectionObject;
TextRange : IHTMLTxtRange;
St : String;
begin
HTMLDoc := DHTMLEdit.DOM as IHTMLDocument2;
Selection := HTMLDoc.Selection as IHTMLSelectionObject;

if Selection.type_ = 'Text' then
begin
TextRange := Selection.CreateRange as IHTMLTxtRange;
// Get the selected HTML code
St := DHTMLEdit.FilterSourceCode(TextRange.htmlText);
// Change the information in the HTML code
ReplaceInfo(St);
// Paste the HTML code back into the document;
TextRange.pasteHTML(St);
end;
end;
0
Comment
Question by:treqw
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 800 total points
ID: 6995423
i left a comment in your other q,
you can delete this one if you want you gave me enough points already this week :)

to replace the selected text just change the line to

St := 'hello'; //or whatever your new string will be.
0
 

Author Comment

by:treqw
ID: 6995737
How to replace selected DHTMLEdit control (HTML text) with another :


Selected :
{
<TABLE cellSpacing=0 cellPadding=0 width=288 align=center border=0><TBODY>
  <TR>
    <TD width=288 colSpan=2><A href="http://www.online.hr/"><IMG
                  alt="GlobalNet Online" src="" border=0></A></TD></TR>
  TR>
    <TD height=10></TD></TR></TBODY></TABLE>
}

Replaced
{
<TABLE cellSpacing=0 cellPadding=0 width=100%><TBODY>
  <TR>
    <TD width=288 colSpan=2><A href="http://www.exoperts-exchange.hr/"><IMG
                  alt="GlobalNet Online" src="" border=0></A></TD></TR>
  TR>
    <TD height=10></TD></TR></TBODY></TABLE>
}
0
 
LVL 17

Expert Comment

by:inthe
ID: 6996191
example of changing html:

procedure TForm1.Button2Click(Sender: TObject);
var
HTMLDoc : IHTMLDocument2;
Selection : IHTMLSelectionObject;
TextRange : IHTMLTxtRange;
St : String;
begin
HTMLDoc := DHTMLEdit1.DOM as IHTMLDocument2;
Selection := HTMLDoc.Selection as IHTMLSelectionObject;
if Selection.type_ = 'Text' then
begin
TextRange := Selection.CreateRange as IHTMLTxtRange;
St := DHTMLEdit1.FilterSourceCode(TextRange.text);
showmessage(textrange.Get_htmlText);
//will show the html source

st := '<b>new text</b>';  //now change it
TextRange.pasteHTML(St); //and paste into control
end;
end;
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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

885 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