Button created only on first Inspector opened

  • Thread starter Thread starter Mike
  • Start date Start date
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
 
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:
 
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
 
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
 
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
 
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
 
Back
Top