Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <windowsx.h>
- #include "Data.h"
- #include "Scene2D.h"
- LRESULT _stdcall WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
- int _stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- WNDCLASS wc;
- wc.style = CS_OWNDC;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
- wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(6);
- wc.lpszMenuName = 0;
- wc.lpszClassName = (LPCSTR)"MainWindowClass";
- RegisterClass(&wc);
- HWND hWnd = CreateWindow(
- (LPCSTR)"MainWindowClass",
- (LPCSTR)"VTORAYA BLYAT'",
- WS_OVERLAPPEDWINDOW,
- 200,200,800,800,
- nullptr,nullptr,hInstance,nullptr);
- ShowWindow(hWnd,nCmdShow);
- UpdateWindow(hWnd);
- MSG msg;
- while(GetMessage(&msg,nullptr,0,0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
- Scene2D scene(-3, 3, -2, 2);
- LRESULT _stdcall WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch(msg)
- {
- case WM_PAINT:
- {
- HDC dc = GetDC(hWnd);
- scene.Clear(hWnd, dc);
- scene.PlotAxe(dc);
- scene.First___MethodFuncPlot(dc);
- scene.Second___MethodFuncPlot(dc);
- scene.Third___MethodFuncPlot(dc);
- ReleaseDC(hWnd, dc);
- return DefWindowProc(hWnd,msg,wParam,lParam);
- }
- case WM_SIZE:
- {
- HDC dc = GetDC(hWnd);
- scene.SetResolution(hWnd, dc);
- ReleaseDC(hWnd,dc);
- InvalidateRect(hWnd,nullptr,false);
- return 0;
- }
- case WM_LBUTTONDOWN:
- {
- scene.startDragging(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
- return 0;
- }
- case WM_MOUSEMOVE:
- {
- if (scene.IsDragging())
- {
- scene.dragging(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
- InvalidateRect(hWnd, nullptr, false);
- }
- return 0;
- }
- case WM_LBUTTONUP:
- {
- scene.StopDragging();
- return 0;
- }
- case WM_MOUSEWHEEL:
- {
- POINT P;
- P.x = GET_X_LPARAM(lParam);
- P.y = GET_Y_LPARAM(lParam);
- ScreenToClient(hWnd, &P);
- bool delta = (GET_WHEEL_DELTA_WPARAM(wParam) >= 0) ? true : false;
- scene.Zooming(delta, P.x, P.y);
- InvalidateRect(hWnd, nullptr, false);
- return 0;
- }
- case WM_DESTROY:
- {
- PostQuitMessage(0);
- return 0;
- }
- default:
- {
- return DefWindowProc(hWnd, msg, wParam, lParam);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement