When the width of an Outlook Explorer or Inspector window is reduced the ribbon changes. In my VSTO addin can I influence how the scaling happens with the Office Ribbon?
Further at a certain width the tab becomes a single icon with a small arrow which when clicked the buttons/elements of the tab appear in a pop-up. How can I set the icon that appears in this case?
Below is my current XML for the tab.
I have also added a picture of how my ribbon looks when the window is made narrow.
I am not able to find a new XML Markup from Microsoft is this really the latest version [MS-CUSTOMUI2]: Custom UI XML Markup Version 2 Specification
<tabs>
<!-- Creates a new App Tab on the inspector toolbar-->
<tab idMso="TabReadMessage">
<group id="AppGroup" label="App">
<!-- A toggle or ON/OFF button to Encrypt or Decrypt an email and show the current encryption -->
<toggleButton id="insDecryptButton"
getLabel="insDecryptButton_getLabel"
size="large"
onAction="insDecryptButton_ButtonClick"
getImage="insDecryptButton_getImage"
getSupertip="insDecryptButton_getSupertip"
getScreentip="insDecryptButton_getScreentip"
getPressed="insDecryptButton_getPressed"
getVisible="insDecryptButton_getVisible"/>
<!-- A Button with drop down that shows all the File Numbers in the Email. If there are no file numbers this will not appear. -->
<dynamicMenu id="insMenu"
getLabel="insMenu_getLabel"
size="large"
getImage="insMenu_getImage"
getVisible="insMenu_getVisible"
getSupertip="insMenu_getSupertip"
getScreentip="insMenu_getScreentip"
getContent="insMenu_getContent"/>
<!-- Button to upload the email or attachments to IPAS -->
<dynamicMenu id="upMenu"
getLabel="upMenu_getLabel"
size="large"
getImage="upMenu_getImage"
getVisible="upMenu_getVisible"
getSupertip="upMenu_getSupertip"
getScreentip="upMenu_getScreentip"
getContent="upMenu_getContent"/>
</group>
</tab>
Office applications perform the scaling optimization on its own. There is no new schema for that. Instead, as other poster noticed, you need to provide the getImage callback to all your group controls. It should look like this:
C#: IPictureDisp GetImage(IRibbonControl control)
VBA: Sub GetImage(control As IRibbonControl, ByRef image)
C++: HRESULT GetImage([in] IRibbonControl *pControl, [out, retval] IPictureDisp ** ppdispImage)
Visual Basic: Function GetImage(control as IRibbonControl) as IPictureDisp
Calling the Invadiate or InvalidateControl you may get a new image displayed (so, your callback will be invoked).
Read more about the Fluent UI (aka Ribbon UI) in the following articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
If you want to know more about dynamic customizations you may take a look at:
OfficeTalk: Display and Hide Tabs, Groups, and Controls on the Microsoft Office Ribbon User Interface (Part 1 of 2)
OfficeTalk: Display and Hide Tabs, Groups, and Controls on the Microsoft Office Ribbon User Interface (Part 2 of 2)
Related
Well, every time I need to do things in my Outlook Add-in using VSTO I always get problems, limitations, restrictions, etc.....
Having said that... Now I am trying to detect when explorer or inspector window are not visible as the topmost.
For example, I have a custom task pane which I catch any visibility change through the correspondent VisibleChanged event. This event is triggered when its visibility changes from true to false or vice versa or when the custom task pane is closed for any reason. When the custom task pane is not visible I do some stuff.
The problem I have is the following:
If I am in the explorer or inspector window and I click on the Outlook "File" tab/menu, the current view changes and the explorer and inspector are not the topmost (they are not visible) and the worst, the custom task pane VisibleChanged event is triggered.... so in this use case I do not want to do those stuffs when custom task pane is not visible. How can I detect this particular use case? I mean when explorer or inspector window are not displayed as the topmost.
You need to use backstage UI customizations where you could specify callbacks for handling the backstage open and close operations. For example, the following backstage UI XML markup declares the callback for opening the backstage UI:
<?xml version="1.0" encoding="utf-8"?>
<!-- customUI is the root tag of all Fluent UI customizations. -->
<customUI xmlns="https://schemas.microsoft.com/office/2009/07/customui"
onLoad="OnLoad">
<!—The Backstage element defines the custom structure of the Backstage UI. -->
<backstage onShow="OnShow">
So, by getting the onShow callback invoked you will be aware when the task pane is overlapped with a backstage UI in Office applications. See Adding Custom Commands and Changing the Visibility of Controls in the Office 2010 Backstage View for more information.
The backstage UI is described in depth in the Introduction to the Office 2010 Backstage View for Developers article.
FYI The Outlook object model provides the Application.ActiveWindow method which returns an object representing the current Microsoft Outlook window on the desktop, either an Explorer or an Inspector object.
I have seen that Outlook has a quick access toolbar (QAT).
You can access it doing below:
And then the QAT appears (see below screenshot, I marked it with a blue rectangle):
So taken into account that a custom task pane (ctp) have some limitations, for example, you cannot remove title bar nor buttons I was thinking about if it is possible to create a QAT programmatically and embed into it an WPF user control.
Is it possible?
No, it is not possible. At least there is no trivial way of getting the job done without Windows API functions involved.
The QAT (Quick Access Toolbar) has a predefined set of controls that can be put inside it. Read more about the Fluent UI (aka Ribbon UI) in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
I create a toolbar menu hierarchy in Outlook using VSTO, CommandBarPopup and CommandBarButton. I set a Click handler on the CommandBarButton's and everything works fine, but I would like to be able to do different things in the click handler depending on whether the user right-clicked on the menu, or shift-left-clicked or what not (for example, to include or not include the original message when automatically composing a template reply).
How do I detect which mouse button the user clicked with, or whether shift, alt, or ctrl keys were pressed when the user clicked?
In the event handler you can use the Keyboard.GetKeyStates method which gets the set of key states for the specified key.
// Uses the Keyboard.GetKeyStates to determine if a key is down.
// A bitwise AND operation is used in the comparison.
if ((Keyboard.GetKeyStates(Key.LeftShift) & KeyStates.Down) > 0)
{
// the left shift is pressed now
}
CommandBars were deprecated with Office 2010. You need to use the Fluent UI for creating a custom UI in the add-in. There are two main ways in VSTO to create a custom UI:
Walkthrough: Create a custom tab by using the Ribbon Designer
Walkthrough: Create a custom tab by using Ribbon XML
A context menu is customized using the Fluent UI as well. See Extending the User Interface in Outlook 2010 for more information.
The Fluent UI is described in depth in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
I'm creating a custom ribbon for an outlook addin, but the button sizes, large, medium, and small are not defined anywhere. What are the size I should use for large/medium/small images in Microsoft.Office.Tools.Ribbon.RibbonButton.Button ?
Will it autoresize or is there a certain size I need to use?
EDIT: Seems in properties for the button you can change ControlSize to large. But my second edit is the question I now need answered.
EDIT2: Is there documentation for the properities for ribbons in Visual Studio 2013? As in what all the different properties do?
16x16 - small
32x32 - medium
48x48 - large
The Fluent UI (aka Ribbon UI) is based on the XML markup and IRibbonExtensibility interface which add-ins should implement to get the custom UI displayed in Office applications. I'd suggest reading the following series of articles that describe the UI in depth:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
Controlsize paramter in properties can be set to large. I know it can be done in XAML but not sure how or in Outlook.Ribbon.Designer.cs... Form my purposes it seems to work fine.
I want to customise the ribbon that is displayed when the "Home" tab is clicked in OUtlook 2010 and 2013.
Questions -
Is this possible? Or do I have to create a custom ribbon and cannot modify the existing ribbon?
If the existing ribbon can be modified, please can you'll direct me to links that can provide this information.
I absolutely have no clue where to start from with this. Any links, docs or samples will be helpful.
I've been going through msdn but it all speaks of custom ribbon and that doesn't fit my purpose. I need to modify the existing ribbon.
It is possible... by creating a custom ribbon which will in turn be added to the Home tab.
First, create a custom ribbon. Here's an example http://msdn.microsoft.com/en-us/library/ee692172.aspx#OfficeOLExtendingUI_Explorer
Then add:
idMso="TabMail"
to the tab tag on your XML. This will instruct Outlook to add your custom ribbon to Home tab.
Using the link's example, it would be like this:
<ribbon>
<tabs>
<tab id="MyTab"
idMso="TabMail"
getVisible="MyTab_GetVisible"
label="MyTab">
<group label="MyGroup" id="MyGroup">
<button id="MyButton"
size="large"
label="MyButton"
imageMso="HappyFace"
onAction="OnMyButtonClick"/>
</group>
</tab>
</tabs>
If you're using Visual Studio's designer instead of XML, set the ControlId property of your custom ribbon's tab to TabMail. Here's a walkthrough for custom ribbon creation with Visual Studio: http://msdn.microsoft.com/en-us/library/vstudio/bb386104(v=vs.100).aspx
And if you want to place your custom ribbon somewhere other than the Home tab, you'll need to find the locations's MSO ID. Microsoft provides a list which can be downloaded at http://www.microsoft.com/en-us/download/details.aspx?id=6627
Yes, an existing ribbon can be modified. Follow the steps given below to customize an existing ribbon in Outlook 2010:
Open Outlook 2010.
Go to the top of the Ribbon and click the Office Button
Click Outlook and then click on Options button.
In the left pane, select Customize Ribbon.
In the right pane, find the desired tab in the list of available tabs and expand it.
Use the list of available commands and the Add/Remove buttons to
customize the tab.
Click the OK button and you will be done.