0

I have and VSTO Outlook Add-in which has a custom task pane at the top. Now I am trying to detect if there is a way or some trick to detect when the custom task pane is being resized (its height). Height resize can be done through the menu or clicking on the custom task pane splitter. So how can I detect that the user is being resizing the custom task pane height? is there some way?

Willy
  • 9,848
  • 22
  • 141
  • 284

1 Answers1

1

You can override the OnResize method in any user control, for example, the following code can be used for the Outlook form region instance or custom task pane:

protected override void OnResize(EventArgs e)
{
   // add your code here
   base.OnResize(e);
}

Or just handle the Resize event of the UserControl class:

private void UserControl1_Resize(object sender, EventArgs e)
{
  // add your code here
}
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • yep, i know, the second approach is what i have implemented and it is working but now i have a very particular use case in which i have a problem when moving outlook app to a second external monitor, the resize event is fired and i need to detect if it comes from moving outlook app from one screen to another or if it is really a manual resize of the custom task pane realized by the user, so how can i distinguish one use case from another? so this is why i was asking it is possible to know if the resize was cause explicitly by the user when resizing the ctp. – Willy Feb 09 '23 at 16:38
  • since i have not asked the question properly and here it is asked how to detect if user resize the ctp, ok, your solution is ok, so i have accepted it as the correct answer. You cannot detect directly if the ctp is being resized instead you use the resize changed event of the user control since ctp does not provide such event handler. I will post another more specific post. Thank you very much! – Willy Feb 09 '23 at 17:01