Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LRESULT CALLBACK DrawProcedure(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
- {
- int i;
- PAINTSTRUCT ps;
- HDC hdc;
- RECT rect;
- GetClientRect (hWnd, &rect); // client window size
- switch (msg)
- {
- case WM_PAINT:
- {
- hdc = BeginPaint(hWnd, &ps);
- const int xWS = rect.right; // horizontal working window size
- const int yWS = rect.bottom; // vertical working window size
- const int OmegaGridStep = 2; // Omega_step
- const int OmegaMin = -30; // Omega_min
- const int OmegaMax = 30; // Omega_max
- int tMin = 0;
- int tMax_1 = 60;
- SetViewportOrgEx(hdc, 0, yWS / 2, NULL); // origin point
- double nPixPerOmega = yWS / 60;
- double nPixPerT = xWS / 60;
- int yMin = OmegaMin * nPixPerOmega;
- int yMax = OmegaMax * nPixPerOmega;
- const double tGridStep_1_min = 1;
- int xMin = tMin * nPixPerT;
- int xMax_1 = tMax_1 * nPixPerT;
- // OX
- HPEN hPen1=CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
- SelectObject(hdc, hPen1);
- MoveToEx(hdc, 20, 0, NULL);
- LineTo(hdc, xMax_1 + 20, 0);
- TextOutA(hdc, xWS - xWS / 20, yWS / 50, "T,min", 6);
- // OY
- MoveToEx(hdc, 20, yMin, NULL);
- LineTo(hdc, 20, yMax);
- TextOutA(hdc, 15, -yWS / 2, "Omega,deg/sec", 14);
- // grid
- HPEN hPen0=CreatePen(PS_SOLID, 1, RGB(0, 160, 0));
- HPEN hOldPen=(HPEN)SelectObject(hdc, hPen0);
- int vertical_grid_0 = OmegaMin;
- int horizontal_grid_0 = tMin;
- int x, y;
- UINT uAlignPrev;
- for (int i=0; i<(sizeof(yMark)/sizeof(yMark[0])); ++i) // vertical
- {
- y = vertical_grid_0 * nPixPerOmega;
- MoveToEx(hdc, xMin + 20, y, NULL);
- LineTo(hdc, xMax_1 + 20, y);
- vertical_grid_0 += OmegaGridStep;
- static LOGFONT lf;
- lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
- lf.lfItalic = TRUE;
- lf.lfHeight = 12;
- SetTextColor(hdc, RGB(0, 0, 200));
- uAlignPrev = SetTextAlign(hdc, TA_CENTER);
- HFONT hFont0=CreateFontIndirect(&lf);
- HFONT hOldFont=(HFONT) SelectObject(hdc, hFont0);
- TextOutA(hdc, xMin+10, y - 7, yMark[i], strlen(yMark[i]));
- }
- for (int j=1; j<(sizeof(xMark_1)/sizeof(xMark_1[0])); ++j) // horizontal
- {
- x = horizontal_grid_0 * nPixPerT;
- MoveToEx(hdc, x + 20, yMin, NULL);
- LineTo(hdc, x + 20, yMax);
- horizontal_grid_0 += tGridStep_1_min;
- TextOutA(hdc, x+40, 3, xMark_1[j], strlen(xMark_1[j]));
- }
- EndPaint(hWnd, &ps);
- }
- case WM_LBUTTONDOWN:
- {
- HDC hdc;
- WORD nSize, xPos, yPos;
- TCHAR szBuf[80];
- DWORD dw;
- HANDLE File;
- RECT rc;
- GetClientRect (hWnd, &rc); // client window size
- con
Advertisement
Add Comment
Please, Sign In to add comment