问题,如标题。
代码如下:LRESULT CXDialogInc::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if (message==WM_MOVE||message==WM_PAINT||message==WM_NCACTIVATE ||message == WM_NOTIFY|| message==WM_NCPAINT)
{
PAINTSTRUCT ps;
CDC * pDC = NULL;
pDC = BeginPaint( &ps);
pDC = GetWindowDC( );
CRect rectWin;
GetWindowRect( rectWin);
rectWin.SetRect( 0, 0, rectWin.Width(), rectWin.Height());
if ( m_pXDialog > 0)
{
((CXUIBase*)m_pXDialog)->Draw( pDC, rectWin);
}
ReleaseDC( pDC);
EndPaint( &ps);
return 0;
}
if ( message == WM_ERASEBKGND)
{
return 0;
}
return CDialog::WindowProc(message, wParam, lParam);
}
从msdn上看到 The BeginPaint function automatically sets the clipping region of the device context to exclude any area outside the update region.
但 BeginPaint( &ps);只得到 客户区DC, 画在了客户区。而我需要整个窗口的DC。
代码如下:LRESULT CXDialogInc::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if (message==WM_MOVE||message==WM_PAINT||message==WM_NCACTIVATE ||message == WM_NOTIFY|| message==WM_NCPAINT)
{
PAINTSTRUCT ps;
CDC * pDC = NULL;
pDC = BeginPaint( &ps);
pDC = GetWindowDC( );
CRect rectWin;
GetWindowRect( rectWin);
rectWin.SetRect( 0, 0, rectWin.Width(), rectWin.Height());
if ( m_pXDialog > 0)
{
((CXUIBase*)m_pXDialog)->Draw( pDC, rectWin);
}
ReleaseDC( pDC);
EndPaint( &ps);
return 0;
}
if ( message == WM_ERASEBKGND)
{
return 0;
}
return CDialog::WindowProc(message, wParam, lParam);
}
从msdn上看到 The BeginPaint function automatically sets the clipping region of the device context to exclude any area outside the update region.
但 BeginPaint( &ps);只得到 客户区DC, 画在了客户区。而我需要整个窗口的DC。
把擦除背景消息去掉: if ( message == WM_ERASEBKGND)
{
return 0;
} 改为 if ( message == WM_ERASEBKGND)
{
return 1;
}再试试看
而用BeginPaint时,不发生闪烁。
if ( message == WM_ERASEBKGND)
{
return 1;
}还是闪烁。
只是把((CXUIBase*)m_pXDialog)->Draw( pDC, rectWin) 代码去掉了,增加了给窗口加了个图片背景的逻辑,怎么放大,缩小都感觉不到闪.用双缓冲绘图吧,这个是个链接,
http://blog.myspace.cn/e/401978292.htm