This question has been answered today in the component-writing newsgroup. Source code is provided in that thread to a unit which you can add to your project to replace the previewer's behavior in order to suppress the print button.
That is possible executing one "looping" for all the existing components in the "PreviewForm". However as it does not have "Caption" and nor name in the objects, the only form that I found to identify the "PrintButton" was through its "Hint".
Example:
{ evento onPreviewFormCreate } procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject); var i, j: integer; begin for i := 0 to ppReport1.PreviewForm.ComponentCount-1 do for j := 0 to ppReport1.PreviewForm.Components[i].ComponentCount-1 do if ppReport1.PreviewForm.Components[i].Components[j] is TSpeedButton then if (UpperCase(TSpeedButton(ppReport1.PreviewForm.Components[i].Components[j]).H int) = 'IMPRIMIR') or
(UpperCase(TSpeedButton(ppReport1.PreviewForm.Components[i].Components[j]).H int) = 'PRINT') then
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject); var ButtPrint : TSpeedButton; II, JJ, ZZ : Integer; LComp, LComp2 : TComponent; begin ButtPrint := nil;
with (Sender as TppReport) do begin with (PreviewForm as TppPrintPreview) do begin for II := 0 to ComponentCount-1 do if Components[II] is TPanel{=TppPreview.ToolBar} then begin for JJ := 0 to Components[II].ComponentCount-1 do begin LComp2 := Components[II].Components[JJ]; if LComp2 is TSpeedButton then begin if TSpeedButton(LComp2).Tag = Ord(paPrint) then begin ButtPrint := TSpeedButton(LComp2); Break; end; end; if Assigned(ButtPrint) then Break; end; end; end; end;
Comments
Source code is provided in that thread to a unit which you can add to your
project to replace the previewer's behavior in order to suppress the print
button.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
That is possible executing one "looping" for all the existing components in
the "PreviewForm".
However as it does not have "Caption" and nor name in the objects, the only
form that I found to identify the "PrintButton" was through its "Hint".
Example:
{ evento onPreviewFormCreate }
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
var
i, j: integer;
begin
for i := 0 to ppReport1.PreviewForm.ComponentCount-1 do
for j := 0 to ppReport1.PreviewForm.Components[i].ComponentCount-1 do
if ppReport1.PreviewForm.Components[i].Components[j] is TSpeedButton
then
if
(UpperCase(TSpeedButton(ppReport1.PreviewForm.Components[i].Components[j]).H
int) = 'IMPRIMIR') or
(UpperCase(TSpeedButton(ppReport1.PreviewForm.Components[i].Components[j]).H
int) = 'PRINT') then
TSpeedButton(ppReport1.PreviewForm.Components[i].Components[j]).Enabled :=
False;
end;
[]s,
Alessandro Ferreira
Support Technician The Club, www.theclub.com.br.
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
var
ButtPrint : TSpeedButton;
II, JJ, ZZ : Integer;
LComp, LComp2 : TComponent;
begin
ButtPrint := nil;
with (Sender as TppReport) do
begin
with (PreviewForm as TppPrintPreview) do
begin
for II := 0 to ComponentCount-1 do
if Components[II] is TPanel{=TppPreview.ToolBar} then
begin
for JJ := 0 to Components[II].ComponentCount-1 do
begin
LComp2 := Components[II].Components[JJ];
if LComp2 is TSpeedButton then
begin
if TSpeedButton(LComp2).Tag = Ord(paPrint) then
begin
ButtPrint := TSpeedButton(LComp2);
Break;
end;
end;
if Assigned(ButtPrint) then Break;
end;
end;
end;
end;
if Assigned(ButtPrint) then
begin
....
end;
end;
Regards
Roman Krupicka