//added to uses clause uses ppThumbnailViewer, ppOutlineNotebook;
procedure MyForm.PreviewFormCreate(Sender: TObject); begin TppThumbnailViewer(TppPrintPreview(TppReport (Sender).PreviewForm).AccessoryToolbar).OnMouseWheel := PreviewFormMouseWheel; end;
procedure MyForm.PreviewFormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin with TppThumbnailViewer(TppOutlineNotebook(TPanel(Sender).Components[0]).Components [1]).VertScrollBar do Position := Position -(WheelDelta div 5); Handled := True; end;
In the PreviewFormMouseWheel procedure Sender is a TPanel. TPanel.Components[0] is a TppOutlineNotebook. TPanel.Components[0].Components[1] is the TppThumbnailViewer.
procedure TMy_Form.PreviewFormCreate(Sender: TObject); var i, h: Integer; begin with TppPrintPreview(TppReport(Sender).PreviewForm).AccessoryToolbar do for i := 0 to ComponentCount -1 do if (Components[i] is TppOutlineNotebook) then begin with TppOutlineNotebook(Components[i]) do for h := 0 to ComponentCount -1 do if (Components[h] is TppThumbnailViewer) then begin TppThumbnailViewer(Components[h]).OnMouseWheel := PreviewFormMouseWheel; Break end; Break; end; end;
procedure TMy_Form.PreviewFormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin with TppThumbnailViewer(Sender).VertScrollBar do Position := Position -(WheelDelta div 5); Handled := True; end;
Thanks for posting your solution. The TppOutlineNotebook is a tab control that contains two pages (tabs). One for the OutlineViewer and one for the ThumbnailViewer. An easier way to access the ThumbnailViewer would be by directly accessing the OutlineNotebook.
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject); begin TppPrintPreview(ppReport1.PreviewForm).OutlineNotebook.ThumbnailViewer.OnMouseWheel := ThumbnailMouseWheelEvent;
Comments
I discovered that the following works:
//added to uses clause
uses
ppThumbnailViewer, ppOutlineNotebook;
procedure MyForm.PreviewFormCreate(Sender: TObject);
begin
TppThumbnailViewer(TppPrintPreview(TppReport (Sender).PreviewForm).AccessoryToolbar).OnMouseWheel := PreviewFormMouseWheel;
end;
procedure MyForm.PreviewFormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
with TppThumbnailViewer(TppOutlineNotebook(TPanel(Sender).Components[0]).Components [1]).VertScrollBar do Position := Position -(WheelDelta div 5);
Handled := True;
end;
In the PreviewFormMouseWheel procedure Sender is a TPanel. TPanel.Components[0] is a TppOutlineNotebook. TPanel.Components[0].Components[1] is the TppThumbnailViewer.
Perhaps there is a simpler way?
Best Regards,
Tommy
Here is what I ended up with:
procedure TMy_Form.PreviewFormCreate(Sender: TObject);
var
i, h: Integer;
begin
with TppPrintPreview(TppReport(Sender).PreviewForm).AccessoryToolbar do
for i := 0 to ComponentCount -1 do
if (Components[i] is TppOutlineNotebook) then
begin
with TppOutlineNotebook(Components[i]) do
for h := 0 to ComponentCount -1 do
if (Components[h] is TppThumbnailViewer) then
begin
TppThumbnailViewer(Components[h]).OnMouseWheel := PreviewFormMouseWheel;
Break
end;
Break;
end;
end;
procedure TMy_Form.PreviewFormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
with TppThumbnailViewer(Sender).VertScrollBar do Position := Position -(WheelDelta div 5);
Handled := True;
end;
Best Regards,
Tommy
Thanks for posting your solution. The TppOutlineNotebook is a tab control that contains two pages (tabs). One for the OutlineViewer and one for the ThumbnailViewer. An easier way to access the ThumbnailViewer would be by directly accessing the OutlineNotebook.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
So much less work!
Thank You,
Tommy