Board index » delphi » Outlook COM Add-in email inspector commandbar button event sinking problem
Bruno Fierens [tmssoftware.com]
![]() Delphi Developer |
Outlook COM Add-in email inspector commandbar button event sinking problem2004-08-23 10:25:48 PM delphi278 Would someone have an idea why handling from OnStartupComplete, this code to add an event sink for a new button created in a new commandbar works as expected: FButton: CommandBarButton; FCommandBar: CommandBar; FCookie: Longint; FEventSink: TEventSink; FEventSink := TEventSink.Create(CommandBarButtonClick); InterfaceConnect(FButton, DIID__CommandBarButtonEvents, FEventSink, FCookie); FCommandBar.Visible := True; but for a commandbar button created in the email Inspector, this is not working, ie. no events are handled by the eventsink? This shows how the commandbar button was created & event sink attached: oItem := FApplication.CreateItem(olMailItem); oCBS := oItem.GetInspector.CommandBars; CmdBarsInsp := CommandBars(oCBS); for i := 1 to CmdBarsInsp.Count do begin if CmdBarsInsp.Item[i].Name = 'BrunosBar' then FCommandBarInsp := CommandBar(CmdBarsInsp.Item[i]); end; if FCommandBarInsp = nil then FCommandBarInsp := CmdBarsInsp.Add('BrunosBar', EmptyParam, EmptyParam, EmptyParam); if FCommandBarInsp.Controls_.Count>0 then Control := FCommandBarInsp.Controls_.Item[1] else Control := FCommandBarInsp.Controls_.Add(msoControlButton, EmptyParam, EmptyParam, EmptyParam, EmptyParam); // access control as command bar button FButtonInsp := CommandBarButton(Control); FButtonInsp.Caption := 'Bruno''s Button'; FButtonInsp.Style := msoButtonIconAndCaption; rh := LoadBitmap(sysinit.HInstance , MakeIntResource(101)) ; if (rh <>0) then begin Image1 := TImage.Create(nil); try Image1.Picture.Bitmap.Handle := rh ; clipboard.Assign( Image1.Picture.Graphic) ; finally Image1.Free ; end ; end ; FButtonInsp.PasteFace ; FButtonInsp.Visible := True; FButtonInsp.TooltipText := 'Tip for my button' ; // hook up Click event FEventSinkInsp := TEventSink.Create(InspectorButtonClick); InterfaceConnect2(FButtonInsp, DIID__CommandBarButtonEvents, FEventSinkInsp, FCookieInsp); FCommandBarInsp.Visible := True; oItem := unassigned; Same was tried by inserting the button from the NewInspector event (using an event sink for NewInspector) and also in this case, the button / commandbar is succesfully added to the email inspector, but no way to get the button click event. ? Any tips / hints would be very welcome Thanks, Bruno |