How do you pass the owner window to Show() method overload?

后端 未结 1 1387
忘了有多久
忘了有多久 2020-12-10 07:33

I\'m working on an Excel add in that opens a winform after the user clicks a button on a ribbon bar. This button needs to be non-modal so that the user can still interact w

相关标签:
1条回答
  • 2020-12-10 08:15

    You need to create a class that implements IWin32Window and returns Excel's Application.Hwnd property.

    For example:

    class ArbitraryWindow : IWin32Window {
        public ArbitraryWindow(IntPtr handle) { Handle = handle; }
        public IntPtr Handle { get; private set; }
    }
    
    newForm.Show(new ArbitraryWindow(new IntPtr(Something.Application.Hwnd)));
    
    0 讨论(0)
提交回复
热议问题