粗略看了下GDI+sdk,就像马上跃跃欲试的冲动,于是,在一个对话框里面,我响应OnEraseBkgnd(CDC* pDC)消息,添加如下代码
CClientDC clientDC (this);
//创建Graphics对象
Graphics graphics(clientDC);
//创建pen
Pen myPen(Color(0,255,0, 0));
myPen.SetWidth(10);
//画X轴
myPen.SetColor(Color::Blue);
CRect rect;
GetClientRect(&rect);
graphics.DrawLine(&myPen, 0, 0, rect.right, rect.bottom);
但是,运行程序后,什么情况都没发生,对话框一样是光光的。
GDI+是怎么在画图的?希望给个例子参考下.
CClientDC clientDC (this);
//创建Graphics对象
Graphics graphics(clientDC);
//创建pen
Pen myPen(Color(0,255,0, 0));
myPen.SetWidth(10);
//画X轴
myPen.SetColor(Color::Blue);
CRect rect;
GetClientRect(&rect);
graphics.DrawLine(&myPen, 0, 0, rect.right, rect.bottom);
但是,运行程序后,什么情况都没发生,对话框一样是光光的。
GDI+是怎么在画图的?希望给个例子参考下.
其次,你忘记初始化gdi+了。
GDI+必须在当前窗口初始化才有效啊?