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
Print Preview / Zooming
-
- Site Admin
- Posts: 17534
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
It can be implemented simpler, by changing SRichViewEdit1.ViewProperty.ViewMode.
This code switches editor to preview mode and back:
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;
-
- Posts: 54
- Joined: Mon Jul 31, 2006 2:10 am
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;