View Single Post
  #8  
Old February 9th 06, 10:31 AM posted to microsoft.public.outlook.program_addins
Sergey Anchipolevsky
external usenet poster
 
Posts: 6
Default Help! Inspector.Close is fired before Inspector.Activate handler finishes

Hello Dmitry,

I need the overall enumeration because I have to disable many functions that
aren't consistent with my custom form's functionality. To be more specific,
I have a list of controls that should be left enabled in the custom form.
The rest of the buttons must be hidden. This is a project requirement.

Also, the addin must work under different versions of Outlook which have
different sets of buttons. Since I don't know a priori the exact set of controls
to be hidden, I cannot use FindControl(), but I can iterate over all the
controls and determine if this one must be hidden or not.

WBR,
Sergey Anchipolevsky

That should work, but... Why do you need to enumerate through *all*
controls
in an inspector? If you are using the Word editor, there could be
thousands
of them. Do you really care about all of them?
Did you try to use FindControl() instead to only work with the
controls
thata you care about?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Sergey Anchipolevsky" wrote in message
.com...

Hello Dmitry,

If your code in the Activate event handler does anything that can
potentially run the Windows message loop (such sa displaying a
message box or any other window), then Close event can potentially
fire while Activate is still beign processed. What do you do in the
Activate event handler?

I followed Josh's advice and found out that the message loop is
pumped in
CommandBars.GetEnumerator(). (very surprising actually).
I use this method to iterate through toolbar buttons and menu items
in
order to hide some of them upon inspector activation.
I implemented the following workaround that seems to work quite well.

I subclassed the inspector's window with the code that suppresses
WM_CLOSE message when it comes while the Activate handler is running.
In the end of the Activate method I explicitly call Inspector.Close()
if WM_CLOSE message has been received.

What do you think about this solution?

WBR,
Sergey Anchipolevsky



Ads
 

Credit Cards - Ringtone - Credit Cards - Credit Card UK - Mobile Phones