Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <tchar.h>
  3.  
  4.  
  5. LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
  6. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) // C언어로 치면 선언문
  7.  
  8. {
  9. HWND hwnd;
  10. MSG msg;
  11. WNDCLASS WndClass;
  12. WndClass.style = CS_HREDRAW | CS_VREDRAW;
  13. WndClass.lpfnWndProc = WndProc;
  14. WndClass.cbClsExtra = 0;
  15. WndClass.cbWndExtra = 0;
  16. WndClass.hInstance = hInstance;
  17. WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  18. WndClass.hCursor = LoadCursor(NULL, IDC_IBEAM);
  19. WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  20. WndClass.lpszMenuName = NULL;
  21. WndClass.lpszClassName = _T("window Class Name");
  22.  
  23. RegisterClass(&WndClass);
  24.  
  25. hwnd = CreateWindow(_T("window Class name"),
  26. _T("박우현의 첫 번쨰 윈도우"),
  27. WS_OVERLAPPEDWINDOW,
  28. CW_USEDEFAULT,
  29. CW_USEDEFAULT,
  30. CW_USEDEFAULT,
  31. CW_USEDEFAULT,
  32. NULL,
  33. NULL,
  34. hInstance,
  35. NULL
  36. );
  37.  
  38. ShowWindow(hwnd, nCmdShow);
  39. UpdateWindow(hwnd);
  40. while (GetMessage(&msg, NULL, 0, 0))
  41. {
  42. TranslateMessage(&msg);
  43. DispatchMessage(&msg);
  44.  
  45. }
  46.  
  47. return (int)msg.wParam;
  48.  
  49. }
  50.  
  51. LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
  52. {
  53. HDC hdc;
  54. PAINTSTRUCT ps;
  55. static TCHAR str[20][100];
  56. static int count, count2, yPos;
  57.  
  58. switch (iMsg)
  59. {
  60. case WM_CREATE:
  61. count = 0;
  62. count2 = 0;
  63. yPos = 380;
  64. break;
  65.  
  66. case WM_PAINT:
  67. hdc = BeginPaint(hwnd, &ps);
  68. for (int i = 0; i <= count2; i++)
  69. {
  70. TextOut(hdc, 0, yPos, str[i], _tcslen(str[i]));
  71. }
  72. EndPaint(hwnd, &ps);
  73. break;
  74.  
  75. case WM_CHAR:
  76. if (wParam == VK_BACK && count > 0)
  77. {
  78. count--;
  79. if (count <= 0 && count2 > 0)// 2줄이상이고 글자가 없을때 개행할 수 있는 조건문
  80. {
  81. count = _tcslen(str[count2]);
  82. count2--;
  83. }
  84. }
  85.  
  86. else if (wParam == VK_RETURN)
  87. {
  88. yPos = yPos - 20;
  89. count2++;
  90. count = 0;
  91. }
  92.  
  93. else
  94. {
  95. str[count2][count++] = wParam;
  96. }
  97. str[count2][count] = NULL;
  98. InvalidateRgn(hwnd, NULL, TRUE);
  99. break;
  100.  
  101.  
  102. case WM_DESTROY:
  103. PostQuitMessage(0);
  104. break;
  105.  
  106. }
  107.  
  108. return (DefWindowProc(hwnd, iMsg, wParam, lParam));
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement