Modal Form invocation

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

Modal Form invocation
How do I ensure my form is Modal relative to the Browser and positioned properly ? 
George Kierstein




Posts: 47
Joined: 2013-05-04
Hi,

I have created a Form which I open when a toolbar button is clicked. This works fine but I would like it to be a Modal dialog that is tied to the open tab and positioned in the upper left corner of the page.

I have seen a few places on the web that suggest that you have to do some manuvering with the HWND of the browser - What do you suggest a good solution would be ?

Thanks
G
Posted 28 Jun, 2013 17:14:05 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Hello George,

Please search the string "MyWinApiWindow" in the manual. In the code samples that the manual provides, this class is used to specify the parent window for a messagebox.

In your case, you need to show the modal form using this overload:
DialogResult Form.ShowDialog(IWin32Window owner);

You can pass new MyWinApiWindow(this.ParentHandle) as the owner parameter.

Hope this helps.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 01 Jul, 2013 04:15:42 Top
George Kierstein




Posts: 47
Joined: 2013-05-04
Thanks,

That does make it Modal which is great. How would I use this to specify an alignment with the parent window - it always opens in the same location which isn't related to the window and the default options are only to center it.

Ideally what I'd like is to be able to retrieve the bounds of the the actual page area (or the browser itself) so that the form is aligned to the top right of the page instead of floating off to the side or forcibly centered.

Is that possible ? If not, how can I pull out the bounds of the open IE window from its parent handle ?

THanks
G
Posted 02 Jul, 2013 14:33:12 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
George,

Try setting Form.Location in the Form.Shown event of the form. You can use GetWindowRect WinAPI function to get coordinates of the IE window identified by its hwnd.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Jul, 2013 05:45:47 Top