changing zoom with Ctrl + Mouse wheel

General TRichView support forum. Please post your questions here
Post Reply
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

changing zoom with Ctrl + Mouse wheel

Post by Cosmin3 »

Hi.
I'm trying to implement in my editor (which is using ScaleRichView) Ctrl+MouseWheel>>ChangingZoom. Just like in Word...
In SclRView.pas (at "TSRichViewEdit = class(TCustomControl)") I have declared a public variable: IsScrollDisabled (Boolean).
In TSRichViewEdit.HookMouseWheelEvent most of the code is running only if IsScrollDisabled is False. In essence when IsScrollDisabled is True ScaleRichView is not scrolling the text.
At ScaleRichView1 OnKeyDown event:
ScaleRichView1.IsScrollDisabled := (Shift = [ssCtrl]) and (Key = 17);
At ScaleRichView1 OnKeyUp event:
ScaleRichView1.IsScrollDisabled := False;
And at ScaleRichView1 OnMouseWheel event:

Code: Select all

   if Shift = [ssCtrl] then begin
      if WheelDelta > 0 then
         if cmbListZoom.ItemIndex < cmbListZoom.Items.count - 3 then begin
            cmbListZoom.ItemIndex := cmbListZoom.ItemIndex + 1;
            cmbListZoomChange(Self);
         end;
      if WheelDelta < 0 then
         if (cmbListZoom.ItemIndex > 0) and (cmbListZoom.ItemIndex < cmbListZoom.Items.count - 2) then begin
            cmbListZoom.ItemIndex := cmbListZoom.ItemIndex - 1;
            cmbListZoomChange(Self);
         end;
3 questions:
1. Is it ok to do it like that or is there a better way...?
2. How can I know the value of Zoom factor for PageWidth and FullPage so I can increase/decrease properly on any Zoom value?
3. Is there a way to increase/decrease Zoom in smaller "steps"..?

Thank you in advance for any help.
Best regards.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

We plan to add Ctrl+MouseWheel zooming as a standard optional feature (that can be turned off). Probably will be included in the next update.
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post by Cosmin3 »

I understand.
Thank you for your reply.
Best regards.
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post by proxy3d »

Added the new version of SRV 3.2
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: changing zoom with Ctrl + Mouse wheel

Post by jgkoehn »

Greetings Sergey,
Was this added as a standard option? If so where might I find the setting? I did find other ways to do it but no point in doing a lot of extra if already there.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: changing zoom with Ctrl + Mouse wheel

Post by Sergey Tkachenko »

Yes, this is a standard option in ScaleRichView. It is active by default.
To disable Ctrl+mouse wheel zooming, assign SRichViewEdit.ViewProperty.MouseWheelZoom = False.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: changing zoom with Ctrl + Mouse wheel

Post by jgkoehn »

Greetings Sergey,
Is it the same for TRichViewEdit or just ScaleRichView?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: changing zoom with Ctrl + Mouse wheel

Post by Sergey Tkachenko »

Only in ScaleRichView.

Please note that zooming is completely different in TRichView and ScaleRichView.
In ScaleRichView, documents are always formatted in a fixed DPI, zoom affects only displaying.
In TRichView, zoom is implemented by changing document DPI, It affects both displaying and formatting. So, when you assign a new value of DocumentPixelsPerInch, you need to reformat TRichVIew (call Reformat method). For large documents, it may take some time.
So I do not think that mouse wheel zooming in TRichViewEdit is a good idea.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: changing zoom with Ctrl + Mouse wheel

Post by jgkoehn »

Ah thanks yes, it can take time, more of a set once per document thing. Thanks
Post Reply