我直接在OnPaint里面写显示语句的话,一切正常:CRect rc;
GetRects(rc); //自己写的一个函数,获取Picture Box的位置CWnd *pWnd = GetDlgItem(IDC_IMG);
CPaintDC dc(pWnd);
Gdiplus::Graphics g(dc);Gdiplus::Bitmap img("image.png");
g.DrawImage(&img,0,0,rc.Width(), rc.Height());但是我如果把img当作程序的一个成员变量,比如在打开文件的地方执行实例化一个Bitmap对象:
Gdiplus::Bitmap *m_img;
m_img->FromFile("image.png");
在OnPaint里面执行:
g.DrawImage(m_img,0,0,rc.Width(), rc.Height());
程序还是能够运行,但是不能显示图像。
我加上刷新语句也不行
这是为什么呢?