代码图像的图形方面. [英] Graphic aspects of a code image.
本文介绍了代码图像的图形方面.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一个类似的滑动控制示例,每个滑动块的结果,出现下面的图表,从图1开始,滑动到图2的左侧后.
图I
图2
下图是主要代码块:
I wrote a similar example of sliding control, the results of each slide the slider, there appeared the following chart, from Figure 1, after sliding to the left block in Figure 2.
Figure I
Figure 2
Chart below is the main code block:
void SliderBoth::SetBlockColor()
CClientDC dc(this);
CRect rc;
GetClientRect(&rc);
int iNumTic=(pos.iMax-pos.iMin)/pos.iTick;
const int iL=MARGIN_SLIDE;
const int iR=rc.right-MARGIN_SLIDE;
const double dbStep=(iR-iL)*1.0/iNumTic;
double db=iL;
CBrush brush;
brush.CreateSolidBrush(RGB(165,196,211));
CBrush * pOldBrush= dc.SelectObject (&brush);
dc.Rectangle((int)lval+MARGIN_SLIDE*2,rc.top+1,(int)rval,rc.bottom-MARGIN_SLIDE*2);
dc.SelectObject (pOldBrush);
brush.DeleteObject();
#endif
}
如何解决此问题,获得我有问题的DC?
请帮忙,谢谢!
How can we solve this problem, obtain the DC I have problems?
Please help, thank you!
推荐答案
在SetBlockColor()函数中,您应该只更改颜色,而不是将WM_PAINT消息发布到控件.
在覆盖的OnPaint()中,您应该进行绘制.
in the SetBlockColor() function you should only change the color and than post a WM_PAINT message to the control.
In the overriden OnPaint() you should do the drawing.
这篇关于代码图像的图形方面.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文