Solved

DHTMLEdit problem

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

11 Experts available now in Live!

Get 1:1 Help Now