outlookvstooutlook-addinoffice-addinscustomtaskpane

VSTO Outlook: Handle event when custom task pane changes its height


The custom task pane has a down arrow button at the top right corner which if you click on it a contextual menu appears showing two options:

I would like to handle the event when user resize the height of the custom task pane and gather the height set by the user. Is that possible? if so, how? what event do I need to handle?


Solution

  • Your task pane is a user control where you could override methods in the following way:

    protected override void OnSizeChanged(EventArgs e)
    {  
       // this.Size
       base.OnSizeChanged(e);
    }
    

    Don't forget that you could also override the windows procedure which processes Windows messages - WndProc, where you could detect such actions like closing (see WM_CLOSE).