|
Office2000(2003) 下 outlook,word 的 com addin 之 delphi实现!(整理摸索)(4) public constrUCtor Create(AOwner: TComponent); override; destrUCtor Destroy; override; procedure Connect; override; procedure ConnectTo(svrIntf: CommandBarButton); procedure Disconnect; override; property DefaultInterface: CommandBarButton read GetDefaultInterface; published property OnClick : TCommandBarButtonClick read FOnClick write SetOnClick; end; //实施部分 { TCommandBarButton } procedure TCommandBarButton.Connect; var punk: IUnknown; begin if FIntf = nil then begin punk := GetServer; ConnectEvents(punk); Fintf:= punk as CommandBarButton; end; end; procedure TCommandBarButton.ConnectTo(svrIntf: CommandBarButton); begin Disconnect; FIntf := svrIntf; ConnectEvents(FIntf); end; constrUCtor TCommandBarButton.Create(AOwner: TComponent); begin inherited; end; destrUCtor TCommandBarButton.Destroy; begin inherited; end; procedure TCommandBarButton.Disconnect; begin if Fintf <> nil then begin DisconnectEvents(FIntf); FIntf := nil; end; end; function TCommandBarButton.GetDefaultInterface: CommandBarButton; begin if FIntf = nil then Connect; Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation'); Result := FIntf; end; procedure TCommandBarButton.InitServerData;
|