changing zoom with Ctrl + Mouse wheel
Posted: Tue Mar 16, 2010 9:51 am
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:
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.
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;
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.