delphi中Word的Com Add-in插件中的CommandBarButton的Click事件怎么回传(200分)

  • 主题发起人 主题发起人 lfl32512742
  • 开始时间 开始时间
L

lfl32512742

Unregistered / Unconfirmed
GUEST, unregistred user!
delphi中Word的Com Add-in插件中的CommandBarButton的Click事件怎么回传
我用delphi中Add-In做Word2000的Com Add-in插件,在Word中生成一个工具按钮,但
Click事件无法响应。
 
以前的贴有
 
可以的,
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;


三言两语说不清,
 
后退
顶部