Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- #include <time.h>
- #include <Windowsx.h>
- HWND Edit;
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- POINT start;
- int max = 500, current = 10;
- int randx, randy, randz;
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
- srand(time(0));
- HWND Main;
- MSG msg;
- WNDCLASSEX wc;
- char szClassName[] = "AppClass";
- wc.style = 0;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hIcon = 0;
- wc.hCursor = 0;
- wc.hbrBackground = 0;
- wc.lpszMenuName = NULL;
- wc.hIconSm = 0;
- wc.cbSize = sizeof(wc);
- wc.lpszClassName = szClassName;
- wc.hInstance = hInstance;
- wc.lpfnWndProc = WndProc;
- if (!RegisterClassEx(&wc)) {
- MessageBox(NULL, "Не удалось зарегистрировать класс окна", "Ошибка", MB_OK);
- return 0;
- }
- Main = CreateWindow(szClassName, "dsg", DS_CENTER | WS_MAXIMIZEBOX | WS_SYSMENU, CW_USEDEFAULT, 0, 700, 700, 0,0, hInstance,0);
- ShowWindow(Main, nCmdShow);
- while (GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 1;
- }
- LRESULT CALLBACK WndProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) {
- HDC hdc;
- switch (Msg) {
- case WM_CREATE: {
- break;
- }
- case WM_PAINT: {
- hdc = GetDC(hDlg);
- MoveToEx(hdc, 0, 350,0);
- LineTo(hdc, 700, 350);
- MoveToEx(hdc, 350, 0, 0);
- LineTo(hdc, 350, 700);
- for (int x = -5; x <= 5; x++) {
- int cX = 350 + x*30;
- if (x>-5)LineTo(hdc, cX, cX ^ 2);
- SetPixel(hdc, cX, cX ^ 2, RGB(255,0,0));
- MoveToEx(hdc, cX, cX ^ 2, 0);
- }
- break;
- }
- case WM_CLOSE: {
- DestroyWindow(hDlg);
- break;
- }
- case WM_DESTROY: {
- PostQuitMessage(0);
- break;
- }
- default: {
- return DefWindowProc(hDlg, Msg, wParam, lParam); //обработка сообщений по умолчанию
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement