Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Plugin not working in RB7?

edited February 2006 in General
Hi,

I've downloaded the HidePrintButton plugin example, but it's not working
correctly. When I'm trying to hide the print button, the entire toolbar
doesn't have any buttons.

So I expanded the example to view/hide the other buttons by constructing
a small procedure within my (registered) preview class. Trying to hide
some of the other buttons simply has no effect - they're still visible.
Trying to hide the print button still gives the result mentioned above.

Is this approach incompatible with V7.04, or is the example just
incomplete?

TIA,
Michael

--- Here goes my code ---
unit uRepPreview;

interface

uses
Buttons, StdCtrls, ppPreview, ppTypes;

type
TPreviewPlugin1 = class(TppPreview)
private
function GetSpeedButtonForPreviewAction(aPreviewAction:
TppPreviewActionType): TSpeedButton;
procedure EnableAction(aPreviewAction: TppPreviewActionType; V:
boolean);

public
procedure BeforePreview; override;


end;

implementation

uses
Graphics, SysUtils, Controls;


function TPreviewPlugin1.GetSpeedButtonForPreviewAction(aPreviewAction:
TppPreviewActionType): TSpeedButton;
var
x: integer;
C: TControl;
begin
Result := nil;
x := 0;

while (Result = nil) and (x < Toolbar.ControlCount) do begin
C := Toolbar.Controls[x];

if (C.Tag = Ord(aPreviewAction)) then Result := TSpeedButton(C)
else Inc(x);
end;
end;

procedure TPreviewPlugin1.EnableAction(aPreviewAction:
TppPreviewActionType; V: boolean);
var
spbtnAction: TSpeedButton;
begin
case aPreviewAction of
paPrint,
paAutoSearch,
paTextSearch,
paWholePage,
paPageWidth,
pa100Percent,
paFirst,
paPrior,
paNext,
paLast,
paClose,
paGoToPage:
begin
spbtnAction := GetSpeedButtonForPreviewAction(aPreviewAction);
if spbtnAction <> nil then spbtnAction.Visible := V;
end;
end;
end;

procedure TPreviewPlugin1.BeforePreview;
var
btnPrint: TSpeedButton;
begin
inherited BeforePreview;

// won't work, entire toolbar is empty
EnableAction(paPrint, false);

// won't work, simply has no effect
EnableAction(paPageWidth, false);

end;


initialization
TppPreviewPlugIn.Register(TPreviewPlugin1);

finalization
TppPreviewPlugIn.UnRegister(TPreviewPlugin1);

end.

Comments

This discussion has been closed.