Solved

DHTMLEdit problem

Posted on 2002-05-07
3
431 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 200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now