Creating toolbar in new Explorer

  • Thread starter Thread starter tnemec78@googlemail.com
  • Start date Start date
Status
Not open for further replies.
T

tnemec78@googlemail.com

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

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
 
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.

<tnemec78@googlemail.com> wrote in message

news:4696c4a0-2d1a-4726-8053-ba12e844c905@z7g2000vbh.googlegroups.com...
> 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

> 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
 
> 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::DispEventAdvise((IDispatch*)m_spExplorer);

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)
 
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.

<tnemec78@googlemail.com> wrote in message

news:d7cb4027-4581-4b9f-ab9d-5db8273cc6a0@r34g2000vba.googlegroups.com...
> > 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::DispEventAdvise((IDispatch*)m_spExplorer);
> 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)
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T Outlook 2010 Creating a email 'Group' in OL 2010 Using Outlook 2
G Creating Macro to scrape emails from calendar invite body Outlook VBA and Custom Forms 6
S Custom Contact card - need help creating one Outlook VBA and Custom Forms 1
D Outlook 2016 Creating an outlook Macro to select and approve Outlook VBA and Custom Forms 0
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
G Event when creating task from mailitem Outlook VBA and Custom Forms 2
T Outlook creating unwanted tasks in Tasks and Todo from emails Using Outlook 1
Fozzie Bear Outlook 2016 Creating a shared local Contacts folder Using Outlook 2
R Creating a user defined function Outlook VBA and Custom Forms 3
M Creating an RSS Feed **FROM** Outlook 2013 Calendar. Using Outlook 5
O How to prevent CC from showing when creating a new mail? Using Outlook 1
N Creating a button or link to a form in the Organizational Forms Library Outlook VBA and Custom Forms 3
B Creating an email with the list of tasks Outlook VBA and Custom Forms 0
L Creating drafts when I thought I was sending Using Outlook 1
R Would creating a new profile cause Outlook to download all the old mails from the server? Using Outlook 1
A Creating Progress Bar or Status Bar Update Outlook VBA and Custom Forms 0
T Outlook creating a folder named: "Unwanted" Using Outlook 3
M Outlook 2007 Contacts Glitch: Creating a new email Using Outlook 1
Liza Creating a rule in outlook to filter messages Using Outlook 0
A Are categories still recommended for creating local distribution lists? Using Outlook 3
S Creating Email - Selecting Pre-Defined Text Using Outlook 2
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
M Creating Outlook Appointments from Excel Cells Outlook VBA and Custom Forms 1
N Creating New Profile Using Outlook 0
Y Creating custom appointment request form with multiple mail recipients Outlook VBA and Custom Forms 5
M creating email from contact file = 3 emails in To field Using Outlook 3
P Recover / Extract Rules from standalone PST file creating RWZ file Using Outlook 2
A Creating an outlook rule to forward an email with a specific message Using Outlook 1
I Creating meeting invite with disabled tentative button Outlook VBA and Custom Forms 5
E Creating email templates for organizational use Using Outlook 0
N Creating or changing the main new mail message template in Outlook 2010 Using Outlook 2
D Creating custom view with VBA Outlook VBA and Custom Forms 2
J Outlook creating unwanted rule on its own Using Outlook 1
R Creating a Room Mailbox with Exchange Online Outlook VBA and Custom Forms 0
A Creating a rule on “Deleted items” folder Using Outlook 1
CMG73 Creating templates with predefined subject and CC Using Outlook 1
G Creating Contact Sub Folders Using Outlook 2
Rupert Dragwater creating gmail account in Outlook 2013 Using Outlook 7
nathandavies Creating a Select Case for a directory of folders Outlook VBA and Custom Forms 1
2 creating custom stationery Using Outlook 2
A Help creating macro for conditional formatting settings Using Outlook 8
Fozzie Bear Creating Custom Meeting Form Outlook VBA and Custom Forms 6
U Creating a (This computer only) folder within an IMAP account directory Using Outlook 1
A Creating archive rule on the clients by script/ Outlook VBA and Custom Forms 3
J Creating a URL from a message body excerpt before forwarding Using Outlook 2
B Need Help Creating Email Based on Subject w Address in Body Outlook VBA and Custom Forms 1
A Creating rule to create week folder and transfer mail using alert Using Outlook 3
J Creating an "isolated" shared calendar in Outlook Outlook VBA and Custom Forms 1
L Creating a Task from Email and Attaching Original Email Outlook VBA and Custom Forms 6
S Creating custom rule to move if "NAME" is in body but ignore the phrase "Hi NAME" in the search Using Outlook 2

Similar threads

Back
Top