Search code examples
.netoutlookvstooutlook-addinoffice-addins

VSTO Outlook: How to detect when any Outlook explorer or inspector window is being drag and then drop (left mouse down and left mouse up/released)


Simply and brief, when programming VSTO Outlook Add-ins, is there any way when any Outlook explorer or inspector window is being drag and drop? I need to handle when the mouse left button is down and then when it is released (up). I want to detect drag-and-drop operations on these windows.


Solution

  • There is no trivial way for detecting that. You can use Windows API functions to subclass any Outlook windows and handle such scenarios. If a control does almost everything you want, but you need a few more features, you can change or add features to the original control by subclassing it. A subclass can have all the features of an existing class as well as any additional features you want to give it. Also you may consider using the SetWindowsHookEx function which installs an application-defined hook procedure into a hook chain. You would install a hook procedure to monitor the system for certain types of events. These events are associated either with a specific thread or with all threads in the same desktop as the calling thread.

    In your case if you need to detect when Outlook windows is dragged into another monitor with a different DPI settings, you may consider handling events related to the DPI change. See Auto-Scale but still process WM_DPICHANGED for more information.