Application of DirectX in MFC Framework

Generally speaking, when programming with DirectX, one will directly create a window under the Win32 project and then perform operations on that window. However, if you have written some code with MFC, and then suddenly find that using DirectX to process the 3D display part will be more awesome, then you need to combine the two
Due to my previous research on DirectX as a beginner, I left a big shadow in my mind, so I only started working on it again recently when I was forced to do so. As a result, it was found that the integration with the MFC framework was not as difficult as imagined. Based on this article by Qian Mo, the following is a brief introduction to the process:
1. Modify the initialization function of D3D
From the initialization process of D3D in the article, it can be seen that the window handle, width, and height parameters are related to the window during initialization. If you want to present the results of D3D processing on the Picture Control control in MFC, you can obtain the window handle, width, and height of the Picture Control, and then pass them to the initialization function for assignment
2. Modify the call location of the rendering function in D3D
For the convenience of operation, this article has created a new thread specifically responsible for calling the D3D rendering function. During initialization, the D3D initialization function is called, and when the start button is clicked, the thread is called to start rendering
OK, that's all that needs to be modified. Of course, if it is to be truly applied to practical engineering, further improvement is needed and will not be repeated. The following is a schematic diagram of the modified program's running effect: