The following code shows how to paint into a CStatic Control and make sure this painting is flicker-free.
The example code for download:
FlickerFreeDemoStatic.zip (61,6 KiB)
Unfortunately one can not draw inside a CStatic control directly. Therefore one need to overload the CStatic class an do the following (let CGraphCtrl be the overloaded class)
The calls presented here saves its data in
vector<vector <COLORREF> > PlotData;
and includes methods for resizing
void Resize(const unsigned short width, const unsigned short height); void FullResize(const CRect newRect); void SetSize(const unsigned short width, const unsigned short height); void SetPlotDataSize(const int x, const int y); CRect GetSize(); CRect GetPlotDataSize();
and the actual painting
void SetPlotData(vector</vector><vector <COLORREF> > InputArray); void UpdatePlot(); void PaintPixel(CMemDC* pDC, const int x, const int y, COLORREF c); void PlotToDC(CMemDC* pDC);