Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <tchar.h>
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
- TCHAR WinName[] = _T("MainFrame");
- int APIENTRY WinMain(HINSTANCE This, HINSTANCE Prev, LPSTR cmd, int mode)
- {
- HWND hWnd;
- MSG msg;
- WNDCLASS wc;
- wc.hInstance = This;
- wc.lpszClassName = WinName;
- wc.lpfnWndProc = WndProc;
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.lpszMenuName = NULL;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- if(!RegisterClass(&wc))
- return 0;
- hWnd = CreateWindow(WinName, _T("Karkas Windows-application"), WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- HWND_DESKTOP, NULL, This, NULL);
- ShowWindow(hWnd, mode);
- while(GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
- void paintCell(HWND* hWnd, int sx, int sy)
- {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(*hWnd, &ps);
- for(int x = 0; x < sx; x += sx/10 )
- {
- MoveToEx(hdc, x, 0, NULL);
- LineTo(hdc, x, sy);
- }
- for(int y = 0; y < sy; y += sy/10 )
- {
- MoveToEx(hdc, 0, y, NULL);
- LineTo(hdc, sx, y);
- }
- EndPaint(*hWnd, &ps);
- }
- void paintTriangle(HWND* hWnd, int sx, int sy)
- {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(*hWnd, &ps);
- int width = sx;
- int height = sy;
- int stX = (width - height) / 2;
- int stY = height;
- int lbX = stX;
- int lbY = stY-50;
- int tX = stX+(height/2);
- int tY = stY-450;
- int rbX = stX+height;
- int rbY = stY-50;
- BeginPath(hdc);
- HBRUSH blue = CreateSolidBrush(RGB(0,0,255));
- HBRUSH black = CreateSolidBrush(RGB(0,0,0));
- SelectObject(hdc, blue);
- FillPath(hdc);
- EndPath(hdc);
- for( int i = 0; i < width/2; i += 10 )
- {
- MoveToEx(hdc, lbX+i, lbY, NULL);
- LineTo(hdc, tX, tY);
- MoveToEx(hdc, tX, tY, NULL);
- LineTo(hdc, rbX-i, rbY);
- MoveToEx(hdc, rbX-i, rbY, NULL);
- LineTo(hdc, lbX+i, lbY);
- }
- Ellipse(hdc, lbX+150, lbY-250, rbX-150, rbY-100);
- SelectObject(hdc, black);
- FillPath(hdc);
- Ellipse(hdc, lbX+300, lbY-235, rbX-300, rbY-125);
- EndPaint(*hWnd, &ps);
- }
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- int x = 0;
- int y = 0;
- static int sx = 0;
- static int sy = 0;
- if(message == WM_DESTROY)
- {
- PostQuitMessage(0);
- }
- else if(message == WM_SIZE)
- {
- sx = LOWORD(lParam);
- sy = HIWORD(lParam);
- }
- else if(message == WM_PAINT)
- {
- paintTriangle(&hWnd, sx, sy);
- }
- else
- {
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement