Popup Window Placement

Add-in Express™ Support Service
That's what is more important than anything else

Popup Window Placement
How to determine pop-up Window size and position, subclassing IE ? 
Robert Apostolico



I've created a Command Item add-in. When the icon is clicked, I'd like to display our add-in's pop-up menu.
I've determined that I can easily access IEApp.Left, .Width, .Top, .Height and .HWnd.

What I can't seem to figure out is how to properly locate the TOP of our menu/pop-up.

The IEApp.Top refers to the TOP of the IE application window. Between that and the actual HTML/webBrowser control, there could be numerous other toolbars/menus. How do I determine that offset?

Additionally (and slightly off topic) is if/when our menu appears, someone could move/size the IE App.
Any suggestions on subclassing the IE App window so our menu appears "glued to it" ?

Anyone looking to create a pop-up menu from a Command Item would be looking for similar functionality.
An example of this would be great! (C#)

Thank you.
Posted 06 May, 2014 10:44:47 Top
Andrei Smolin

Add-in Express team

Posts: 18652
Joined: 2006-05-11
Hello Bob,

Please check section Windowing and Threading in the PDF file in the folder {Add-in Express}\Docs on your development PC. You use the handle (hwnd) returned by the corresponding property to show your form so that the IE window corresponding to the handle owns the form; please find the code sample in the manual - search for "Getting the right-clicked and selected elements". As to positioning the form, you use Form.StartPostion and optionally Form.Location. You get the owner window coordinates as demonstrated at http://stackoverflow.com/questions/1434524/how-do-i-find-the-position-location-of-a-window-given-a-hwnd-without-nativemet. You position the form as shown at http://stackoverflow.com/questions/17369159/setting-forms-location-when-calling-form-show.

Andrei Smolin
Add-in Express Team Leader
Posted 07 May, 2014 07:14:49 Top