1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#include "ChildWindowToMainWindow.h"
#include "WindowsProgram/MainWindow.h"
#include "resources.h"
char ChildWindowToMainWindow::m_szChildClassName[]="Child!";
HINSTANCE ChildWindowToMainWindow::hChildInstance = NULL;
ChildWindowToMainWindow::ChildWindowToMainWindow(HINSTANCE hinstance)
{
hChildInstance = hinstance;
m_classChild.cbClsExtra = 0;
m_classChild.cbSize = sizeof(WNDCLASSEX);
m_classChild.cbWndExtra;
m_classChild.hbrBackground = (HBRUSH) (COLOR_WINDOW);
m_classChild.hCursor = LoadCursor(NULL, IDC_HAND);
m_classChild.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_APP_ICON));
m_classChild.hIconSm = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_APP_ICON));
m_classChild.hInstance = hinstance;
m_classChild.lpfnWndProc = MainWndProc;
m_classChild.lpszClassName = m_szChildClassName;
m_classChild.lpszMenuName = NULL;
m_classChild.style = CS_DBLCLKS;
}
ChildWindowToMainWindow::~ChildWindowToMainWindow()
{
//dtor
}
LONG APIENTRY ChildWindowToMainWindow::MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
RECT RectClient;
switch(msg)
{
case WM_CREATE:
CreateWindowEx(
0,
m_szChildClassName,
"ChildWindow",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
500, 400,
MainWindow::m_hwnd,
NULL,
hChildInstance,
NULL
);
return 0;
case WM_SIZE:
GetClientRect(hwnd, &RectClient);
EnumChildWindows(hwnd, EnumChildProc,
(LPARAM) &RectClient);
return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
BOOL CALLBACK ChildWindowToMainWindow::EnumChildProc(HWND hwndChild, LPARAM lParam)
{
rcParent = (LPRECT) lParam;
MoveWindow(hwndChild,
/* Make sure the child window is visible. */
ShowWindow(hwndChild, SW_SHOW);
return TRUE;
}
}
|