Solved

DHTMLEdit problem

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
proper way to parse url in delphi 2 191
TVirtualStringTree  search using TEdit 7 119
How to debug For loops? 3 49
Delphi: making a BW image transparent 10 35
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

10 Experts available now in Live!

Get 1:1 Help Now