This article mainly introduces the VC implementation of a process window embedded in the B process window display, for the understanding of the Windows program operating principle of the process problems have some help, the need for friends can refer to the following
This article tells a demo example of how to embed a application in a B application.
The main code is as follows:
<span style= "Font-size:12px;font-weight:normal;" >//Create a process CreateProcess (_t ("A.exe"), Null,null,null,false,create_new_console,null,null,null,null) when the B application is started; Sleep (30); HWND hwndchild = FindWindow (_t ("AAA"), _t ("AAA")), while (!hwndchild) { hwndchild = FindWindow (_t ("AAA"), _t ("AAA")) ;} Move a Process window position MoveWindow (hwndchild,80,20,240,320,true);//a process window embedded in the B process window setparent (hwndchild,hwnd);</span>
An application can with the SetParent function to set the parent window of a pop-up, overlapped, or child window. The new parent window and the child window are must belong to the same application.
This is a description of the use of SetParent from MSDN, saying that the window setparent to be embedded must belong to the same application as the embedded window , but the setparent returned is indeed a null, This is because the window in the a process does not exist in the parent window, and the setparent call returns a handle to the parent window, which returns NULL. However, it does not affect the A-process window embedding.
When the B process window is displayed, the Wm_active received will first receive wa_active or wa_clickactive, and then you will receive the Wa_inactive parameter, that is, at some point, the B process is not set to the front window, This should be when the setparent is called, affecting the B process window. If you want the B process window to receive the wm_active message, you must call SetForegroundWindow (HWND), and if the current window is not the front window, you will not receive wa_inactive in the wm_active message when you exit or minimize. In particular, the code for nesting applications should be kept in mind.
In addition, when using SetParent (Hwndchild,hwnd) to move a process to the B Process window, a window handle with FindWindow query to a process is null.
VC implementation of a process window embedded in the B process window display method