Switching to the next page when end of page has been reached
Switching to the next page when end of page has been reached
I would like TRichViewEdit control automatically switch to next page when the end of page has been reached. How can I do this ?
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You can do it in OnMouseWheel* events.
For example, RichViewActions's print preview dialog scrolls to next/previous page on mouse wheel, and changes zooming on Ctrl + mouse wheel (but only if TRVPrintPreview is not focused; otherwise, mouse wheels scrolls inside the component; but you can implement your own logic)
For example, RichViewActions's print preview dialog scrolls to next/previous page on mouse wheel, and changes zooming on Ctrl + mouse wheel (but only if TRVPrintPreview is not focused; otherwise, mouse wheels scrolls inside the component; but you can implement your own logic)
My solution:
Code: Select all
TRVPrintPreview = class(TCustomRVPrintPreview)
private
FVScrollDownAgain: Integer;
FVScrollUpAgain: Integer;
...
protected
...
{$IFDEF RICHVIEWDEF4}
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
{$ENDIF}
...
constructor TRVPrintPreview.Create(AOwner: TComponent);
begin
inherited;
FCachePageImage := False;
FVScrollUpAgain := 0;
FVScrollDownAgain := 0;
end;
function TRVPrintPreview.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean;
begin
Result := inherited DoMouseWheelDown(Shift, MousePos);
FVScrollUpAgain := 0;
if Result and (VScrollPos = VScrollMax) then
begin
if (FVScrollDownAgain > 3) and (PageNo < GetPageCount()) then
begin
FVScrollDownAgain := 0;
VScrollPos := 0;
Next;
end;
Inc(FVScrollDownAgain);
end;
end;
function TRVPrintPreview.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean;
begin
Result := inherited DoMouseWheelUp(Shift, MousePos);
FVScrollDownAgain := 0;
if Result and (VScrollPos = 0) then
begin
if (FVScrollUpAgain > 3) and (PageNo > 1) then
begin
FVScrollUpAgain := 0;
VScrollPos := VScrollMax;
Prev;
end;
Inc(FVScrollUpAgain);
end;
end;