Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Saving and restoring form size, position and zoom state

edited May 2003 in General
I am allowing operators to save the size, position ans zoom state of
reports. Here are code fragments to achive this. The code can be more
efficient. The forms are MDIChildren.

Save a reports size, position and zoom configuration:

if ((MDIChildren[0].Owner as TppReport).inheritsFrom(TppReport)) then
begin
Screen.Cursor := crHourGlass;
with (MDIChildren[0].Owner as TppReport) do
begin
// Report Position and size
rid := tag;
SetUserForms(rId,propTop, (MDIChildren[0].Owner as
TppReport).PreviewForm.top,'report top');
SetUserForms(rId,propLeft, (MDIChildren[0].Owner as
TppReport).PreviewForm.left,'report left');
SetUserForms(rId,propHeight, (MDIChildren[0].Owner as
TppReport).PreviewForm.height,'report height');
SetUserForms(rId,propWidth, (MDIChildren[0].Owner as
TppReport).PreviewForm.width,'report width');
I
:=TppViewer(TppReport(MDIChildren[0].Owner).PreviewForm.Viewer).CalculatedZo
om;
SetUserForms(rId,propZP,I ,'zoomPercentage');
I:=integer(TppViewer((MDIChildren[0].Owner as
TppReport).PreviewForm.Viewer).ZoomSetting);
SetUserForms(rId,propZS,I ,'zoomSetting');
end;
end;{inherits from TppReport}


Restore them:
// get the data set of 6 values
"B:= (form is not to be maximized)"
locate(fldITEM_ID,VarArrayOf([propZS]),[lopPartialKey]); // IBOBJECTS
BSetZoomPercentage :=
(FieldByname(fldIVALUE).AsInteger=integer(zsPercentage));
First;
while not EOF do
begin
itemid := FieldByname(fldITEM_ID).AsInteger;
IVal := FieldByname(fldIVALUE).AsInteger;
// restore form position and size
case itemID of
propTop: if B then (rb as TppReport).PreviewForm.Top := IVal;
propLeft: if B then rb.previewForm.Left := Ival;
propHeight: if B then rb.previewForm.Height := IVal;
propwidth: if B then rb.previewForm.Width := IVal;
propZP : if BSetZoomPercentage then
begin
tppViewer(rb.PreviewForm.Viewer).zoomPercentage :=
Ival;
tppViewer(rb.PreviewForm.Viewer).DoOnPageChange;
end;
propZS : if not BSetZoomPercentage then
begin
rb.PreviewFormSettings.ZoomSetting :=
TppZoomSettingType(IVal);
TppViewer(rb.PreviewForm.Viewer).ZoomSetting :=
TppZoomSettingType(IVal);
tppViewer(rb.PreviewForm.Viewer).DoOnPageChange;
end;
end; {case}
Next;
end; {while not EOF}

Comments

This discussion has been closed.