How to create button in multiple lines?

  • Thread starter ryotyankou via OfficeKB.com
  • Start date
R

ryotyankou via OfficeKB.com

I create a toolbar with 8 buttons, in outlook2007 it display in one row, it
is too long, how to set them in two rows, 4 buttons each row? which property
or interface etc. And i don't want to make outlook2003 not work, in
outlook2003, 2003 seems all button is in one row, Thank you.
 
K

Ken Slovak - [MVP - Outlook]

You would need to create two separate toolbars. There are no rows in
toolbars (CommandBar objects).

If this is for Inspector UI you really should be handling the ribbon instead
of creating button/toolbar UI if you discover at runtime that the code is
running under Outlook 2007.
 
R

ryotyankou via OfficeKB.com

After see some document I know what a ribbon is, forgive my innocent.
Now i have a question, since my codes wrote under outlook2003 which not
support ribbon. But i want to maintain only one project. What should i do
with IRibbonExtensibility interface, when outlook is 2007 it can take effect,
and 2003 ignore the interface?
 
R

ryotyankou via OfficeKB.com

One more question, how to monitor other existing button click event on ribbon?
and after i create my button and then click on my button, in my click button
produre, how could i do a click on other existing button such as sign button
or encrypt button?
 
K

Ken Slovak - [MVP - Outlook]

Search for Andrew Whitechapel's blog at MSDN, he's a member of the VSTO
team. He posted how to handle the callbacks for the ribbon without having to
explicitly having an Office 2007 reference.

You also should be downloading and studying the Ribbon XML and documentation
and the Outlook 2007 sample addins all available for download at the Office
Development Web site at MSDN so you understand how to do what you need to do
with the ribbon.
 
K

Ken Slovak - [MVP - Outlook]

Office 2007 has a CommandBars.ExecuteMso() method that you call with the
idMso of the control you want to execute. If you are only referencing the
Office 2003 object library then you can call that method using reflection.
 
R

ryotyankou via OfficeKB.com

Thank you for reply, Ken. Ribbon is quite strange to me, i'm trying at my
best, now two questions, 1.)How could i load two different xml file for two
conditions, one for editor mode, another for viewer mode, since GetCustemUI
only initialize for once after first NewInspector event.
2.)How could i monitor click event on other button(not created by me) if user
click on it. Should i found the specified button and get its CommandBarButton
or If i can get its ribbon interface and make something on it?
These are my understanding, may be it is misunderstand, if so, could you pls
help me out? thanks.
Office 2007 has a CommandBars.ExecuteMso() method that you call with the
idMso of the control you want to execute. If you are only referencing the
Office 2003 object library then you can call that method using reflection.
One more question, how to monitor other existing button click event on
ribbon?
[quoted text clipped - 3 lines]
button
or encrypt button?
 
K

Ken Slovak - [MVP - Outlook]

If you look at the ribbon stuff I told you to look at you will see that
there are separate GetCustomUI() callbacks for messages in create and read
modes. So you can supply different XML for each type. One provides
"Microsoft.Outlook.Mail.Read" and the other provides
""Microsoft.Outlook.Mail.Compose" as the RibbonID argument.

There is no way to get or handle any callbacks for any custom ribbon control
not created by you. If that's what you want forget about it.

If what you want is to handle clicks on built-in ribbon controls that is
repurposing the controls, and there are articles on how to do that. Just
google for "repurpose ribbon controls".

Many of these questions are already answered if you look at the materials
that are available.
 
R

ryotyankou via OfficeKB.com

Thank you for the reply, Ken. I got the answers for my question. But that's
not the end, i still have a question:
How to change control image by code, in getImage callback? How about multiple
inspector?
As what i understand, we can call IRibbonUI::InvalidateControl("myctrlid")
make the control initialize and get in callback function again, then set the
image we wanted. But in multiple inspector, all control id are "myctrlid", if
i call InvalidateControl, all inspector's getImage callback will fire, i
don't know how to process it. I checked the IRibbonControl::GetContext, and
compare it with active inspector, if equal, set the new image, if not, return
old one, question is that how to know which is the old one, If i open 10
inspector, should there be 9 old images? How to process? I'm quite confused.
If you look at the ribbon stuff I told you to look at you will see that
there are separate GetCustomUI() callbacks for messages in create and read
modes. So you can supply different XML for each type. One provides
"Microsoft.Outlook.Mail.Read" and the other provides
""Microsoft.Outlook.Mail.Compose" as the RibbonID argument.

There is no way to get or handle any callbacks for any custom ribbon control
not created by you. If that's what you want forget about it.

If what you want is to handle clicks on built-in ribbon controls that is
repurposing the controls, and there are articles on how to do that. Just
google for "repurpose ribbon controls".

Many of these questions are already answered if you look at the materials
that are available.
Thank you for reply, Ken. Ribbon is quite strange to me, i'm trying at my
best, now two questions, 1.)How could i load two different xml file for
[quoted text clipped - 10 lines]
pls
help me out? thanks.
 
R

ryotyankou via OfficeKB.com

Hi, ken, could i be able to click a build-in button by code, for instance,
when user click on my button, then i want to click a build-in button by code
in my button callback function, could i do it, if so, how?
If you look at the ribbon stuff I told you to look at you will see that
there are separate GetCustomUI() callbacks for messages in create and read
modes. So you can supply different XML for each type. One provides
"Microsoft.Outlook.Mail.Read" and the other provides
""Microsoft.Outlook.Mail.Compose" as the RibbonID argument.

There is no way to get or handle any callbacks for any custom ribbon control
not created by you. If that's what you want forget about it.

If what you want is to handle clicks on built-in ribbon controls that is
repurposing the controls, and there are articles on how to do that. Just
google for "repurpose ribbon controls".

Many of these questions are already answered if you look at the materials
that are available.
Thank you for reply, Ken. Ribbon is quite strange to me, i'm trying at my
best, now two questions, 1.)How could i load two different xml file for
[quoted text clipped - 10 lines]
pls
help me out? thanks.
 
K

Ken Slovak - [MVP - Outlook]

How you would do that depends on whether it's an Explorer with
CommandBarButton's to click or ribbon controls in Inspectors.

For a CommandBarButton you find it in the CommandBar where it's shown and
then call its Execute() method.

For a ribbon control you need its idMso, which you can get from the ribbon
XML schema, then you get the Inspector.CommandBars object and call the
ExecuteMso() method, passing the ribbon control's idMso.
 
K

Ken Slovak - [MVP - Outlook]

When multiple Inspectors (and Explorers) are open, or to handle that
situation you use a wrapper class and keep all wrapper class instances alive
in a collection of some sort (list, sorted list, hashtable, etc.). The
wrapper class has event handlers in it for the Inspector and item in the
Inspector, such as Activate() and Close(). It also exposes the Inspector and
CurrentItem as public properties available to the outside.

In a callback such as getImage() you would iterate the Inspectors wrapper
collection and get the Inspector exposed by each wrapper class instance,
then you compare that Inspector with what was passed in the callback.

Outlook 2007 makes that easy by allowing a direct comparison using == in c#
or Is in VB.NET.

When you find your Inspector you then can supply an image for it based on
the current setup and configuration.

I have some wrapper class examples on my Web site as part of the addin
sample templates there. I have templates for C#, VB.NET and VB6. You can
find them at http://www.slovaktech.com/outlook_2007_templates.htm. There are
also other sample templates available at the outlookcode.com Web site.
 

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