Loading a WPF Window without showing it

前端 未结 12 796
独厮守ぢ
独厮守ぢ 2020-12-12 16:14

I create a global hot key to show a window by PInvoking RegisterHotKey(). But to do this I need that window\'s HWND, which doesn\'t exist until the

12条回答
  •  [愿得一人]
    2020-12-12 16:46

    The WindowInteropHelper class should allow you to get the HWND for the WPF window.

    MyWindow win = new MyWindow();
    WindowInteropHelper helper = new WindowInteropHelper(win);
    
    IntPtr hwnd = helper.Handle;
    

    MSDN Documentation

提交回复
热议问题