일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Graphics
- OpenGL
- c4d
- 셰이더프로그래밍
- shader programming
- 렌더링
- 컴퓨터 아키텍쳐
- 컴퓨터 구조
- window programming
- 윈도우 구조
- denoising
- modeling
- Win32 API
- shader
- 그래픽스
- Geometry Modeling
- Mesh Processing
- 윈도우프로그래밍
- 베지에 곡선
- 핵심 API로 배우는 윈도우프로그래밍
- 윈도우 프로그래밍
- win32
- 오픈지엘
- bezier curve
- 윈도우
- 운영체제
- MFC
- 그래픽스기초
- MFC 윈도우 프로그래밍
- 셰이더
Archives
- Today
- Total
오다기리 박의 알고리즘 노트
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 8장 2번 풀이 본문
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 151 | #include <Windows.h> #include<tchar.h> #include<string.h> #include"resource.h" #include<winres.h> //#pragma comment(linker,"/entry:WinMainCRTStartup /subsystem:console") LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam); HINSTANCE hInst; void FileWrite(HWND hwnd, LPTSTR filename) { HANDLE hFile; LPTSTR buffer; int size; hFile = CreateFile(filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); size = GetWindowTextLength(hwnd); buffer = new TCHAR[size + 1]; memset(buffer, 0, (size + 1) * sizeof(TCHAR)); GetWindowText(hwnd, buffer, size + 1); buffer[size] = NULL; WriteFile(hFile, buffer, (size) * sizeof(TCHAR), (LPDWORD)&size, NULL); free(buffer); CloseHandle(hFile); } void FileRead(HWND hwnd, LPTSTR filename) { HANDLE hFile; LPTSTR buffer; DWORD size, CharNum; int fileSize; hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if (hFile == INVALID_HANDLE_VALUE) return; fileSize =GetFileSize(hFile, &size); buffer = new TCHAR[(int)fileSize / sizeof(TCHAR) + 1]; memset(buffer, 0, fileSize); ReadFile(hFile, buffer, fileSize, &CharNum, NULL); buffer[(int)fileSize / sizeof(TCHAR)] = NULL; SetWindowText(hwnd, buffer); free(buffer); CloseHandle(hFile); } 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 = MAKEINTRESOURCE(IDR_MENU1); 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 LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; RECT rect; PAINTSTRUCT ps; OPENFILENAME OFN,SFN; static TCHAR filepath[1000], filename[100]; TCHAR filter[] = _T("텍스트 파일 (*.txt)\0*.txt\0모든 파일 (*.*)\0*.*\0"); static HWND hEdit; switch (iMsg) { case WM_CREATE: GetClientRect(hwnd, &rect); hEdit = CreateWindow( _T("edit"), NULL, WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, 0, 100, rect.right, rect.bottom, hwnd, (HMENU)IDC_EDIT1, hInst, NULL); break; case WM_SIZE: GetClientRect(hwnd, &rect); MoveWindow(hEdit, 0, 0, rect.right, rect.bottom, TRUE); break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_FILEOPEN: memset(&OFN, 0, sizeof(OPENFILENAME)); OFN.lStructSize = sizeof(OPENFILENAME); OFN.hwndOwner = hwnd; OFN.lpstrFile = filepath; OFN.nMaxFile = 1000; OFN.lpstrFileTitle = filename; OFN.nMaxFileTitle = 100; OFN.lpstrFilter = filter; OFN.Flags = OFN_EXPLORER; OFN.lpstrInitialDir = _T("."); GetOpenFileName(&OFN); FileRead(hEdit, filepath); break; case ID_FILESAVE: memset(&SFN, 0, sizeof(OPENFILENAME)); SFN.lStructSize = sizeof(OPENFILENAME); SFN.hwndOwner = hwnd; SFN.lpstrFilter = filter; SFN.lpstrFile = filepath; SFN.nMaxFile = 1000; SFN.lpstrInitialDir = _T("."); GetSaveFileName(&SFN); FileWrite(hEdit, filepath); break; } break; case WM_PAINT: break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, iMsg, wParam, lParam); } | cs |
'WIN32 API' 카테고리의 다른 글
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 8장 5번 풀이 (0) | 2018.01.09 |
---|---|
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 8장 3~4번 풀이 (0) | 2018.01.09 |
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 8장 1번 풀이 (0) | 2018.01.09 |
[WIN32 API] 9. 윈도우 소켓 프로그래밍 (0) | 2018.01.09 |
[핵심 API로 배우는 윈도우프로그래밍(강경우, 한빛아카데미)] 7장 11번 풀이 (0) | 2017.11.03 |