BluePosition
Guest
|
|
Andrei Smolin
Add-in Express team
Posts: 19174
Joined: 2006-05-11
|
Hello Nicklas,
That link applies to using commandbar-style controls. They can be used in Outlook 2007-2010; they've stopped supporting such controls in Outlook 2013.
For Outlook 2010-2013 you use ribbon context menus.
[CODE]this.components = new System.ComponentModel.Container();
this.adxRibbonContextMenu1 = new AddinExpress.MSO.ADXRibbonContextMenu(this.components);
this.adxRibbonButton1 = new AddinExpress.MSO.ADXRibbonButton(this.components);
//
// adxRibbonContextMenu1
//
this.adxRibbonContextMenu1.ContextMenuNames.AddRange(new string[] {
"Outlook.Explorer.ContextMenuCalendarItem",
"Outlook.Explorer.ContextMenuCalendarView",
"Outlook.Explorer.ContextMenuMultipleItems"});
this.adxRibbonContextMenu1.Controls.Add(this.adxRibbonButton1);
this.adxRibbonContextMenu1.Ribbons = AddinExpress.MSO.ADXRibbons.msrOutlookExplorer;
//
// adxRibbonButton1
//
this.adxRibbonButton1.Caption = "adxRibbonButton1";
this.adxRibbonButton1.Id = "adxRibbonButton_4ebbd97c5b104d668b9b19c1e91eddf2";
this.adxRibbonButton1.ImageTransparentColor = System.Drawing.Color.Transparent;
this.adxRibbonButton1.Ribbons = AddinExpress.MSO.ADXRibbons.msrOutlookExplorer;[QUOTE]
The settings above show the ribbon button in the context menu that opens when you right-click an appointment ("ContextMenuCalendarItem"), a date selection ("ContextMenuCalendarView") or selected items ("ContextMenuMultipleItems"). To control the visibility of the button in the context menu, you intercept the PropertyChanging event of the button. In the event handler, when e.PropertyType = ADXRibbonControlPropertyType.Visible, you verify the condition and set e.Value to true/false. To verify the condition, you retrieve information about the right-clicked object(s) as recommended in the section Determining a Ribbon Control's Context of the manual, see the PDF file in the folder {Add-in Express}\Docs on your development PC (you can also download it http://www.add-in-express.com/downloads/documentation.php).
Hope this helps.
Andrei Smolin
Add-in Express Team Leader |
|
BluePosition
Guest
|
Thank you, that's exactly what I needed.
However, looking in the PDF I can't seem to find anything related to how I get the current selected Item when the user right clicks an appointment in the calendar.
I have looked in the section Determining a Ribbon Control's Context, but this only says to get the e.Context and by debugging it seems that the e.Context is a Outlook Explorer object and from there I can't seem to find how to get the selected item.
Further help is much appreciated.
Thanks |
|
BluePosition
Guest
|
Hi again,
I found a solution:
OutlookApp.ActiveExplorer().Selection.Count > 0 |
|
Andrei Smolin
Add-in Express team
Posts: 19174
Joined: 2006-05-11
|
BluePosition writes:
I have looked in the section Determining a Ribbon Control's Context, but this only says to get the e.Context and by debugging it seems that the e.Context is a Outlook Explorer object
I use Microsoft.VisualBasic.Information.TypeName() as suggested in the manual to get the following types behind e.Context (Outlook 2013):
- right-clicking an appointment (context menu name = "ContextMenuCalendarItem") - Selection
- right-clicking several items (context menu name = "ContextMenuMultipleItems") - Selection
- right-clicking a date or date selection (context menu name = "ContextMenuCalendarView") - CalendarView
You need to get selected items from the context object - just cast e.Context to Selection. Getting selected items using OutlookApp.ActiveExplorer().Selection may produce different (incorrect) results.
Andrei Smolin
Add-in Express Team Leader |
|