读书人

请教一个:InvalidateRect的有关问题

发布时间: 2012-05-29 12:16:00 作者: rapoo

请问一个::InvalidateRect的问题?
对话框中一个IDC_PICTURE控件,两个button控件(button1 button2)

C/C++ code
void CReaderDlg::Button1(){    HWND hpic=::GetDlgItem(m_hWnd,IDC_PICTURE);    CWnd * pWnd = GetDlgItem(IDC_PICTURE);    SetDIBitsToDevice(hdc,                m_nPanx, m_nPany, m_pImage->w, m_pImage->h,                0, 0, 0, m_pImage->h, color,                dibinf, DIB_RGB_COLORS);    ::ReleaseDC(m_hWnd, hdc);}void CReaderDlg::Button2(){    HWND hpic=::GetDlgItem(m_hWnd,IDC_PICTURE);    CWnd * pWnd = GetDlgItem(IDC_PICTURE);    ::InvalidateRect(hpic, NULL, TRUE);    ::ReleaseDC(m_hWnd, hdc); }

我点击按钮Button1,在控件上显示内容.
然后再点击按钮button2,但是IDC_PICTURE上的内容还存在!
请问,InvalidateRect不是让IDC_PICTURE无效了吗?不是应该IDC_PICTURE内容消失吗?

[解决办法]
InvalidateRect是让区域无效
不过这样只会激发它重绘
如果绘制的内容还是一样的当然就还是那样
计算世界里没有清除内容这一说
绘图软件里橡皮擦的功能其实就是用背景色来覆盖
和画笔功能没有本质区别
[解决办法]
SetDIBitsToDevice后picture控件有了image,他自己会重绘,你要把他的image去掉才行(或给给个空image)
[解决办法]
CStatic::SetBitmap
HBITMAP SetBitmap( HBITMAP hBitmap );

Return Value

The handle of the bitmap previously associated with the static control, or NULL if no bitmap was associated with the static control.

读书人网 >VC/MFC

热点推荐