在窗口大小变化时,让位图区域外重绘。 不属于怪问题。 谢谢!

来源:百度知道 编辑:UC知道 时间:2024/06/07 17:09:16
代码:http://www.yanglihao.com/filesUploaded/displayViaGDIView.cpp
工程压缩包:http://www.yanglihao.com/filesUploaded/displayViaGDI.rar

void CdisplayViaGDIView::OnDrawBegin()
{
// TODO: Add your command handler code here

if ( MemDC == NULL )
{
createDC(m_pDC);

}

CBrush brush(RGB(0,255,0));
MemDC.SelectObject(&brush);

MemDC.Rectangle(0,0,100,100);

Invalidate();

}

void CdisplayViaGDIView::drawTest(char* Text, int i, DWORD colorref)
{
if ( MemDC == NULL )
{
createDC(m_pDC);
}

int len = strlen(Text);

CFont font;

//CClientDC dc(this);
//MemDC.CreateCompatibleDC(&dc);
C

处理WM_SIZE 事件,然后用InvalidateRect函数
函数原型:
BOOL InvalidateRect(
HWND hWnd, // handle of window with changed update region
CONST RECT *lpRect,
// address of rectangle coordinates
BOOL bErase // erase-background flag
);

具体用法,可以查MSDN.

将布画大小重新设置为窗口大小。