Solved

Get <p>, <span>, <ul> and <ol> from DHTMLEdit

Posted on 2004-04-14
8
277 Views
Last Modified: 2010-04-04
How can I get the code from a paragraph or span tag in DHTMLEdit?
What I want to do is change a paragraph tag from <p> to somethig like <p style=""> etc... I want to do the same thing with the span, ol and ul tags, but I have no idea how to do this.

Marko
0
Comment
Question by:Bindza
  • 4
  • 4
8 Comments
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10826578
procedure TForm1.Button1Click(Sender: TObject);
var
List: Tstrings;
begin
  List := TSTringList.Create;
  try
  List.LoadFromFile('c:\file.htm');
  List.Text := STringReplace(List.Text,'<p>','<p style = "">',[rfReplaceAll, rfIgnoreCase]);
  finally
  list.Free;
end;
0
 

Author Comment

by:Bindza
ID: 10831752
This is not what I ment, I know how to get and replace all of them, but i need the tag from the current line the caret is in.
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10831801
mmm...you said --> What I want to do is change a paragraph tag from <p> to somethig like <p style="">....

So please explain better what do you need (maybe with some example)
0
 

Author Comment

by:Bindza
ID: 10842216
Well I'm trying to make a format paragraph dialog, like in Front Page. It has the align property, then there's indenting and spacing.
This is where I got so far:

procedure TForm1.Button1Click(Sender: TObject);
var
 r: IHTMLTxtRange;
begin
r := DHTMLEdit1.DOM.selection.createRange as IHTMLTxtRange;
FormatParagraphWin.ShowModal;
if FormatParagraphWin.ModalResult = mrOK then
 begin
  if FormatParagraphWin.AlignBox.ItemIndex = 0 then
   r.parentElement.style.textAlign := ''
  else
   r.parentElement.style.textAlign := FormatParagraphWin.AlignBox.Items.Strings[FormatParagraphWin.AlignBox.ItemIndex];
   r.parentElement.style.lineHeight := OleVariant(IntToStr(FormatParagraphWin.SpBox.ItemIndex * 50) + '%');
   r.parentElement.style. <-- here I wanna add the indent and spacing property, but I don't know how. I want to add these : indent before, indent after, indent first line, spacing before, spacing after and word spacing.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 250 total points
ID: 10842398
ah ok....
Sorry but the only thing that i know for this is the MSDN SDK link to the IHTMLStyle Interface with all properties listed....

Hope it helps

http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/style/style.asp

0
 

Author Comment

by:Bindza
ID: 10843095
Thanks for your help, but I've just solved the problem myself, like this:


procedure TForm1.Button1Click(Sender: TObject);
var
 r: IHTMLTxtRange;
begin
if DHTMLEdit1.DOM.selection.type_ = 'Text' then
 begin
  r := DHTMLEdit1.DOM.selection.createRange as IHTMLTxtRange;
  FormatParagraphWin.ShowModal;
   // set paragraph styles
  if FormatParagraphWin.ModalResult = mrOK then
   begin
    if FormatParagraphWin.AlignBox.ItemIndex = 0 then
     r.parentElement.style.textAlign := ''
    else
     r.parentElement.style.textAlign := FormatParagraphWin.AlignBox.Items.Strings[FormatParagraphWin.AlignBox.ItemIndex];
    r.parentElement.style.marginLeft := OleVariant(FormatParagraphWin.IndBefore.Value);
    r.parentElement.style.marginRight := OleVariant(FormatParagraphWin.IndAfter.Value);
    r.parentElement.style.textIndent := OleVariant(FormatParagraphWin.IndFirst.Value);
    r.parentElement.style.marginTop := OleVariant(FormatParagraphWin.SpBefore.Value);
    r.parentElement.style.marginBottom := OleVariant(FormatParagraphWin.SpAfter.Value);
    r.parentElement.style.wordSpacing := OleVariant(FormatParagraphWin.SpWord.Value);
    r.parentElement.style.lineHeight := OleVariant(IntToStr((FormatParagraphWin.SpBox.ItemIndex + 1)*50) + '%');
    // reset dialog controls
    with FormatParagraphWin do
     begin
      IndBefore.Value := 0;
      IndAfter.Value := 0;
      IndFirst.Value := 0;
      AlignBox.ItemIndex := 0;
      SpBefore.Value := 0;
      SpAfter.Value := 0;
      SpWord.Value := 0;
      SpBox.ItemIndex := 1;
     end;
   end;
 end;
end;
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10843182
Solved by yourself?
I hope that it is, because it seems just that you got exactly the needed params after my link post....

BTW good work.
0
 

Author Comment

by:Bindza
ID: 10848533
I've been on that site 100 times and couldn't understand a thing. Thanks for your help anyway. You deserve these points, so I'll give um to you.

Cheers!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Create a Restore Point In Windows 10 3 102
FMX enumerated colours 2 72
find a node in VST 2 46
SUM 2 INTEGER ARRAYS INTO 1 10 56
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

12 Experts available now in Live!

Get 1:1 Help Now