Hide header text and header toolbar in Outlook addin - c#

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

Related

Excel VSTO Add-In: Cannot reactivate Excel after MessageBox.Show("Test");

I am implementing a VSTO Excel Add-In which displays some modal dialogs. These dialogs are not shown as own windows in the windows taskbar. But under certain circumstances these dialogs are not are vanishing from the top of Excel and cannot got back by using the task bar!
The whole story (reproducable with Windows XP - 7, Excel 2007 - 2010):
I do open Excel and create two or more new workbooks
I do show a modal dialog, let's say via "MessageBox.Show" I open "notepad" and maximize its window
I try to reactivate one of the excel workbook windows via the windows
taskbar
I expect: Excel will come up with my modal MessageBox to
appear on top
The actual result is: Neither the MessageBox nor any of the Excel workbooks comes up, when you click a workbook item in the windows taskbar!
Why???
I can reactivate Excel via Ctrl + Tab. Then my modal dialog / MessageBox is correctly on the top. It's easy to reproduce if you have Visual Studio and Excel. Please help!
Greets, Jörg
Code-Sample:
Just create an empty Visual C# / Office / 2010 / Office 2010 Add-In
Replace the content of "ThisAddIn.cs" by the following code:
-
namespace ExcelAddIn6
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
NativeWindow excelWindowThatIsTheOwner = null;
try
{
//Get excel main window to set owner (however does not help anyway)
excelWindowThatIsTheOwner = new NativeWindow();
excelWindowThatIsTheOwner.AssignHandle(new IntPtr(Globals.ThisAddIn.Application.Hwnd));
//Create two more workbooks to have more than one...
Globals.ThisAddIn.Application.Workbooks.Add();
Globals.ThisAddIn.Application.Workbooks.Add();
Globals.ThisAddIn.Application.WindowState = Excel.XlWindowState.xlMaximized;
//Show modal dialog (here: a message box, but )
MessageBox.Show(owner: excelWindowThatIsTheOwner,
text: "I am a modal MessageBox.\nNow bring another application to the foreground and then try to bring excel back via the windows taskbar...");
//Problem stays the same for modal forms
var myForm = new Form();
myForm.ShowInTaskbar = false;
myForm.ShowDialog(excelWindowThatIsTheOwner);
}
finally
{
//Cleanup
if (excelWindowThatIsTheOwner != null) excelWindowThatIsTheOwner.ReleaseHandle();
}
}
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
}

How can you add a Custom Panel in a Visio 2013 add-in?

Recently I wrote an outlook add-in which has a ribbon.xml file for an extra ribbon, context menu's, etc. I also added an extra panel docked on the right of my window.
Now I've begun some research as on how to create add-ins for Visio. The ribbon.xml is practically the same, so that's not a problem at all. However, I can't seem to find any way to add a custom panel when a Visio document is opened.
So far I have this in Visio to know if a document is opened/created/changed:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
MessageBox.Show("Visio Add-In V1");
Globals.ThisAddIn.Application.DocumentChanged += new Visio.EApplication_DocumentChangedEventHandler(docChanged);
Globals.ThisAddIn.Application.DocumentOpened += new Visio.EApplication_DocumentOpenedEventHandler(docChanged);
Globals.ThisAddIn.Application.DocumentCreated += new Visio.EApplication_DocumentCreatedEventHandler(docChanged);
}
private void docChanged(Visio.Document doc)
{
MessageBox.Show("Document loaded");
}
In outlook I would do this to add a custom panel (simplified):
MyPanel ctrl = new MyPanel();
Microsoft.Office.Tools.CustomTaskPane ctp = Globals.ThisAddIn.CustomTaskPanes.Add(ctrl, title);
ctp.Visible = true;
ctp.Width = 300;
ctp.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;
Now how would I be able to do this in a Visio 2013 Add-In?
Edit:
Unfortunately this makes me think it's not possible:
http://msdn.microsoft.com/en-us/library/vstudio/bf08984t.aspx
Edit2:
The following answer should work: Are Task Panes Available in Visio VSTO?
However I can't seem to find a way to get a docked panel on my main window. Here is what I tried:
Globals.ThisAddIn.Application.Windows.Add("testpanel", VisWindowStates.visWSDockedLeft, VisWinTypes.visStencilAddon, null, null, null, 300);
This adds the window as if it were a new drawing...
Edit3:
Visio throws a COM exception on this saying I have an invalid window type.
Application.Windows.Add("testpanel", VisWindowStates.visWSDockedRight, VisWinTypes.visAnchorBarAddon, null, null, 300);
You can use Anchor Bars in Visio, not Task Panes
If you download the Visio SDK and look in the Codes Samples Library, you will find Anchor Bar Usage under User Interface.
For completeness, you may wish to review this MSDN article Windows.Add Method (Visio) - http://msdn.microsoft.com/en-us/library/office/ff767674.aspx

CustomTaskPane wont close completely

When I close a CustomTaskPane and change the worksheet, it seems that a pane wasn't removed completely. And the Worksheet area of size of CustomTaskPane becomes inactive.
Here is how I am doing in code:
ctp.Visible = false;
And in PaneVisibleChanged event:
private void PaneVisibleChanged(object sender, EventArgs e)
{
CustomTaskPane pane = (CustomTaskPane)sender;
if (!pane.Visible)
{
pane.Control.Dispose();
CustomTaskPanes.Remove(pane);
}
}
Observation: It happens when I have two CustomTaskPanes side by side and I am closing one.
I'm facing a similar issue with a custom task pane not disposing correctly in VSTO Excel 2010. The code I'm using that tries to fix the issue is simple:
var taskbar = Globals.ThisWorkbook.Application.CommandBars["Task Pane"];
taskbar.Reset();
The Visible event of the side panel does not seem to work ok for me. I usually show or hide the task pane like this:
Globals.ThisWorkbook.Application.CommandBars["Task Pane"].Visible = false;

Adding panel to Appointment/calendar item window in outlook

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

Alternative to TextViewCreated such as (TextViewChanged)?

I am creating a small Visual Studio 2010 extension in C# which uses the IWpfTextViewCreationListener and TextViewCreated to capture when a new TextView is opened in the VS environment. The problem I am having is that this method only fires when a new window is opened via the VS Solution Explorer window, and not fired when VS already contains opened windows when started, and switching window tabs. I have tried looking for something like TextViewChanged, but could not find such method. Is there anyway to capture the new TextView when another tabbed window is selected?
Any help would be greatly appreciated.
This question has also been posted on the MSDN VS Extensibility forum:
VSX 2010 - Alternative to TextViewCreated such as (TextViewChanged)?
Thanks
John
There is no TextViewCreated, but if you register to IWpfTextView.GotAggregateFocus as it is created, you get a hook to every switch between files:
public void TextViewCreated(IWpfTextView textView)
{
textView.GotAggregateFocus += TextViewCameToFocus;
// Do stuff when a new IWpfTextView is created...
}
void TextViewCameToFocus(object sender, EventArgs e)
{
var focusedTextView = (IWpfTextView)sender;
// Do stuff when a specific IWpfTextView comes to focus...
}
You may also want to keep track of the IWpfTextView objects, if you want to be able to link between the fired events to your logic of each textview.

Categories