Adding a section to the taskbar in Outlook 2007/2010?

I would like to add a new section to the taskbar in Outlook 2010 (or 2007). I found code to create a new folding taskbar, and someone claims you can't change the To-Do panel, but I also found a product called Add-In Express that claims to be able to do this. (although at a price of $ 349 this is not worth it for a one-time project).

Can this be done?

+3
source share
3 answers

After some research (and seeing the documentation for the Express add-in product), I realized that you can customize the taskbar in Outlook 2007.

CodeProject --, "" ( ) Outlook. :

Microsoft Outlook

:

  • Outlook , (, )
  • , .
  • To-Do Bar,

, :

  • : "To-Do" "WUNDERBAR". , ( "ToDoBar" ) .
  • (, ; -).

( , To-Do ..).

, Spy ++, , Outlook.

:

Connect.cs:

private const string SIBLING_WINDOW_CLASS = "NetUINativeHWNDHost";
public delegate bool EnumChildCallback(IntPtr hwnd, ref IntPtr lParam);

[DllImport("User32.dll")]
public static extern bool EnumChildWindows(IntPtr hWndParent, EnumChildCallback lpEnumFunc, ref IntPtr lParam);

[DllImport("User32.dll")]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern int GetWindowTextLength(IntPtr hWnd);

public static bool EnumChildProc(IntPtr hwndChild, ref IntPtr lParam)
{
    StringBuilder className = new StringBuilder(128);
    GetClassName(hwndChild, className, 128);

    int length = GetWindowTextLength(hwndChild);
    StringBuilder windowText = new StringBuilder(length + 1);
    GetWindowText(hwndChild, windowText, windowText.Capacity);

    if (className.ToString() == "WUNDERBAR" && windowText.ToString() == "ToDoBar")
    {
        lParam = hwndChild;
        return false;
    }
    return true;
}

public void OnStartupComplete(ref System.Array custom)
{
    if (_outlookApplication == null)
        return; //We were not loaded into Outlook, so do nothing

    //Get the instance of Outlook active explorer (= the main window) and start capturing selection changes
    _outlookExplorer = _outlookApplication.ActiveExplorer();
    _outlookExplorer.SelectionChange += new ExplorerEvents_10_SelectionChangeEventHandler(outlookExplorer_SelectionChange);

    //Find Outlook window handle (HWND)
    IntPtr outlookWindow = FindOutlookWindow();

    if (outlookWindow == IntPtr.Zero)
        return;

    // Find ToDoBar window handle
    IntPtr todoBarWindow = IntPtr.Zero;
    EnumChildCallback cb = new EnumChildCallback(EnumChildProc);
    EnumChildWindows(outlookWindow, cb, ref todoBarWindow);

    if (todoBarWindow == IntPtr.Zero)
        return;

    //Find sibling window handle (HWND)
    //Sibling window is the window which we are going to "cut" to make space for our own window
    IntPtr siblingWindow = SafeNativeMethods.FindWindowEx(todoBarWindow, IntPtr.Zero, SIBLING_WINDOW_CLASS, null);
    if (siblingWindow == IntPtr.Zero)
        return;

    //Initialise PanelManager and assign own panel to it
    _panelManager = new PanelManager(outlookWindow, siblingWindow);
    _customPanel = new MyPanel();
    _panelManager.ShowBarControl(_customPanel);
}

PanelManager.cs:

private void ResizePanels()
{
    if (_changingSize)
        return; //Prevent infinite loops

    _changingSize = true;

    try
    {
        //Get size of the sibling window and main parent window
        Rectangle siblingRect = SafeNativeMethods.GetWindowRectangle(this.SiblingWindow);
        Rectangle parentRect = SafeNativeMethods.GetWindowRectangle(this.ParentWindow);

        //Calculate position of sibling window in screen coordinates
        SafeNativeMethods.POINT topLeft = new SafeNativeMethods.POINT(siblingRect.Left, siblingRect.Top);
        SafeNativeMethods.ScreenToClient(this.ParentWindow, ref topLeft);

        //Decrease size of the sibling window
        int newHeight = parentRect.Height - topLeft.Y - _panelContainer.Height;
        SafeNativeMethods.SetWindowPos(this.SiblingWindow, IntPtr.Zero, 0, 0, siblingRect.Width, newHeight, SafeNativeMethods.SWP_NOMOVE | SafeNativeMethods.SWP_NOZORDER);

        //Move the bar to correct position
        _panelContainer.Left = topLeft.X;
        _panelContainer.Top = topLeft.Y + newHeight;

        //Set correct height of the panel container
        _panelContainer.Width = siblingRect.Width;
    }
    finally
    {
        _changingSize = false;
    }
}

COM VSTO, VSTO. , , Office (IDTExtensibility2).

, , Outlook. , -)

+3

, , TaskPane, . TaskPanes , Form Regions, Office 2007 ( , , 2007-2010 ). , , , .

MSDN.

, TaskPane, . , , .

, Express . ​​ 2- . - , , , .

+2

Take a look at the areas of the Outlook form. http://msdn.microsoft.com/en-us/library/bb386301.aspx You can add them using the VSTO add-on. Although Add-in express has a few more options where you can add them. The network also has several tutorials.

Mark

0
source

Source: https://habr.com/ru/post/1725115/


All Articles