Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DHTMLEdit problem

Posted on 2002-05-07
3
Medium Priority
?
442 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

715 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