Page 1 of 1
PrintPreview BeginEdit EndEdit question

Posted:
August 2nd, 2005, 7:56 am
by lbc
Hello
I have read in the TPrintPreview documentaton that there are the
function BeginEdit and the procedure EndEdit in order to edit an existing page.
Is there available some simple code snippet to see how to use these feature?
thank you

Posted:
August 2nd, 2005, 8:05 am
by Kambiz
There's nothing particular. Just inside BeginEdit/EndEdit block, use PrintPreview.Canvas to update the page.

Posted:
August 2nd, 2005, 11:14 am
by lbc
Hi Kambiz thank you again
so it's better to use BeginEdit/EndEdit to edit items in a page instead of recreate a page (within the BeginDoc/EndDoc block)?

Posted:
August 2nd, 2005, 12:35 pm
by Kambiz
It depends on what you are going to modify.

Posted:
August 2nd, 2005, 6:55 pm
by lbc
Hello Kambiz
let's say some graphical items drawn by the user on a drawing canvas
for example imagine the user moving a rectangle over a panel on the left and wishing to get the print preview on the right immediately updated to watch how looks the "real page" paper preview as he moves the shapes around.
for similar purposes could be used the BeginEdit/EndEdit block?
thanks again

Posted:
August 3rd, 2005, 10:02 am
by Kambiz
In your example, you have to consider that the BeginEdit/EndEdit block doesn't cause the old drawn rectangle be erased.

Posted:
August 3rd, 2005, 2:31 pm
by lbc
Hi Kambiz
ok, so basically with the BeginEdit/EndEdit I can use the canvas of an existing page to add new items (for example draw new rectangle, some text out ecc.).
As a test I have tried the following
- Code: Select all
with PrintPreview do
for PageNo := 1 to TotalPages do
if BeginEdit(PageNo) then
try
// write a simple test text
Canvas.TextOut(10,10,'EDITING PAGE: '+IntToStr(PageNo));
finally
EndEdit;
end;

Posted:
August 4th, 2005, 11:16 am
by Kambiz
Yes, this is exactly what BeginEdit/EndEdit block is supposed to do.

Posted:
August 4th, 2005, 4:21 pm
by lbc
Hi Kambiz thank you
well now I got the correct purpose of a BeginEdit/EndEdit block