Commandbar in special Inspectors

H

Hans-Joerg Propach

I develope an Outlook Com-Addin that needs a Commandbar with some
CommandbarButtons in mail- and contact-inspectors.
I use the NewInspectorEvent, check the type of the item and add the
commandbar and commandbarbuttons with temporary=true, so they are visible
only in this inspector.
Because of "temporary=true" i have to check every new inspector if the
commandbar already exists (normaly not) and add the bar and the buttons.
My problem: I have a global Object Commandbarbutton declared "withevents",
and everytime i get a newinspectorevent, iset it to the new created
commandbarbutton so i can get the users mouseclick. But when the user opens
several inspector windows, how can i be sure that the different
commandbarbuttons (remember, i create them often because of temporary=true)
fire the event ? Is every commandbarbutton with the same tag the same
commandbarbutton ???
On my dev-System everything works fine, but i can't believe it will work in
a user enviroment (user opens mail, opens word, opens another mail etc., and
then every of my for every inspector created commandbarbuttons fires the
event ???).

Thank for any idea,

Hans-Jörg "Keke" Propach, GIID
 
H

Hans-Jörg Propach

Your answer is what I expected. It's a little bit funny to create an object
for every inspector by the way. Another idea was to create a common
commandbar for all inspectors (temporary=false), but how remove the
commandbar when the user uninstalls the addin? The inspectors commandbar may
be not availble at this time. Next idea, set a handler to one of the open
inspectors close-events (withevents inspectorhandler as outlook.inspector,
when the inspectors.newinspector fires, set inspectorhandler = inspector).
When this inspector closes, check if other inspectors are open. If yes,
remapp the handler to an other inspector (find one through the inspectors
collection), else delete the commandbar and set the inspectorhandler =
nothing. So far, so good: It works fine (I thought). But when I close an
inspector and set the handler to an stickynote-inspector, the close-event
of the sticky-inspector doesn't fire if I close it. Instead, when I then
close Outlook, it says it could not save the changes in the sticky-note
(which seems to be already closed). After that, when I close the
error-message, the event fires (before Outlook goes). I don't tried to
access a commandbar from within the sticky-note-inspector (because that
could not work), really.
Good idea so far, but ...
Any experience like that ???
Ken Slovak - said:
Use an Inspector wrapper similar to the Explorer wrapper used in
ItemsCB, create the toolbar in your code and handle the button press
in the Inspector wrapper. You'd declare a WithEvents button in each
Inspector class object in the wrapper collection.

Each button should have its own unique Tag or otherwise each button
that is created will fire when one of the buttons is pressed.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Hans-Joerg Propach said:
I develope an Outlook Com-Addin that needs a Commandbar with some
CommandbarButtons in mail- and contact-inspectors.
I use the NewInspectorEvent, check the type of the item and add the
commandbar and commandbarbuttons with temporary=true, so they are visible
only in this inspector.
Because of "temporary=true" i have to check every new inspector if the
commandbar already exists (normaly not) and add the bar and the buttons.
My problem: I have a global Object Commandbarbutton declared "withevents",
and everytime i get a newinspectorevent, iset it to the new created
commandbarbutton so i can get the users mouseclick. But when the user opens
several inspector windows, how can i be sure that the different
commandbarbuttons (remember, i create them often because of temporary=true)
fire the event ? Is every commandbarbutton with the same tag the same
commandbarbutton ???
On my dev-System everything works fine, but i can't believe it will work in
a user enviroment (user opens mail, opens word, opens another mail etc., and
then every of my for every inspector created commandbarbuttons fires the
event ???).

Thank for any idea,

Hans-Jörg "Keke" Propach, GIID
 
D

Dmitry Streblechenko

