A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook commandbars once more



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old September 12th 06, 11:47 AM posted to microsoft.public.outlook.program_addins
Marcin Junger
external usenet poster
 
Posts: 5
Default Outlook commandbars once more

Hello everyone,
I'm writing an Outlook plugin for Outlook 2003 in Delphi 5. One of its
functions is to display a command bar in new mail inspector. I have read
a lot articles and messages on that topic but I still have sum problems.
Everything works fine when I do not use Word as editor. Problems begin
when I do.
The 1st problem: I cannot set my command bar visible. Command
cbCRM.Set_Visible(true) raises an exception.
The 2nd problem: When I open new mail inspector I have my commandbar. I
can press a button on it and hooked procedure executes. But when I open
the second new mail inspector without closing the 1st one, my command
bar is not docked and buttons are not connected. I have debugged the
code and the behaviour is the same in both OnNewInspector events...
The 3rd problem: When I have MS Word editor open and then start the new
mail inspector, the behaviour is exactly the same as if I had one new
mail inspector already opened (the 2nd problem).
I also had a problem that my bar was available in Word editor, but after
setting idWordEditor.Application.CustomizationContext := idWordEditor
the problem appears to be solved.

The code I wrote to create toolbar, button and hook up events:

procedure OnNewInspector(const Inspector : _Inspector);
var
cbCRM : CommandBar;
btnFile :CommandBarButton;
olMailItem :_MailItem;
idWordEditor : Word97._Document;
begin
(...)
//create command bar
if Inspector.CurrentItem.QueryInterface(IID__MailItem ,olMailItem) =
S_Ok then
begin
if not(olMailItem.Sent) then begin
if Inspector.IsWordMail then begin
idWordEditor := IDispatch(Inspector.WordEditor) as _Document;
try
idWordEditor.Application.CustomizationContext := idWordEditor;
finally
pointer(idWordEditor) := nil;
end;
end;

cbCRM :=
Inspector.CommandBars.Add('CRM',EmptyParam,EmptyPa ram,EmptyParam) as
CommandBar;
cbCRM.Set_Position(msoBarTop);
//cbCRM.Set_Visible(true); -exception when word
end;
if assigned(cbCRM) then begin
btnFile :=
FindOrAddButton(cbCRM.Controls,Trans('sendandfile' ),'sendandfile',Trans('sendandfile'));
if assigned(btnFile) then begin
btnFile.Set_Style(msoButtonIconAndCaption);
MakeConnection(btnFile, DIID__CommandBarButtonEvents, 1,
oEmbeddedCRM.SendAndFile);
end;
end;
end;


function
TOutlookAddin.FindOrAddButton(Controls:CommandBarC ontrols;vButtonName,vResourceName,vToolTip:string) :CommandBarButton;
var
x : integer;
begin
result:=nil;
for x:=1 to Controls.Count do
begin
if (Controls.Item[x].Caption=vButtonName) then
begin
result := Controls.Item[x] as CommandBarButton;
break;
end;
end;
if result=nil then
begin
result := Controls.Add(msoControlButton, EmptyParam, EmptyParam,
EmptyParam, EmptyParam) as CommandBarButton;
result.Set_Caption(vButtonName);
if vResourceName'' then
BmpToBtn(vResourceName,result);
if vToolTip'' then
result.Set_TooltipText(Trans(vToolTip));
end;
end;

procedure TOutlookAddin.MakeConnection(
Unk : IUnknown;
EventIID : TGUID;
EventDispID : integer;
EventProc : TOutlookEventProc;
EventDispID1 : integer=0;
EventProc1 : TOutlookEventProc=nil;
EventDispID2 : integer=0;
EventProc2 : TNewExplorerEvent=nil;
//BJR .60 - need lots more types of events for the OnNewInspector and
//ItemAdd event......
EventDispID3 : integer=0;
EventProc3 : TItemsEvents=nil;
EventDispID4 : integer=0;
EventProc4 : TInspectorsEvents=nil
);
var
CPC: IConnectionPointContainer;
EventClass : TOutlookEventClass;
begin

EventClass := TOutlookEventClass.Create;

EventClass.EventIID:=EventIID;
EventClass.EventProc:=EventProc;
EventClass.EventDispID:=EventDispID;
EventClass.EventProc1:=EventProc1;
EventClass.EventDispID1:=EventDispID1;
EventClass.EventProc2:=EventProc2;
EventClass.EventDispID2:=EventDispID2;
EventClass.EventProc3:=EventProc3;
EventClass.EventDispID3 := EventDispID3;
EventClass.EventProc4:=EventProc4;
EventClass.EventDispID4 := EventDispID4;

if Succeeded(Unk.QueryInterface(IConnectionPointConta iner, CPC)) then
if Succeeded(CPC.FindConnectionPoint(EventIID, EventClass.CP)) then
begin
//EventClass.CP._AddRef;
EventClass.CP.Advise(EventClass, EventClass.Cookie);
end;
EventList.AddObject('',EventClass);
end;

Do you have any ideas, comments or suggestions?
Marcin Junger
Sage Ireland
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Inspector CommandBars and MS Word Yuri Loban Add-ins for Outlook 4 July 12th 06 07:26 AM
deleting CommandBars Mark J. McGinty Add-ins for Outlook 5 July 5th 06 04:07 PM
Newbie question to CommandBars Claus Schiroky Outlook and VBA 1 May 10th 06 07:01 AM
Outlook commandbars Radiohead Add-ins for Outlook 1 January 25th 06 03:35 PM
how to use the CommandBars Collection Jim B Outlook - Using Forms 0 January 22nd 06 01:46 AM


All times are GMT +1. The time now is 08:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.