Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <tchar.h>
- LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) // C언어로 치면 선언문
- {
- HWND hwnd;
- MSG msg;
- WNDCLASS WndClass;
- 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_IBEAM);
- 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,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 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 WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
- {
- HDC hdc;
- PAINTSTRUCT ps;
- static TCHAR str[20][100];
- static int count, count2, yPos;
- switch (iMsg)
- {
- case WM_CREATE:
- count = 0;
- count2 = 0;
- yPos = 380;
- break;
- case WM_PAINT:
- hdc = BeginPaint(hwnd, &ps);
- for (int i = 0; i <= count2; i++)
- {
- TextOut(hdc, 0, yPos, str[i], _tcslen(str[i]));
- }
- EndPaint(hwnd, &ps);
- break;
- case WM_CHAR:
- if (wParam == VK_BACK && count > 0)
- {
- count--;
- if (count <= 0 && count2 > 0)// 2줄이상이고 글자가 없을때 개행할 수 있는 조건문
- {
- count = _tcslen(str[count2]);
- count2--;
- }
- }
- else if (wParam == VK_RETURN)
- {
- yPos = yPos - 20;
- count2++;
- count = 0;
- }
- else
- {
- str[count2][count++] = wParam;
- }
- str[count2][count] = NULL;
- InvalidateRgn(hwnd, NULL, TRUE);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- }
- return (DefWindowProc(hwnd, iMsg, wParam, lParam));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement