TIcon problem

General TRichView support forum. Please post your questions here
Post Reply
umi
Posts: 9
Joined: Fri Aug 03, 2007 1:18 pm

TIcon problem

Post by umi »

Hello
I want to insert icon file (.ico) into my RichView document. The icon file is 16x16 size and is i one line with text it's mean the line starts with text then I insert a picture and and after the picture I added another text after this operation I formated document. The document look like the inserted icon is bigger than it should be, when I make some operation after the inserted icon (delete char, insert char) the document is reformated and icon have their orginal size.
The code looks like :

RichViewEdit1.AddText('Some text ', 0);
ico := TIcon.Create;
ico.LoadFromFile('word.ico'); // 16x16 icon file
RichViewEdit1.AddPicture(ico);
RichViewEdit1.AddText(' Some other text', 0);
RichViewEdit1.Format;

Is there any way to fix/baypass the problem
RichViewEdit ver 1.9.45.1

Thanks in advance.
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This is a problem with TIcon.
Until it is drawn (or, more exactly, until its Handle is used), it returns system default icon size (usually 32 x 32).
I added a workaround in TRichView code.
Until the next update, you can call:

RichViewEdit1.AddText('Some text ', 0);
ico := TIcon.Create;
ico.LoadFromFile('word.ico'); // 16x16 icon file
ico.Handle;
RichViewEdit1.AddPicture(ico);
RichViewEdit1.AddText(' Some other text', 0);
RichViewEdit1.Format;
umi
Posts: 9
Joined: Fri Aug 03, 2007 1:18 pm

Post by umi »

The workaround works.
Thanks for help.
Post Reply