WIN32 API
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 4번 풀이
오다기리 박
2017. 11. 3. 21:59
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 83 84 85 86 87 | #include <Windows.h> #include<tchar.h> #include<string.h> #include<math.h> //#include"resource.h" //#pragma comment(linker,"/entry:WinMainCRTStartup /subsystem:console") LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam); HINSTANCE hInst; HWND hwndChild[4]; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { HWND hwnd; MSG msg; WNDCLASS WndClass; hInst = hInstance; WndClass.style = CS_HREDRAW | CS_VREDRAW; WndClass.lpfnWndProc = FrameWndProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = hInstance; WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); WndClass.lpszMenuName = NULL; WndClass.lpszClassName = _T("Window Class Name"); RegisterClass(&WndClass); WndClass.lpfnWndProc = ChildWndProc; WndClass.lpszClassName = _T("Child Window Class Name"); RegisterClass(&WndClass); hwnd = CreateWindow( _T("Window Class Name"), _T("박정호"), WS_OVERLAPPEDWINDOW, 50, 50, 1000, 700, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam; } LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; RECT rect; switch (iMsg) { case WM_CREATE: break; case WM_LBUTTONDOWN: GetClientRect(hwnd, &rect); hwndChild[0] = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Child Window Class Name"), NULL, WS_CHILD | WS_VISIBLE, 0, 0, rect.right / 2 - 1, rect.bottom / 2 - 1, hwnd, NULL, hInst, NULL); hwndChild[1] = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Child Window Class Name"), NULL, WS_CHILD | WS_VISIBLE, rect.right/2+1, 0, rect.right / 2 - 1, rect.bottom / 2 - 1, hwnd, NULL, hInst, NULL); hwndChild[2] = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Child Window Class Name"), NULL, WS_CHILD | WS_VISIBLE, 0, rect.bottom/2+1, rect.right / 2 - 1, rect.bottom / 2 - 1, hwnd, NULL, hInst, NULL); hwndChild[3] = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Child Window Class Name"), NULL, WS_CHILD | WS_VISIBLE, rect.right/2+1, rect.bottom / 2 + 1, rect.right / 2 - 1, rect.bottom / 2 - 1, hwnd, NULL, hInst, NULL); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, iMsg, wParam, lParam); } LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { return DefMDIChildProc(hwnd, iMsg, wParam, lParam); } | cs |