alexx876

Untitled

Jan 14th, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <time.h>
  4. #include <Windowsx.h>
  5. HWND Edit;
  6. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  7. POINT start;
  8.  
  9. int max = 500, current = 10;
  10. int randx, randy, randz;
  11.  
  12. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  13. srand(time(0));
  14.  
  15. HWND Main;
  16. MSG msg;
  17.  
  18. WNDCLASSEX wc;
  19.  
  20. char szClassName[] = "AppClass";
  21.  
  22. wc.style = 0;
  23. wc.cbClsExtra = 0;
  24. wc.cbWndExtra = 0;
  25. wc.hIcon = 0;
  26. wc.hCursor = 0;
  27. wc.hbrBackground = 0;
  28. wc.lpszMenuName = NULL;
  29. wc.hIconSm = 0;
  30.  
  31. wc.cbSize = sizeof(wc);
  32. wc.lpszClassName = szClassName;
  33. wc.hInstance = hInstance;
  34. wc.lpfnWndProc = WndProc;
  35.  
  36. if (!RegisterClassEx(&wc)) {
  37. MessageBox(NULL, "Не удалось зарегистрировать класс окна", "Ошибка", MB_OK);
  38. return 0;
  39. }
  40.  
  41. Main = CreateWindow(szClassName, "dsg", DS_CENTER | WS_MAXIMIZEBOX | WS_SYSMENU, CW_USEDEFAULT, 0, 700, 700, 0, 0, hInstance, 0);
  42.  
  43. ShowWindow(Main, nCmdShow);
  44.  
  45. while (GetMessage(&msg, NULL, 0, 0)) {
  46. TranslateMessage(&msg);
  47. DispatchMessage(&msg);
  48. }
  49.  
  50. return 1;
  51. }
  52.  
  53.  
  54. LRESULT CALLBACK WndProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) {
  55. HDC hdc;
  56.  
  57. switch (Msg) {
  58. case WM_CREATE: {
  59. break;
  60. }
  61. case WM_PAINT: {
  62. hdc = GetDC(hDlg);
  63.  
  64. MoveToEx(hdc, 0, 350, 0);
  65. LineTo(hdc, 700, 350);
  66.  
  67. MoveToEx(hdc, 350, 0, 0);
  68. LineTo(hdc, 350, 700);
  69.  
  70. double fDot = -1;
  71.  
  72. for (int x = -5; x <= 5; x += 1) {
  73. double fY = cos(x);
  74. fY = 350 - fY * 30;
  75. if (fDot == -1)
  76. {
  77. fDot = fY;
  78. continue;
  79. }
  80. int cX = x * 30 + 350;
  81.  
  82. MoveToEx(hdc, cX - 30, fDot, 0);
  83. LineTo(hdc, cX, fY);
  84.  
  85. fDot = fY;
  86. }
  87.  
  88. break;
  89. }
  90. case WM_CLOSE: {
  91. DestroyWindow(hDlg);
  92. break;
  93. }
  94. case WM_DESTROY: {
  95. PostQuitMessage(0);
  96. break;
  97. }
  98. default: {
  99. return DefWindowProc(hDlg, Msg, wParam, lParam); //обработка сообщений по умолчанию
  100. }
  101. }
  102. return 1;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment