Я создал окно MFC и из другого проекта хотел добавить кнопку в это окно через его дескриптор (используя FindWindow). Ручка правильная, но ничего не происходит. Это недостижимо или я что-то не так делаю?
Вот мой код:
HWND hWnd = FindWindow(NULL, "MFCtest");
if(hWnd)
{
printf("Found it\n");
HWND hwndButton = CreateWindow(
"BUTTON",
"OK", // Button text
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles
0, // x position
0, // y position
100, // Button width
100, // Button height
hWnd, // Parent window
NULL, // No menu.
(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),
NULL); // Pointer not needed.
if(!hwndButton)
printf("GetLastError: %d\n", GetLastError());
}