VC implementation of a process window embedded in the B process window display method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.