Advertisement
alexx876

Untitled

Jan 14th, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 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. for (int x = -5; x <= 5; x++) {
  71. int cX = 350 + x*30;
  72. if (x>-5)LineTo(hdc, cX, cX ^ 2);
  73.  
  74. SetPixel(hdc, cX, cX ^ 2, RGB(255,0,0));
  75. MoveToEx(hdc, cX, cX ^ 2, 0);
  76.  
  77. }
  78.  
  79. break;
  80. }
  81. case WM_CLOSE: {
  82. DestroyWindow(hDlg);
  83. break;
  84. }
  85. case WM_DESTROY: {
  86. PostQuitMessage(0);
  87. break;
  88. }
  89. default: {
  90. return DefWindowProc(hDlg, Msg, wParam, lParam); //обработка сообщений по умолчанию
  91. }
  92. }
  93. return 1;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement