0

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.

1 Answers1

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
  • I updated the answer. You should use App.WindowHandle32 in Visio. – EylM May 21 '20 at 07:28
  • 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