일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- MFC
- 윈도우프로그래밍
- 윈도우 프로그래밍
- 운영체제
- 컴퓨터 구조
- 핵심 API로 배우는 윈도우프로그래밍
- 윈도우 구조
- Win32 API
- Graphics
- c4d
- 베지에 곡선
- denoising
- window programming
- modeling
- Mesh Processing
- 그래픽스
- OpenGL
- win32
- 윈도우
- 렌더링
- MFC 윈도우 프로그래밍
- 그래픽스기초
- bezier curve
- 셰이더
- 오픈지엘
- shader programming
- shader
- 컴퓨터 아키텍쳐
- Geometry Modeling
- 셰이더프로그래밍
Archives
- Today
- Total
오다기리 박의 알고리즘 노트
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 6번 풀이 본문
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 | #include <Windows.h> #include<tchar.h> #include<string.h> #include<math.h> //#pragma comment(linker,"/entry:WinMainCRTStartup /subsystem:console") LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam); HINSTANCE hInst; 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 = WndProc; 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); 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; } #define IDC_EDIT1 100 #define IDC_EDIT2 101 #define IDC_EDIT3 102 #define IDC_BUTTON1 103 #define IDC_BUTTON2 104 #define IDC_BUTTON3 105 #define IDC_BUTTON4 106 LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; static HWND hEdit1, hEdit2, hEdit3,hButton1, hButton2, hButton3, hButton4; double num1, num2, result; TCHAR tmp[20]; switch (iMsg) { case WM_CREATE: hEdit1 = (HWND)CreateWindow(_T("edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 80, 70, 80, 20, hwnd, (HMENU)IDC_EDIT1, hInst, NULL); hEdit2 = (HWND)CreateWindow(_T("edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 200, 70, 80, 20, hwnd, (HMENU)IDC_EDIT2, hInst, NULL); hEdit3 = (HWND)CreateWindow(_T("edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 100, 170, 150, 20, hwnd, (HMENU)IDC_EDIT3, hInst, NULL); hButton1 = (HWND)CreateWindow(_T("button"), _T("+"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 100, 100, 50, 20, hwnd, (HMENU)IDC_BUTTON1, hInst, NULL); hButton2 = (HWND)CreateWindow(_T("button"), _T("-"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 200, 100, 50, 20, hwnd, (HMENU)IDC_BUTTON2, hInst, NULL); hButton3 = (HWND)CreateWindow(_T("button"), _T("X"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 100, 130, 50, 20, hwnd, (HMENU)IDC_BUTTON3, hInst, NULL); hButton4 = (HWND)CreateWindow(_T("button"), _T("/"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 200, 130, 50, 20, hwnd, (HMENU)IDC_BUTTON4, hInst, NULL); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BUTTON1: num1=GetDlgItemInt(hwnd, IDC_EDIT1, NULL, TRUE); num2 = GetDlgItemInt(hwnd, IDC_EDIT2, NULL, TRUE); result = num1 + num2; SetDlgItemInt(hwnd, IDC_EDIT3, result, TRUE); break; case IDC_BUTTON2: num1 = GetDlgItemInt(hwnd, IDC_EDIT1, NULL, TRUE); num2 = GetDlgItemInt(hwnd, IDC_EDIT2, NULL, TRUE); result = num1 - num2; SetDlgItemInt(hwnd, IDC_EDIT3, result, TRUE); break; case IDC_BUTTON3: num1 = GetDlgItemInt(hwnd, IDC_EDIT1, NULL, TRUE); num2 = GetDlgItemInt(hwnd, IDC_EDIT2, NULL, TRUE); result = num1 * num2; SetDlgItemInt(hwnd, IDC_EDIT3, result, TRUE); break; case IDC_BUTTON4: num1 = GetDlgItemInt(hwnd, IDC_EDIT1, NULL, TRUE); num2 = GetDlgItemInt(hwnd, IDC_EDIT2, NULL, TRUE); result = num1 / num2; _stprintf_s(tmp, 20, _T("%lf"), result); SetDlgItemText(hwnd, IDC_EDIT3, tmp); break; } break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, iMsg, wParam, lParam); } | cs |
'WIN32 API' 카테고리의 다른 글
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 8번 풀이 (0) | 2017.11.03 |
---|---|
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 7번 풀이 (0) | 2017.11.03 |
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 5번 풀이 (0) | 2017.11.03 |
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 4번 풀이 (0) | 2017.11.03 |
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 3번 풀이 (0) | 2017.11.03 |