Button created only on first Inspector opened

M

Mike

I have a mature application where I use Inspector.Activate event as the
place where I add a Button to a Contact when a contact is opened.

This is the code section I am concerned with...
Set objBar = objInsp.CommandBars.item("Standard")
If objButton Is Nothing Then
Set objButton = objBar.Controls.Add(msoControlButton, , , , True)

It works just fine on the first contact opened but when I open subsequentcontacts while
the first is still open then the "If objButton Is Nothing" test bypasses adding a new
button.

Is there a better wrapper object or event that I should move my UI creation code to, or is
there some way to track new inspectors?

-mike
 
M

Michael Bauer [MVP - Outlook]

For having unique buttons I always add a counter to the name of a button.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Tue, 16 Dec 2008 23:01:35 -0500 schrieb Mike:
 
M

Mike

Am Tue, 16 Dec 2008 23:01:35 -0500 schrieb Mike:
creation code to, or is there some way to track new inspectors?


Michael Bauer said:
For having unique buttons I always add a counter to the name of a button.
Best regards
Michael Bauer - MVP Outlook

Hi Michael,
How do you test if it safe to add a new button when testing for the button object returns
True?

-mike
 
M

Michael Bauer [MVP - Outlook]

I don't understand the question. If the button exists, it exists.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 17 Dec 2008 21:35:26 -0500 schrieb Mike:
 
M

-mhd

Michael Bauer said:
I don't understand the question. If the button exists, it exists.

It exists on the first inspector but testing for existence when new inspectors (contacts)
activate I get a false *exists* and never get a get a new button on secondary inspectors.
If the all inspectors are closed then it works when I open a new one.

This was my original post:

I have a mature application where I use Inspector.Activate event as the
place where I add a Button to a Contact when a contact is opened.

This is the code section I am concerned with...
Set objBar = objInsp.CommandBars.item("Standard")
If objButton Is Nothing Then
Set objButton = objBar.Controls.Add(msoControlButton, , , , True)

It works just fine on the first contact opened but when I open subsequentcontacts while
the first is still open then the "If objButton Is Nothing" test bypasses adding a new
button.

Is there a better wrapper object or event that I should move my UI creation code to, or is
there some way to track new inspectors?

-mike
 
K

Ken Slovak - [MVP - Outlook]

You should use an Inspector wrapper class, with a collection of wrappers to
keep them alive. As Inspectors.NewInspector() fires you add the Inspector to
a new wrapper class.

Then each button gets a unique Tag to make sure a click in one Inspector
isn't handled in every Inspector.

You can download sample templates from my Web site in your language of
choice (C#, VB.NET and VB6) at
http://www.slovaktech.com/outlook_2007_templates.htm. The templates are for
Outlook 2007 but they show Inspector and Explorer wrappers and various other
things such as form regions, custom task panes, property pages and so on.




Michael Bauer said:
I don't understand the question. If the button exists, it exists.

It exists on the first inspector but testing for existence when new
inspectors (contacts)
activate I get a false *exists* and never get a get a new button on
secondary inspectors.
If the all inspectors are closed then it works when I open a new one.

This was my original post:

I have a mature application where I use Inspector.Activate event as the
place where I add a Button to a Contact when a contact is opened.

This is the code section I am concerned with...
Set objBar = objInsp.CommandBars.item("Standard")
If objButton Is Nothing Then
Set objButton = objBar.Controls.Add(msoControlButton, , , , True)

It works just fine on the first contact opened but when I open subsequent
contacts while
the first is still open then the "If objButton Is Nothing" test bypasses
adding a new
button.

Is there a better wrapper object or event that I should move my UI creation
code to, or is
there some way to track new inspectors?

-mike
 
M

Mike

Ken Slovak - said:
As Inspectors.NewInspector() fires you add the Inspector to
a new wrapper class.

Then each button gets a unique Tag to make sure a click in one Inspector
isn't handled in every Inspector.

Thanks, that is the logic my app lacks.

-mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top