I don't think using a separate object for each inspector is funny, this is
exactly how classes are supposed to be used, even though VB doesn't exactly
encourage their use. Why not steal the working code from ItemsCB
(http://www.microeye.com)?
Create the command bars as temporary (CommandBars.Add(Temporary:=true)),
there won't be anything to remove.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Hans-Jörg Propach said:
Your answer is what I expected. It's a little bit funny to create an object
for every inspector by the way. Another idea was to create a common
commandbar for all inspectors (temporary=false), but how remove the
commandbar when the user uninstalls the addin? The inspectors commandbar may
be not availble at this time. Next idea, set a handler to one of the open
inspectors close-events (withevents inspectorhandler as outlook.inspector,
when the inspectors.newinspector fires, set inspectorhandler = inspector).
When this inspector closes, check if other inspectors are open. If yes,
remapp the handler to an other inspector (find one through the inspectors
collection), else delete the commandbar and set the inspectorhandler =
nothing. So far, so good: It works fine (I thought). But when I close an
inspector and set the handler to an stickynote-inspector, the close-event
of the sticky-inspector doesn't fire if I close it. Instead, when I then
close Outlook, it says it could not save the changes in the sticky-note
(which seems to be already closed). After that, when I close the
error-message, the event fires (before Outlook goes). I don't tried to
access a commandbar from within the sticky-note-inspector (because that
could not work), really.
Good idea so far, but ...
Any experience like that ???
Ken Slovak - said:
Use an Inspector wrapper similar to the Explorer wrapper used in
ItemsCB, create the toolbar in your code and handle the button press
in the Inspector wrapper. You'd declare a WithEvents button in each
Inspector class object in the wrapper collection.

Each button should have its own unique Tag or otherwise each button
that is created will fire when one of the buttons is pressed.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Hans-Joerg Propach said:
I develope an Outlook Com-Addin that needs a Commandbar with some
CommandbarButtons in mail- and contact-inspectors.
I use the NewInspectorEvent, check the type of the item and add the
commandbar and commandbarbuttons with temporary=true, so they are visible
only in this inspector.
Because of "temporary=true" i have to check every new inspector if the
commandbar already exists (normaly not) and add the bar and the buttons.
My problem: I have a global Object Commandbarbutton declared "withevents",
and everytime i get a newinspectorevent, iset it to the new created
commandbarbutton so i can get the users mouseclick. But when the user opens
several inspector windows, how can i be sure that the different
commandbarbuttons (remember, i create them often because of temporary=true)
fire the event ? Is every commandbarbutton with the same tag the same
commandbarbutton ???
On my dev-System everything works fine, but i can't believe it will work in
a user enviroment (user opens mail, opens word, opens another mail etc., and
then every of my for every inspector created commandbarbuttons fires the
event ???).

Thank for any idea,

Hans-Jörg "Keke" Propach, GIID
 
H

Hans-Joerg Propach

Funny is that there is so much code in my project for such things like
Commandbars, User-Options, ...
And then, your real work, your Application, is less code than the things
around.
Maybe my problem is to say "OK, let us add some objects, so what" cause 16
years ago when I started with Pascal and Modula-2, I had to care about every
kbyte.
OK, we're in 2003, my PC has 400MB, let's go.
By the way, I think the Code in ItemsCB is a good idea for an
Inspector-Wrapper, and because I own the Development-Handbook Outlook2002
from Randy Byrne I think it's ok to use it :)
Next problem might be the "security update" from MS, so maybe you earn 182,-
? in about a month or two...

Thank's so far,
H.-J. "Keke" Propach, GIID

Dmitry Streblechenko said:
I don't think using a separate object for each inspector is funny, this is
exactly how classes are supposed to be used, even though VB doesn't exactly
encourage their use. Why not steal the working code from ItemsCB
(http://www.microeye.com)?
Create the command bars as temporary (CommandBars.Add(Temporary:=true)),
there won't be anything to remove.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Hans-Jörg Propach said:
Your answer is what I expected. It's a little bit funny to create an object
for every inspector by the way. Another idea was to create a common
commandbar for all inspectors (temporary=false), but how remove the
commandbar when the user uninstalls the addin? The inspectors commandbar may
be not availble at this time. Next idea, set a handler to one of the open
inspectors close-events (withevents inspectorhandler as outlook.inspector,
when the inspectors.newinspector fires, set inspectorhandler = inspector).
When this inspector closes, check if other inspectors are open. If yes,
remapp the handler to an other inspector (find one through the inspectors
collection), else delete the commandbar and set the inspectorhandler =
nothing. So far, so good: It works fine (I thought). But when I close an
inspector and set the handler to an stickynote-inspector, the close-event
of the sticky-inspector doesn't fire if I close it. Instead, when I then
close Outlook, it says it could not save the changes in the sticky-note
(which seems to be already closed). After that, when I close the
error-message, the event fires (before Outlook goes). I don't tried to
access a commandbar from within the sticky-note-inspector (because that
could not work), really.
Good idea so far, but ...
Any experience like that ???
Use an Inspector wrapper similar to the Explorer wrapper used in
ItemsCB, create the toolbar in your code and handle the button press
in the Inspector wrapper. You'd declare a WithEvents button in each
Inspector class object in the wrapper collection.

Each button should have its own unique Tag or otherwise each button
that is created will fire when one of the buttons is pressed.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


I develope an Outlook Com-Addin that needs a Commandbar with some
CommandbarButtons in mail- and contact-inspectors.
I use the NewInspectorEvent, check the type of the item and add the
commandbar and commandbarbuttons with temporary=true, so they are
visible
only in this inspector.
Because of "temporary=true" i have to check every new inspector if
the
commandbar already exists (normaly not) and add the bar and the
buttons.
My problem: I have a global Object Commandbarbutton declared
"withevents",
and everytime i get a newinspectorevent, iset it to the new created
commandbarbutton so i can get the users mouseclick. But when the
user opens
several inspector windows, how can i be sure that the different
commandbarbuttons (remember, i create them often because of
temporary=true)
fire the event ? Is every commandbarbutton with the same tag the
same
commandbarbutton ???
On my dev-System everything works fine, but i can't believe it will
work in
a user enviroment (user opens mail, opens word, opens another mail
etc., and
then every of my for every inspector created commandbarbuttons fires
the
event ???).

Thank for any idea,

Hans-Jörg "Keke" Propach, GIID
 
D

Dmitry Streblechenko

There isn't much overhead when classes are used - only per-instance data is
allocated (member variables) and virtual functions table (v-table, I don't
know if VB supports that).

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Hans-Joerg Propach said:
Funny is that there is so much code in my project for such things like
Commandbars, User-Options, ...
And then, your real work, your Application, is less code than the things
around.
Maybe my problem is to say "OK, let us add some objects, so what" cause 16
years ago when I started with Pascal and Modula-2, I had to care about every
kbyte.
OK, we're in 2003, my PC has 400MB, let's go.
By the way, I think the Code in ItemsCB is a good idea for an
Inspector-Wrapper, and because I own the Development-Handbook Outlook2002
from Randy Byrne I think it's ok to use it :)
Next problem might be the "security update" from MS, so maybe you earn 182,-
? in about a month or two...

Thank's so far,
H.-J. "Keke" Propach, GIID

Dmitry Streblechenko said:
I don't think using a separate object for each inspector is funny, this is
exactly how classes are supposed to be used, even though VB doesn't exactly
encourage their use. Why not steal the working code from ItemsCB
(http://www.microeye.com)?
Create the command bars as temporary (CommandBars.Add(Temporary:=true)),
there won't be anything to remove.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Hans-Jörg Propach said:
Your answer is what I expected. It's a little bit funny to create an object
for every inspector by the way. Another idea was to create a common
commandbar for all inspectors (temporary=false), but how remove the
commandbar when the user uninstalls the addin? The inspectors
commandbar
may
be not availble at this time. Next idea, set a handler to one of the open
inspectors close-events (withevents inspectorhandler as outlook.inspector,
when the inspectors.newinspector fires, set inspectorhandler = inspector).
When this inspector closes, check if other inspectors are open. If yes,
remapp the handler to an other inspector (find one through the inspectors
collection), else delete the commandbar and set the inspectorhandler =
nothing. So far, so good: It works fine (I thought). But when I close an
inspector and set the handler to an stickynote-inspector, the close-event
of the sticky-inspector doesn't fire if I close it. Instead, when I then
close Outlook, it says it could not save the changes in the sticky-note
(which seems to be already closed). After that, when I close the
error-message, the event fires (before Outlook goes). I don't tried to
access a commandbar from within the sticky-note-inspector (because that
could not work), really.
Good idea so far, but ...
Any experience like that ???
Use an Inspector wrapper similar to the Explorer wrapper used in
ItemsCB, create the toolbar in your code and handle the button press
in the Inspector wrapper. You'd declare a WithEvents button in each
Inspector class object in the wrapper collection.

Each button should have its own unique Tag or otherwise each button
that is created will fire when one of the buttons is pressed.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


I develope an Outlook Com-Addin that needs a Commandbar with some
CommandbarButtons in mail- and contact-inspectors.
I use the NewInspectorEvent, check the type of the item and add the
commandbar and commandbarbuttons with temporary=true, so they are
visible
only in this inspector.
Because of "temporary=true" i have to check every new inspector if
the
commandbar already exists (normaly not) and add the bar and the
buttons.
My problem: I have a global Object Commandbarbutton declared
"withevents",
and everytime i get a newinspectorevent, iset it to the new created
commandbarbutton so i can get the users mouseclick. But when the
user opens
several inspector windows, how can i be sure that the different
commandbarbuttons (remember, i create them often because of
temporary=true)
fire the event ? Is every commandbarbutton with the same tag the
same
commandbarbutton ???
On my dev-System everything works fine, but i can't believe it will
work in
a user enviroment (user opens mail, opens word, opens another mail
etc., and
then every of my for every inspector created commandbarbuttons fires
the
event ???).

Thank for any idea,

Hans-Jörg "Keke" Propach, GIID
 

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