Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #pragma comment (lib, "User32.lib")
  2. #pragma comment (lib, "gdi32.lib")
  3.  
  4. #include<Windows.h>
  5. #include<TCHAR.H>
  6.  
  7. LRESULT CALLBACK W(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
  8. {
  9. HDC hdc;
  10. PAINTSTRUCT ps;
  11. static TCHAR str[100];
  12. static int count, yPos;
  13. RECT rt = { 0,0 , 1000, 1000 };
  14.  
  15. switch (iMsg)
  16. {
  17. case WM_CREATE:
  18. count = 0;
  19. yPos;
  20. break;
  21. case WM_PAINT:
  22. hdc = BeginPaint(hwnd, &ps);
  23. DrawText(hdc, str, _tcslen(str), &rt, DT_TOP | DT_LEFT);
  24. EndPaint(hwnd, &ps);
  25. break;
  26. case WM_CHAR:
  27. if (wParam == VK_BACK && count >= 0)
  28. {
  29. if (count != 0) count--;
  30. if (str[count] == VK_RETURN) count--;
  31. }
  32. else
  33. {
  34. str[0] = wParam;
  35. count++;
  36. for (int i = count; i > 0; i--)
  37. {
  38. str[i] = str[i - 1];
  39. }
  40. }
  41. str[0] = ' ';
  42. InvalidateRgn(hwnd, NULL, TRUE);
  43. break;
  44. case WM_DESTROY:
  45. PostQuitMessage(0);
  46. break;
  47. }
  48. return DefWindowProc(hwnd, iMsg, wParam, lParam);
  49. }
  50.  
  51. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
  52. {
  53. HWND hwnd;
  54. MSG msg;
  55. WNDCLASS c;
  56. c.style = CS_HREDRAW | CS_VREDRAW;
  57. c.lpfnWndProc = W;
  58. c.cbClsExtra = 0;
  59. c.cbWndExtra = 0;
  60. c.hInstance = hInstance;
  61. c.hIcon = LoadIcon(NULL, IDI_QUESTION);
  62. c.hCursor = LoadCursor(NULL, IDC_IBEAM);
  63. c.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
  64. c.lpszMenuName = NULL;
  65. c.lpszClassName = _T("Window Class Name");
  66. RegisterClass(&c);
  67. hwnd = CreateWindow(_T("Window Class Name"),
  68. _T("박현빈의 첫 번째 윈도우"),
  69. WS_OVERLAPPEDWINDOW,
  70. 200,
  71. 300,
  72. 600,
  73. 400,
  74. NULL,
  75. NULL,
  76. hInstance,
  77. NULL
  78. );
  79. ShowWindow(hwnd, nCmdShow);
  80. UpdateWindow(hwnd);
  81. while (GetMessage(&msg, NULL, 0, 0))
  82. {
  83. TranslateMessage(&msg);
  84. DispatchMessage(&msg);
  85. }
  86. return (int)msg.wParam;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement