可以的,
TCommandBarButton = class(TOleServer)
private
FIntf: CommandBarButton;
FOnClick: TCommandBarButtonClick;
function GetDefaultInterface: CommandBarButton;
procedure SetOnClick(const Value: TCommandBarButtonClick);
protected
procedure InitServerData;
override;
procedure InvokeEvent(DispID: TDispID;
var Params: TVariantArray);
override;
public
procedure Connect;
override;
procedure ConnectTo(svrIntf: CommandBarButton);
procedure Disconnect;
override;
property DefaultInterface: CommandBarButton read GetDefaultInterface;
published
property OnClick : TCommandBarButtonClick read FOnClick write SetOnClick;
end;
.....
procedure SaveDraftClick(const Ctrl: OleVariant;
var CancelDefault: OleVariant);
procedure SendClick(const Ctrl: OleVariant;
var CancelDefault: OleVariant);
procedure saveTmpClick(const Ctrl: OleVariant;
var CancelDefault: OleVariant);
procedure usersClick(const Ctrl: OleVariant;
var CancelDefault: OleVariant);
function createButton(BtnParent: Commandbar;
ACap: wideString;
cnBtn: TcommandBarButton;
ClickEvent: TCommandBarButtonClick;
imgId: integer): _CommandBarButton;
begin
Result := BtnParent.Controls.Add(msoControlButton, EmptyParam,
EmptyParam, 1, True) as _CommandBarButton;
with Resultdo
begin
Set_Style(msoButtonIconAndCaption);
result.Set_Caption(ACap);
Set_Tag(Caption);
result.Set_FaceId(imgId);
cnBtn.ConnectTo(result);
cnBtn.OnClick:=ClickEvent;
end;
end;
三言两语说不清,