OBJECTIVE:
C# .Net VSTO2010
i need to add a panel to appointment/calendar item window in outlook.
AppointmentItem window means window which opens when we click an appointment or create new appointment in outlook.
I need to display to some details(appoitnmentitem related) in appointmentItem Window (i prefer to use panel).
Actually i am displaying some details (addin related details) in separate tab as form in appointment item window, i want to display those details in single window(appointmentitem window) of appointmentItem
Inspector :Represents the window in which an Outlook item is displayed.
but in Inspector there is no support for adding panel
I am able to add panel or custom task pane in outlook main window .but i am not able to do in appointmentitem window.
I am using .Net 4 framework ,visual studio 2010. This has to be done in a outlook Addin, addin is target for MS office outlook 2003,2007,2010(atleast it should support 2007and 2010).
adding panel to outlook main window can be done using window handle and window class , then using function in User32.dll. but same technique i am not able to use on appointmentitem window.( i am not able to get handle of appointment item window)
adding custom task pane to outlook main window can be done using some code but i didnt find functionality to do it on appointment item window.
looking for good help or suggestions
You Can Add the side panel through the Custom Task panes and New Inspector Event Handler.
Step 1:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
inspectors = this.Application.Inspectors;
inspectors.NewInspector +=
new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(NewInspectorHandler);
}
Step 2:
public void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;
if(Inspector.CurrentItem is Microsoft.Office.Interop.Outlook.AppointmentItem ) {
UserControl uc1 = MyUserControl();
myCustomTaskPane = getAddIn().CustomTaskPanes.Add(uc1, "MyPanel",Inspector);
myCustomTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
myCustomTaskPane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
myCustomTaskPane.Visible = true;
}
//Additionally You can add a property change listener to the current Item here
}
This will show the Custom side panel in Appointment Item
Related
Good day everyone.
All my users have 2 monitors. I have a VSTO Outlook add-in which is basically a ribbon button and a form. If my ribbon button is clicked, I create and display a new form. I don't want my form to be displayed on the same monitor where outlook is displayed. I want to open it on the other monitor. This what I usually do in normal winforms apps:
Screen[] allScreens = Screen.AllScreens;
int i = allScreens.Count<Screen>();
if (i > 1)
{
foreach (Screen s in allScreens)
{
if (s.DeviceName != Screen.FromControl(this).DeviceName)
{
myForm.Location = s.WorkingArea.Location;
myForm.maximise = true;
myForm.Show();
}
}
}
else
{
this._outlookAuths.Show(this);
}
But there is no 'this' pointer when working in the Ribbon class. I tried to get the monitor in which the Ribbon button is shown, but it is not part of the normal winforms button class. Tried to get my form's parent, which should be MS Outlook but that returns null. Just as a sidenote, CentreParent property on my form is also not working, but CentreParent is kind of the opposite of what I want. Thanks in advance.
Use Screen.FromHandle instead. You can retrieve HWND of the Outlook windows by casting Explorer or Inspector OOM objects to the IOleWindow interface and calling IOleWindow.GetWindow.
Use Application.ActiveWindow / ActiveExplorer / ActiveInspector depending on your definition of "where Outlook is displayed".
I am developing a custom task pane for Microsoft PowerPoint 2010. I need the task pane to be synchronized between multiple application windows/presentations. The task panes are displayed using a toggle button on the ribbon.
Since PowerPoint 2010 displays each presentation in a different document window (which is different from 2007), I need to create a task pane separately for each window and synchronize them. I have followed the Microsoft tutorial on how to create task panes for multiple application windows, and I am using the CustomTaskPaneCollection.Add(UserControl, String, Object) method to specify which application window the task pane should be associated with. In this case the Object is the PowerPoint.DocumentWindow that the task pane should be associated with.
For some reason all of my task panes are created in the active window and not the window that I assign. For example, if I open 3 PowerPoint presentations and then toggle the task pane, all three task panes will be added to the active window.
This is the code I am using to add the task panes when the toggle is pressed:
public void AddAllTaskPanes()
{
PowerPoint.DocumentWindows windows = Globals.ThisAddIn.Application.Windows;
if(windows.Count > 0)
{
for (int i=1; i<=windows.Count; i++){
PowerPoint.DocumentWindow window = windows[i];
customTaskPane = this.CustomTaskPanes.Add(new UserControl1(), "My User Control", window);
customTaskPane.Visible = true;
}
}
}
It seems that this should successfully add each task pane to its specified window, and I cannot figure out why all of the task panes are being associate with the active window instead. I have done a lot of research into this issue and have not been able to find a solution. The closest I have found was this question, however the answer corresponds to PowerPoint 2007 and not 2010 like the question references.
Any insight into why PowerPoint may be behaving this way would be greatly appreciated.
I went the way of creating the TaskPanes from the PresentationAfterOpen and PresentationAfterNew Events which produces the same behaviour.
A note about the PresentationAfterOpen event, if the document selected by the user is already open, the event is still fired so you need to check if the CustomTaskPane has already been created for that document before creating a new one.
A way to overcome this problem is to create a pointer to the associated DocumentWindow in your CustomPane and enumerate through the CustomTaskPaneCollection checking for the associated one.
I have a custom pane for emails in Outlook 2013, using VSTO. It lists the attachments in a ListView and allows conversion operations to be performed on the attachments:
The user can normally press on an attachment to get a preview pane for the selected attachment. I need to duplicate that preview action when the matching attachment is selected in my ListView. This will allow them to select one attachment, see the preview, then choose which type of document it is (ID doc, CV etc) without having to move back and forth between my custom panel and the usual list of attachments.
I have Googled various terms, but this seems to too obscure to find. I am hoping there is an Outlook 2013 VSTO expert out there that will know where to start with this. The Inspector.AttachmentSelection is a starting point, but that is read-only.
My C# selection change handler is shown below (all error checking removed to simplify it):
private void listview_SelectedIndexChanged(object( sender, EventArgs e)
{
ListView listView = sender as ListView;
ListViewItem listViewItem = listView.SelectedItems[0];
Attachment attachment = lvi.Tag as Attachment;
Inspector inspector = Globals.ThisAddIn.Application.ActiveInspector();
// How to preview the attachment in the inspector???
}
Update:
As a fallback, I am able to go the other way, by catching the Inspector.AttachmentSelectionChange event as shown below and selecting items in my ListView, but I would prefer to be able to select the attachments from my ListView and that cause the AttachmentSelection to change:
void inspector_AttachmentSelectionChange()
{
this.attachmentListView.SelectedItems.Clear();
foreach (Attachment selection in this.Inspector.AttachmentSelection)
{
foreach (ListViewItem item in this.attachmentListView.Items)
{
if (item.Tag as Attachment == selection)
{
item.Selected = true;
}
}
}
}
Unfortunately there's nothing in the Outlook Object Model (or Redemption) that allows you to set the selected attachment.
However, it may be possible to select it using some Win32API commands to set the focus on the attachment selector region. If you use Spy++ you can see that it has a specific window handle (0007096E; AfxWndW). When that window is activated, you could issue TAB keystroke commands to select an attachment. I'm not sure though how to activate a specific attachment; TAB seems to be the only keyboard command in use for that window.
I was searching for few days and cannot find any solution. Do you know how to hide the header text and header "toolbar" in the adjoining Outlook addin?
I dont want to have the text "My custom addin" and i dont want to have this "+" and line.
You might be happier with a "Custom Task Pane." It still has some UI associated with it, but it's prettier.
Or, you can use a blank space (ie. " ") for the title:
To create one, create a UserControl in your project. That's MyTaskPane below. Then, in your ThisAddIn class, create the task pane for windows that you want it on. The following would create the task pane on every window.
You should also remove the task panes when each window closes as described in the MSDN documentation.
public partial class ThisAddIn
{
Inspectors _inspectors;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
MyTaskPane pane = new MyTaskPane();
var taskPane = this.CustomTaskPanes.Add(pane, "My Custom Task Pane");
taskPane.Visible = true;
_inspectors = Application.Inspectors;
_inspectors.NewInspector += Inspectors_NewInspector;
}
void Inspectors_NewInspector(Outlook.Inspector Inspector)
{
MyTaskPane pane = new MyTaskPane();
var taskPane = this.CustomTaskPanes.Add(pane, "My Custom Task Pane", Inspector);
taskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionBottom;
taskPane.Visible = true;
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
If its Form Region's you are looking for, have a look at Add-in Express. They have a product called Regions for Outlook and VSTO.
Key features
Advanced Regions provide developers several unique advantages over the traditional Outlook Form Regions available in VSTO projects:
You can add regions to practically all Outlook windows
You can create form regions for Inspector windows and view regions for Outlook Explorer windows
Your regions work for all versions of Outlook from 2003 to 2013
Your regions are shared (multiple regions can share the same area with the ability to switch between them)
Your regions can be hidden and minimized Your regions can be dragged between Outlook panes
Folder view pane regions
Reading pane regions
Task pane dock based regions
I am new to WPF, I want create a project with ribbon window. I started new project and started with new window with ribbon control. What I want is, when user click on a button in ribbon control, I need to add another window as a tab instance in my main window under the ribbon control like we see in office word (new document) and Photoshop etc. How to achieve this behavior, I searched on google and I found a lot of tutorials how to add ribbon control not going further. any one help me..
In your RibbonWindow XAML, define a TabControl
<RibbonWindow>
...
<TabControl Name="mainTabControl" />
</RibbonWindow>
Add an EventHandler to your RibbonButton:
<RibbonButton Name="newTabRibbonButton" Click="newTabRibbonButton_Click_1" />
private void newTabRibbonButton_Click_1(object sender, RoutedEventArgs e)
{
TabItem newItem = new TabItem();
newItem.Header = "New Document";
mainTabControl.Items.Add(newItem);
}
Note however, that you need to define the Content for your TabItem.