일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- modeling
- Graphics
- denoising
- shader programming
- 그래픽스기초
- Geometry Modeling
- c4d
- 윈도우
- Mesh Processing
- 컴퓨터 구조
- 운영체제
- 셰이더프로그래밍
- 그래픽스
- bezier curve
- 베지에 곡선
- 렌더링
- 윈도우 프로그래밍
- 컴퓨터 아키텍쳐
- 셰이더
- MFC
- win32
- 오픈지엘
- 핵심 API로 배우는 윈도우프로그래밍
- MFC 윈도우 프로그래밍
- window programming
- OpenGL
- 윈도우프로그래밍
- Win32 API
- shader
- 윈도우 구조
Archives
- Today
- Total
오다기리 박의 알고리즘 노트
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 5번 풀이 본문
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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | #include <Windows.h> #include<tchar.h> #include<string.h> #include<math.h> #include<stdio.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[2]; 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 = MAKEINTRESOURCE(IDR_MENU3); WndClass.lpszClassName = _T("Window Class Name"); RegisterClass(&WndClass); WndClass.lpszMenuName = NULL; 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; PAINTSTRUCT ps; RECT rect; switch (iMsg) { case WM_CREATE: break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_SPLIT: GetClientRect(hwnd, &rect); hwndChild[0] = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Child Window Class Name"), NULL, WS_CHILD | WS_VISIBLE, 0, 0, rect.right, rect.bottom / 2 - 1, hwnd, NULL, hInst, NULL); hwndChild[1] = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Child Window Class Name"), NULL, WS_CHILD | WS_VISIBLE, 0, rect.bottom / 2 + 1, rect.right, rect.bottom / 2, hwnd, NULL, hInst, NULL); break; } break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, iMsg, wParam, lParam); } LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { static RECT rect; static HDC hdc; PAINTSTRUCT ps; static bool dirX[2] = { true,true }, dirY[2] = { true,true }; static int x[2], y[2]; static int selection = -1; static bool flag[2] = { false,false }; switch (iMsg) { case WM_CREATE: x[0] = y[0] = x[1] = y[1] = 50; GetClientRect(hwnd, &rect); break; case WM_LBUTTONDOWN: if (hwnd == hwndChild[0]) selection = 0; else selection = 1; flag[selection] = flag[selection] ? false : true; if (flag[selection]) SetTimer(hwndChild[selection], selection, 10, NULL); else if (!flag[selection]) KillTimer(hwndChild[selection], selection); break; case WM_TIMER: if (x[wParam]<20 || x[wParam]>rect.right - 20) dirX[wParam] = dirX[wParam] ? false : true; if (y[wParam]<20 || y[wParam]>rect.bottom - 20) dirY[wParam] = dirY[wParam] ? false : true; if (dirX[wParam]) x[wParam]++; else x[wParam]--; if (dirY[wParam]) y[wParam]++; else y[wParam]--; InvalidateRgn(hwndChild[wParam], NULL, TRUE); break; case WM_PAINT: hdc = BeginPaint(hwndChild[0], &ps); Ellipse(hdc, x[0] - 20, y[0] - 20, x[0] + 20, y[0] + 20); EndPaint(hwndChild[0], &ps); hdc = BeginPaint(hwndChild[1], &ps); Ellipse(hdc, x[1] - 20, y[1] - 20, x[1] + 20, y[1] + 20); EndPaint(hwndChild[1], &ps); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefMDIChildProc(hwnd, iMsg, wParam, lParam); } | cs |
'WIN32 API' 카테고리의 다른 글
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 7번 풀이 (0) | 2017.11.03 |
---|---|
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 6번 풀이 (0) | 2017.11.03 |
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 4번 풀이 (0) | 2017.11.03 |
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 3번 풀이 (0) | 2017.11.03 |
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 2번 풀이 (0) | 2017.11.03 |