Hi. I need to create process from program (WinAPI C++) which will be child window of…
- User
Hi. I need to create process from program (WinAPI C++) which will be child window of program HWND
- Assistant
Here is an example code to create a child window of a program's HWND:
codeHWND hwndParent = ... // Parent HWND HINSTANCE hInstance = ... // Instance handle of the program WCHAR szClassName[] = L"MyChildWindowClass"; // Class name of the child window // Register the window class WNDCLASSEX wcex = { sizeof(WNDCLASSEX) }; wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = DefWindowProc; wcex.hInstance = hInstance; wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszClassName = szClassName; RegisterClassEx(&wcex); // Create the child window HWND hwndChild = CreateWindowEx(0, szClassName, nullptr, WS_CHILD | WS_VISIBLE, 0, 0, 200, 200, hwndParent, nullptr, hInstance, nullptr);