trichview.com

trichview.support




Re: inserting text + applytextstyle ?


Return to index


Author

Message

Stef Mientki

Posted: 07/22/2003 22:37:30


thanks again Sergey,


it didn't fullfill my needs totally, but at least now I'm beginning to

understand a little bit about "items" (I think ...)


Sergey Tkachenko wrote:

> Actually, it is simple:

>

> rve.CurTextStyleNo := 4;

> rve.InsertText(....); // or rve.InsertStringTag()

>

> As for your code. GetCurrentLineCol and SetSelectionBounds are not

> complementary methods. GetSelectionBounds and SetSelectionBounds are.

> GetCurrentLineCol returns line and column indices in the text, not an index

> of item and offset in it.

But if you've only plain text it does apparently,

that explains why it always went ok, when inserting before any other

insertion.


I suppose that a line of plain text is an "item",

and that a textstring with another textstyle is "another item" ?


With this knowledge, I tried again,

and now the code seems to work ok.


//changed "MoveCaretTo" to return also the itemno and itemoffset

MoveCaretTo_and_return_itempos(Point.X,Point.Y,start_itemno,start_offset);


   //then this code seems to do what I want, with a dropped URL

   with richviewedit1 do

   begin

     //from the insertion point, start at new line,

     //slightly indent the line

     //and put an CR at the end

     InsertText(#13+'  '+drop_title+#13,false);


     //because a new line is inserted, itemcount is increased

     start_itemno:=start_itemno+1;

     //I don't want to highlight the leading spaces (why 3 instead of 2?)

     start_offset:=3;

     end_itemno:=start_itemno;

     end_offset:=start_offset+length(drop_title);

     SetSelectionBounds(start_itemno,start_offset,end_itemno,end_offset);

     //rest is from the example "create hyperlink"

     ApplyTextStyle(4);

     SetURLToSelection(drop_URL);

     Invalidate;

   end;



Stef Mientki





Powered by ABC Amber Outlook Express Converter