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

Creating toolbar in new Explorer



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 13th 09, 01:44 PM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 23
Default Creating toolbar in new Explorer

Hi,
I read through all the available information regarding creating of a
toolbar in new windows. I found out that when creating a new inspector
one should:

handle newinspector event and advise for the activate event

inside the inspectoractivate handler create the toolbar

inside the close event destroy the toolbar

Everything works fine. Each button is given a unique tag as Ken Slovak
suggested and so only the correct button click handler gets called. So
far so good.

My question is: how to do the same for the new explorer window? The
difference is that the exploreractivate event does not get called
until i deactivate and then reactivate the window, which means that I
am forced to create my GUI in inside the newexplorer event where all
the objects are not guaranteed to be initialized. Any solutions?

Thanks
  #2  
Old May 13th 09, 02:13 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Creating toolbar in new Explorer

Any Explorer opened after the initial Explorer will fire NewExplorer().
Handle that for those Explorers and use that to get the Activate() event for
that Explorer. Use unique Tag values as you would with an Inspector.

For the initial Explorer Activate() won't fire in almost all cases normally.
So you use Explorer.BeforeFolderSwitch() and Explorer.SelectionChange(). I
add handlers for all 3 events for every Explorer that gets opened, and check
a _startup flag in those events to see if UI creation is needed. If so I
create the UI and then set _startup to False. You'll find that for that
first Explorer you will get the SelectionChange() event, and therefore your
UI will be created.

One other thing that you probably will need will be Inspector and Explorer
wrapper classes and collections. That allows you to individually handle
multiple open Inspectors or Explorers, and to handle individual button
states per window. For example, say you have a toggle button and want each
open window to maintain an individual state for each button instance.
Wrappers are the way to do that.

The wrapper class holds an instance of the Inspector/Explorer, a reference
to the current item or folder in that window, and a Key value that's unique
per window. Any event handlers and code specific to that window instance are
packaged in the wrapper class so that each handles any event individually
(thus the importance of unique Tag values).

I use a global Key integer and increment for any new Inspector or Explorer
that gets opened. That is then appended to my Tag GUID to make unique Tag
values per window. The Close() events, Send() or whatever else, including
BeforeFolderSwitch() and SelectionChange(), are handled in the classes.

Then I add each new wrapper class to an Explorer or Inspector
collection/list/whatever to ensure it stays alive and if using managed code
doesn't get garbage collected.

There are lots of examples of wrappers at www.outlookcode.com, and I have
addin templates with wrappers for C#, VB.NET and VB6 for Outlook 2007 on my
Web site at http://www.slovaktech.com/outlook_2007_templates.htm.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


wrote in message
...
Hi,
I read through all the available information regarding creating of a
toolbar in new windows. I found out that when creating a new inspector
one should:

handle newinspector event and advise for the activate event

inside the inspectoractivate handler create the toolbar

inside the close event destroy the toolbar

Everything works fine. Each button is given a unique tag as Ken Slovak
suggested and so only the correct button click handler gets called. So
far so good.

My question is: how to do the same for the new explorer window? The
difference is that the exploreractivate event does not get called
until i deactivate and then reactivate the window, which means that I
am forced to create my GUI in inside the newexplorer event where all
the objects are not guaranteed to be initialized. Any solutions?

Thanks


  #3  
Old May 13th 09, 03:41 PM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 23
Default Creating toolbar in new Explorer

Any Explorer opened after the initial Explorer will fire NewExplorer().
Handle that for those Explorers and use that to get the Activate() event for
that Explorer. Use unique Tag values as you would with an Inspector.

For the initial Explorer Activate() won't fire in almost all cases normally.
So you use Explorer.BeforeFolderSwitch() and Explorer.SelectionChange(). I
add handlers for all 3 events for every Explorer that gets opened, and check
a _startup flag in those events to see if UI creation is needed. If so I
create the UI and then set _startup to False. You'll find that for that
first Explorer you will get the SelectionChange() event, and therefore your
UI will be created.


Here is what I did:
inside the OnNewExplorer handler I instantiate my ExplorerWrapper
class. Within its constructor I do:

m_spExplorer-Activate(); // --- Does this ensure that all
objects get created by the time I hit the following lines?
CloseEvent:ispEventAdvise((IDispatch*)m_spExplor er);
ToolbarWrapper = new CToolbarWrapper(m_spExplorer);
m_spExplorer-get_CommandBars(&spCmdBars);
ToolbarWrapper-CreateGUI(spCmdBars);

Are there any errors in my logic? If so, then I will try going the
Activate/BeforeFolderSwitch/SelectionChange way, but I am not sure
that those handlers will be called soon enough (i.e. to ensure that
the toolbar is visible right after the explorer window pops up)
  #4  
Old May 14th 09, 07:38 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Creating toolbar in new Explorer

The logic of what I explained works correctly and has for years. That first
Explorer will not fire Activate() for you by the time you can create an
object reference to it and set up event handlers, it will already have
fired. Unless the Explorer is deactivated and then activated again what you
propose will not work on that first Explorer. It will work on all others
opened later on.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


wrote in message
...
Any Explorer opened after the initial Explorer will fire NewExplorer().
Handle that for those Explorers and use that to get the Activate() event
for
that Explorer. Use unique Tag values as you would with an Inspector.

For the initial Explorer Activate() won't fire in almost all cases
normally.
So you use Explorer.BeforeFolderSwitch() and Explorer.SelectionChange().
I
add handlers for all 3 events for every Explorer that gets opened, and
check
a _startup flag in those events to see if UI creation is needed. If so I
create the UI and then set _startup to False. You'll find that for that
first Explorer you will get the SelectionChange() event, and therefore
your
UI will be created.


Here is what I did:
inside the OnNewExplorer handler I instantiate my ExplorerWrapper
class. Within its constructor I do:

m_spExplorer-Activate(); // --- Does this ensure that all
objects get created by the time I hit the following lines?
CloseEvent:ispEventAdvise((IDispatch*)m_spExplor er);
ToolbarWrapper = new CToolbarWrapper(m_spExplorer);
m_spExplorer-get_CommandBars(&spCmdBars);
ToolbarWrapper-CreateGUI(spCmdBars);

Are there any errors in my logic? If so, then I will try going the
Activate/BeforeFolderSwitch/SelectionChange way, but I am not sure
that those handlers will be called soon enough (i.e. to ensure that
the toolbar is visible right after the explorer window pops up)


 




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
Adding custom buttons to the Standard toolbar versus a custom toolbar [email protected] Add-ins for Outlook 2 October 9th 08 05:13 PM
VBA for creating Category toolbar in Outlook 2003 Melody Outlook and VBA 7 September 12th 07 03:13 PM
creating toolbar button to Mark As Read & Delete Andrea Outlook and VBA 2 June 21st 07 07:26 PM
Help with explorer 7 Mal Outlook Express 1 December 21st 06 12:31 AM
Email hyperlinks open Windows Explorer, not Internet Explorer M Skabialka Outlook - General Queries 2 July 7th 06 09:39 PM


All times are GMT +1. The time now is 05:13 AM.


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.