If you do a dynamic graph

xiaoxiao2021-03-05  60

There may be many ways to do such a dynamic graph to express the dynamic situation of flow. I made a class of such a CSTATIC control here. Can dynamically show the trend of traffic

Mainly overpAint functions of the CSTATIC class.

Use one

Typedef Vector cpointarr;

To save the current needs to be connected.

Write such content in the onpaint function.

Void cmyStatic :: onpaint () {cPAINTDC DC (this); DRAWBK (DC); if (m_pointarr.size ()> = 2) {for (INT i = 0; i

The function of the painting background is:

Void CMYSTATIC :: DrawBk (CDC & DC) {CRECT Rect; getClientRect (& Rect); DC.FillSolidRect (& Rect, m_colorbk);

This-> getWindowRect (& Rect); ScreenToClient (& Re); csize tgsize; tgsize.cx = Rect.right - Rect. left; tgsize.cy = Rect.bottom - Rect.top;

// Horizontal Int NH = Tgsize.CY / 20; For (int i = 1; i <= NH; i ) {cpoint p1 (Rect.Lep, Rect.top 20 * i); CPOINT P2 (Rect.right , Rect.top 20 * i); Drawline (DC, P1, P2, M_Colorfram);}

// Value INT NZ = Tgsize.cx / 20; for (i = 1; i <= nz; i ) {cpoint P1 (Rect.Left 20 * i, Rect.top); CPOINT P2 (Rect.Left) 20 * I, Rect.bottom; Drawline (DC, P1, P2, M_ColorFram);}}

Void cmystatic :: Drawline (CPOINT _P2, CPOINT _P1, CPOINT _P2, ColorRef _Color) {CPEN Newpen (PS_SOLID, 1, _COLOR); CPEN * OLDPEN = DC.SelectObject (& newpen); dc.moveto (_p1); dc.lineto (_P2); dc.selectObject (oldpen);

Void cmyStatic :: addpoint (int ncount) {ncount = 100-ncount;

Trace ("The content of the Y-axis added:% d / n", ncount); CRECT RECT; GetClientRect (& Re);

// Mobile for previous For (int i = 0; I

/ ()]; Temp.x = Rect.Left; m_pointarr [m_pointarr.size ()] = TEMP;} / * Convert to 100% * / cpoint point (Rect.right, Rect .Height () * ncount / 100); m_pointarr.push_back (point); invalidate ();

转载请注明原文地址:https://www.9cbs.com/read-31856.html

New Post(0)