Hello,
I am trying to insert a Bitmap from Clipboard into a TRichView document in the position of caret but always it inserts in the beginning of the document.
I write some lines of text in the document and at the end of it I need to insert a picture. I copy the picture to Clipboad as Bitmap and I am using 'MyDoc.PasteBitmap' to insert the piture in the position of caret but to no avail.
I tried put the caret at the document's end by hand (as below) but to no avail as well.
---
if (RVDoc.ItemCount > 0) then
begin
RVDoc.Format;
ItemNo := RVTrab.ItemCount - 1;
Offs := RVTrab.GetOffsAfterItem(ItemNo);
RVDoc.SetSelectionBounds(ItemNo,Offs,ItemNo,Offs);
RVDoc.Format;
end;
---
Is there some additional step in order to get the 'PasteBitmap' function work?
Another question: to make the picture centered in the page can I use the 'Aligment' property from 'TParaInfo'?
Thanks for any help.
Inserting Bitmap in position of caret
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
AddPictureEx is designed for document generation.
If you want to insert picture in the caret position, use InsertPicture, or PasteBitmap method.
PS: Format moves the caret to the beginning of the document.
It's enough to call
Formatted editor always has at least one item (empty text item), so it's safe to assume ItemCount>0.
If you want to insert picture in the caret position, use InsertPicture, or PasteBitmap method.
PS: Format moves the caret to the beginning of the document.
It's enough to call
Code: Select all
ItemNo := RVTrab.ItemCount - 1;
Offs := RVTrab.GetOffsAfterItem(ItemNo);
RVDoc.SetSelectionBounds(ItemNo,Offs,ItemNo,Offs);
Hello, Sergey,
As I told before I can insert a picture in a document without problems, but I need ALL pictures be centralized horizontally. The document is been built like below:
---
some text;
picture
some text;
picture
some text;
picture
...
---
The problem is that all the text has the correct alignment that I want, but ALL picture is left aligned except the last one that is center aligned as expected. Looks like the doc looses the alignment when there is more text after the picture. I think this because the text following the picture is center aligned but the picture is always left aligned altough I set the picture's aligment to center.
I tried lots of things but I can't get the picture center aligned horizontally except the last one.
Do you have some tip for this?
Regards.
As I told before I can insert a picture in a document without problems, but I need ALL pictures be centralized horizontally. The document is been built like below:
---
some text;
picture
some text;
picture
some text;
picture
...
---
The problem is that all the text has the correct alignment that I want, but ALL picture is left aligned except the last one that is center aligned as expected. Looks like the doc looses the alignment when there is more text after the picture. I think this because the text following the picture is center aligned but the picture is always left aligned altough I set the picture's aligment to center.
I tried lots of things but I can't get the picture center aligned horizontally except the last one.
Do you have some tip for this?
Regards.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Hello,
The document is build from scratch. It is not an existing document. I am using the 'rvaCenter' in the paragraph aligment, but I don't know why just after the picture been inserted, if I insert a new text after it the just inserted picture looses the alignment and changes it to rvaLeft. All the text inserted, each one with different alignments, are correct. This problem just occurs with the inserted pictures. I am using the 'PasteBitmap' function to copy a picture that is generated in my application and then paste it into the document been generated. The picture is inserted on the caret position but looses the alignment, except the last one that doesn't have text after it.
What could be the cause of this problem?
Thanks.
The document is build from scratch. It is not an existing document. I am using the 'rvaCenter' in the paragraph aligment, but I don't know why just after the picture been inserted, if I insert a new text after it the just inserted picture looses the alignment and changes it to rvaLeft. All the text inserted, each one with different alignments, are correct. This problem just occurs with the inserted pictures. I am using the 'PasteBitmap' function to copy a picture that is generated in my application and then paste it into the document been generated. The picture is inserted on the caret position but looses the alignment, except the last one that doesn't have text after it.
What could be the cause of this problem?
Thanks.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
If you build document from scratch, it's better to use different methods: AddPictureEx and AddTextNL. These methods have ParaNo parameter, where you can specify an index (in RVStyle.ParaStyles) of paragraph style with center or left alignment.
When generation is finished, call Format.
If you insist on using editing methods, they should be like:
When generation is finished, call Format.
If you insist on using editing methods, they should be like:
Code: Select all
rve.InsertText(...);
rve.InsertText(#13);
rve.ApplyParaStyle(index of centered para);
rve.PasteBitmap (or rve.InsertPicture);
rve.InsertText(#13);
rve.ApplyParaStyle(index of left-aligned para);
rve.InsertText(...);
...