Submit GDI to WPF Window

I did some searches, but I can not find the exact answer to this. In my C # WPF application, I get the HWND pointer and pass it to C dll. Then the C dll tries to use the GDI calls to display the overlay in my window. There are no errors, but nothing appears. If I switch to Windows Form, the DLL can display it perfectly. If I host a WindowsFormHost control and use hwnd, I get the same effect. I saw information about the HwndHost control, but it really doesn't look like what I want. Perhaps someone with more knowledge of this control might tell me differently. I read somewhere that the hwnd used to render DirectX (e.g. WPF) also cannot use GDI. Does this make my script impossible? I could fake it by imposing a boundless shape on top of the WPF window, but obviously that would not be too pretty. Any thoughts or ideas?

+4
source share
1 answer

You cannot have WPF and GDI rendering for the same hwnd, but you can easily have a child hwnd inside your WPF application and let GDI render it. Take a look at HwndHost for this. The section "Microsoft Windows Win32 Hosting in WPF" in this article contains more detailed information. He also talks about the various problems that you will encounter (for example, in airspace) when performing this type of interaction.

+5
source

Source: https://habr.com/ru/post/1338487/


All Articles