Advertisement
chuuupa

Untitled

Dec 6th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #include <windows.h>
  2. #include <windowsx.h>
  3. #include "Data.h"
  4. #include "Scene2D.h"
  5.  
  6. LRESULT _stdcall WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  7. int _stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  8. {
  9. WNDCLASS wc;
  10. wc.style = CS_OWNDC;
  11. wc.lpfnWndProc = WndProc;
  12. wc.cbClsExtra = 0;
  13. wc.cbWndExtra = 0;
  14. wc.hInstance = hInstance;
  15. wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
  16. wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
  17. wc.hbrBackground = (HBRUSH)(6);
  18. wc.lpszMenuName = 0;
  19. wc.lpszClassName = (LPCSTR)"MainWindowClass";
  20. RegisterClass(&wc);
  21.  
  22. HWND hWnd = CreateWindow(
  23. (LPCSTR)"MainWindowClass",
  24. (LPCSTR)"VTORAYA BLYAT'",
  25. WS_OVERLAPPEDWINDOW,
  26. 200,200,800,800,
  27. nullptr,nullptr,hInstance,nullptr);
  28.  
  29. ShowWindow(hWnd,nCmdShow);
  30. UpdateWindow(hWnd);
  31.  
  32. MSG msg;
  33. while(GetMessage(&msg,nullptr,0,0))
  34. {
  35. TranslateMessage(&msg);
  36. DispatchMessage(&msg);
  37. }
  38.  
  39. return 0;
  40. }
  41.  
  42. Scene2D scene(-3, 3, -2, 2);
  43.  
  44. LRESULT _stdcall WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  45. {
  46. switch(msg)
  47. {
  48. case WM_PAINT:
  49. {
  50. HDC dc = GetDC(hWnd);
  51. scene.Clear(hWnd, dc);
  52. scene.PlotAxe(dc);
  53.  
  54. scene.First___MethodFuncPlot(dc);
  55.  
  56. scene.Second___MethodFuncPlot(dc);
  57.  
  58. scene.Third___MethodFuncPlot(dc);
  59.  
  60. ReleaseDC(hWnd, dc);
  61. return DefWindowProc(hWnd,msg,wParam,lParam);
  62. }
  63.  
  64. case WM_SIZE:
  65. {
  66. HDC dc = GetDC(hWnd);
  67. scene.SetResolution(hWnd, dc);
  68. ReleaseDC(hWnd,dc);
  69. InvalidateRect(hWnd,nullptr,false);
  70. return 0;
  71. }
  72. case WM_LBUTTONDOWN:
  73. {
  74. scene.startDragging(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
  75. return 0;
  76. }
  77. case WM_MOUSEMOVE:
  78. {
  79. if (scene.IsDragging())
  80. {
  81. scene.dragging(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
  82. InvalidateRect(hWnd, nullptr, false);
  83. }
  84. return 0;
  85. }
  86. case WM_LBUTTONUP:
  87. {
  88. scene.StopDragging();
  89. return 0;
  90. }
  91. case WM_MOUSEWHEEL:
  92. {
  93. POINT P;
  94. P.x = GET_X_LPARAM(lParam);
  95. P.y = GET_Y_LPARAM(lParam);
  96. ScreenToClient(hWnd, &P);
  97.  
  98. bool delta = (GET_WHEEL_DELTA_WPARAM(wParam) >= 0) ? true : false;
  99. scene.Zooming(delta, P.x, P.y);
  100. InvalidateRect(hWnd, nullptr, false);
  101. return 0;
  102.  
  103. }
  104. case WM_DESTROY:
  105. {
  106. PostQuitMessage(0);
  107. return 0;
  108. }
  109. default:
  110. {
  111. return DefWindowProc(hWnd, msg, wParam, lParam);
  112. }
  113. }
  114. return 0;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement