Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma comment (lib, "User32.lib")
- #pragma comment (lib, "gdi32.lib")
- #include<Windows.h>
- #include<TCHAR.H>
- LRESULT CALLBACK W(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
- {
- HDC hdc;
- PAINTSTRUCT ps;
- static TCHAR str[100];
- static int count, yPos;
- RECT rt = { 0,0 , 1000, 1000 };
- switch (iMsg)
- {
- case WM_CREATE:
- count = 0;
- yPos;
- break;
- case WM_PAINT:
- hdc = BeginPaint(hwnd, &ps);
- DrawText(hdc, str, _tcslen(str), &rt, DT_TOP | DT_LEFT);
- EndPaint(hwnd, &ps);
- break;
- case WM_CHAR:
- if (wParam == VK_BACK && count >= 0)
- {
- if (count != 0) count--;
- if (str[count] == VK_RETURN) count--;
- }
- else
- {
- str[0] = wParam;
- count++;
- for (int i = count; i > 0; i--)
- {
- str[i] = str[i - 1];
- }
- }
- str[0] = ' ';
- InvalidateRgn(hwnd, NULL, TRUE);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- }
- return DefWindowProc(hwnd, iMsg, wParam, lParam);
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
- {
- HWND hwnd;
- MSG msg;
- WNDCLASS c;
- c.style = CS_HREDRAW | CS_VREDRAW;
- c.lpfnWndProc = W;
- c.cbClsExtra = 0;
- c.cbWndExtra = 0;
- c.hInstance = hInstance;
- c.hIcon = LoadIcon(NULL, IDI_QUESTION);
- c.hCursor = LoadCursor(NULL, IDC_IBEAM);
- c.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
- c.lpszMenuName = NULL;
- c.lpszClassName = _T("Window Class Name");
- RegisterClass(&c);
- hwnd = CreateWindow(_T("Window Class Name"),
- _T("박현빈의 첫 번째 윈도우"),
- WS_OVERLAPPEDWINDOW,
- 200,
- 300,
- 600,
- 400,
- NULL,
- NULL,
- hInstance,
- NULL
- );
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return (int)msg.wParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement