I have an AddIn whose UI is a .NET Windows Form. The form's default behaviour is to sink below MicroStation's main window when the user clicks in any MicroStation window or dialog. If I call Form.TopMost(), the form sits permanently right on top of all Windows, including those of other applications. Neither behaviour is what a user expects.
I would like my AddIn's UI to appear on top relative to MicroStation's main window, just like built-in dialogs and toolboxes. Presumably I need the .NET version of MicroStation's Window, so I can set that as my AddIn's parent? Or, do I have to delve into the Win32 API and use the MicroStation window's native handle to achieve my goal?
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Answer Verified By: Jon Summers
That is correct, must inherit from Bentley.MicroStation.WinForms.Adapter in combination with AttachAsTopLevelForm(addin, true); There is a problem with Bentley Winforms showing in the visual studio designer, so I created a custom control that will toggle back to the regular form when in design mode. (Not sure if there is another way) Also, I have noticed issues with maximizing the window, you can override WndProc and handle the maximize state on your own.
Unknown said:Bentley.MicroStation.WinForms.Adapter
Thanks, Jan and Maury, for reminding me about that! Like so much in the .NET API, it's not documented.
Unknown said:...in combination with AttachAsTopLevelForm(addin, true)
Without that the WinForm appears but is frozen. With that statement it behaves as expected.
Unknown said:I created a custom control that will toggle back to the regular form when in design mode
Cool!
Unknown said:I have not tested WinForms in CONNECT Edition yet
The only example of Winforms.Adapter that I can find in the Update 3 SDK is WPFDemo3.cs. No other example uses that adapter.
Regards, Jon Summers LA Solutions