問題描述
您可以將一個進程的 Direct3D 窗口渲染到另一個進程的 HWND 中嗎? (Can you render a Direct3D window for one process into another process' HWND?)
我想做的是讓一個 Windows 應用程序啟動另一個 Direct3D 應用程序,並讓 Direct3D 應用程序呈現到父進程提供的控件中。
這可能嗎?如果是,怎麼做?
參考解法
方法 1:
It can be done easly, all you need to do is pass the HWND window id as a parameter when creating D3DDevice. It even works during interop ‑ you can pass the hWnd from .NET to C++ and render C# window using native directX.
方法 2:
Here's one example, hosting content of a WPF window in an existing Win32 window. I did this when writing a WPF‑based screen saver, having to render into the Screen Saver little preview window.
http://stuff.seans.com/2008/09/01/writing‑a‑screen‑saver‑in‑wpf/
方法 3:
This is possible. I remember doing it in VB6 when writing screen savers. The screen saver control panel sends a commandline to the screen saver with the HWND of the preview window. Using that HWND, you can then get the HDC and from there everything else you need.
(by Oliver Jones、Dror Helper、Sean Sexton、Richard C)