TopMost
it's not good because it's on top of all the applications in the computer.
Except ShowDialog() way, because it's lock the Application.
Asked
Active
Viewed 159 times
0

Gal Tzemach
- 64
- 9
-
Well `ShowDialog()` is modal.. perhaps you just want `Show()`? – Broots Waymb May 12 '20 at 16:18
-
With show() only, the Office App (Visio) take the focos to my Form in some cases. – Gal Tzemach May 13 '20 at 15:58
1 Answers
0
You need to use a modaless dialog in order not to block the Main Office application. You also need to set the Office Application as parent window of the modaless dialog.
1) Use the WindowWrapper class from this answer.
2) Lets assume you have the access to Application object of your Office app. App.WindowHandle32 is the handle to the main Window.
3) Code:
var someDialog = new Form1();
someDialog.Show(new WindowWrapper(new IntPtr(App.WindowHandle32)));
4) Remember to declare the someDialog
variable as a class member.

EylM
- 5,967
- 2
- 16
- 28
-
I working with Visio App (not Excel) and i dont have the Application.hWnd property. What is the equivalent property for visio App? – Gal Tzemach May 21 '20 at 07:19
-
-
Can you please explain me what the different between the four following properties? 1. Application.WindowHandle (it's work fine for few PCs except one, maybe do you know why? the certain one is also with 64bit OS like all others) 2. Application.WindowHandle32 3. Application.InstanceHandle32 4. Application.InstanceHandle64 – Gal Tzemach May 21 '20 at 08:36