Page 1 of 1

Print Preview / Zooming

Posted: Fri Aug 24, 2007 3:56 pm
by Shane Stump
I am implementing a Print Preview dialog by using TScaleRichView.

Once the control is in preview mode, I would like to trap MouseDown so I can handle zooming (via the ViewPropery ZoomPercent).

That is, I want the mouse button events instead of TScaleRichView handling them.

Best regards,

Shane

Posted: Fri Aug 24, 2007 7:11 pm
by Sergey Tkachenko
It can be implemented simpler, by changing SRichViewEdit1.ViewProperty.ViewMode.
This code switches editor to preview mode and back:

Code: Select all

  if SRichViewEdit1.ViewProperty.ViewMode = srvvmEditMode then
    SRichViewEdit1.ViewProperty.ViewMode := srvvmPreviewMode
  else
    SRichViewEdit1.ViewProperty.ViewMode := srvvmEditMode;

Posted: Fri Aug 24, 2007 8:17 pm
by Shane Stump
I saw that but I want zooming to work in +/- 5 % increments. What properties do I set to make that happen?

Best Regards,

Shane

Posted: Sat Aug 25, 2007 9:14 am
by proxy3d
The code below will work in the next update. In the current version, event OnClickPage works only for ViewMode = srvvmEditMode.

Code: Select all

{event OnClick on CheckBox}
procedure TFZoomPage.PreviewModeClick(Sender: TObject);
begin
  srv.ViewProperty.ZoomPercentIN := srv.ViewProperty.ZoomPercent;
  if PreviewMode.Checked then
    srv.ViewProperty.ViewMode := srvvmPreviewMode
  else
    srv.ViewProperty.ViewMode := srvvmEditMode;
end;

{Event OnClickPage on ScaleRichView}
procedure TFZoomPage.srvClickPage(Sender: TSRichViewEdit;
  Button: TMouseButton; Shift: TShiftState; X, Y, PageNo: Integer);
var
     zpB, zpE, delta : Single;
begin
  if srv.ViewProperty.ViewMode = srvvmEditMode then exit;

  if (srv.ViewProperty.ZoomPercent = srv.ViewProperty.ZoomPercentIN) then
    zpE := srv.ViewProperty.ZoomPercentOUT
  else
    zpE := srv.ViewProperty.ZoomPercentIN;
  zpB := srv.ViewProperty.ZoomPercent;

  delta := (zpE - zpB) / 20; {count of incrementations}

  while ((zpB < zpE) and (delta > 0)) or
        ((zpB > zpE) and (delta < 0)) do
    begin
      zpB := zpB + delta;
      srv.ViewProperty.ZoomPercent := zpB;
    end;
end;