TweetIf you are trying to run a WPF application, you must remember that WPF content is actually constraint to a single HWND. You could have only a single window handle that represents the entire window, and everything inside it is a bitmap drawn on the WPF canvas. Except Popup (which eventually have its own HWND) no WPF element has its own HWND associated with it. As a matter of fact, a normal win32 application has several HWND’s, I mean every control has its own HWND and the pixels associated with that HWND isn’t been shared between other elements. But while rendering WPF content, a single Pixel can be shared by multiple UIElement, it cannot have Win32 model applied to it. But as it runs as Win32 application, it needed to have a Window handle associated with it which represents the outer window.
To retrieve the Window handle you can call :HwndSource source = (HwndSource)HwndSource.FromVisual(this);
IntPtr hWnd = source.Handle;The above code will retrieve the Window handle associated with your WPF application.
One of the major cases where HWND is really required is with Modal window. In WPF, you might know that you can use the following code to create a modal window :Window w = new Window();
w.ShowDialog(); Read more: Daily .Net Tips
QR:
To retrieve the Window handle you can call :HwndSource source = (HwndSource)HwndSource.FromVisual(this);
IntPtr hWnd = source.Handle;The above code will retrieve the Window handle associated with your WPF application.
One of the major cases where HWND is really required is with Modal window. In WPF, you might know that you can use the following code to create a modal window :Window w = new Window();
w.ShowDialog(); Read more: Daily .Net Tips
QR:
0 comments:
Post a Comment