如何正确处理WM_ERASEBKGND来解决这个问题? [英] How to properly handle WM_ERASEBKGND to fix this problem ?

查看:76
本文介绍了如何正确处理WM_ERASEBKGND来解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我想首先感谢所有花时间查看此主题并尝试提供帮助的人。



我使用GradientFill(...)API为主窗口制作了渐变背景。



Windows上一切正常7,但在Windows XP上出现以下问题:



当我将窗口一直向左拖动时,其中一半从屏幕上消失,然后将它返回到屏幕,因此它可以完全可见,我的主窗口的背景变成白色(白色是我在窗口类创建中指定的画笔)在窗口的部分不可见。



在我做最小化和最大化之后,所有内容都被正确绘制。



如果我移动其他窗口使窗口部分无效一切都很好。



我试过添加InvalidateRect(hWndMainWindow,NULL,TRUE);在WM_ERASEBKGND中它解决了它,但是以闪烁为代价。



我怀疑它与更新区域或设备上下文有关,但我不知道知道如何解决这个问题。



这就是全部,再次感谢所有想要帮助的人。



我在MS Visual Studio Express 2008,Windows XP,C ++中使用纯WIN32 API。



如果需要任何其他信息(源代码或类似的东西),请求它,我将非常乐意提供它。

Hello everyone!

I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.

I have made gradient background for main window, using GradientFill( ... ) API.

Everything works fine on Windows 7, but on Windows XP the following problem occurs:

When I drag my window all the way to the left, so half of it disappears from the screen, and then return it back to the screen, so it can be fully visible, my main window's background turns into white ( white is the brush I have assigned in window class creation ) on the portion of the window that was not visible.

After I do minimize and maximize, everything is painted properly.

If I move other window to invalidate portion of my window, everything paints well.

I have tried adding InvalidateRect( hWndMainWindow, NULL, TRUE ); in WM_ERASEBKGND and it solved it, but at the expense of flickering.

I suspect that it has something to do with the updating region or device context, but I don't know what to do to fix it.

That would be all, thanks again to everyone who will try to help.

I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.

If any other information is required ( source code or something similar ), please ask for it, I will more than gladly supply it.

推荐答案

在头文件(* .h)中

In a header file (*.h)
// Attributes
public:
       CBitmap bmpPlayer;
       CDC*  m_pdcPlayerMem;





然后在实现文件中(* .c,* .cpp)



Then in the implementation file (*.c, *.cpp)

void CView::OnDraw(CDC* pDC)
{
         bmpPlayer.LoadBitmap(IDBMP_PLAYER1);
         m_pdcPlayerMem->CreateCompatibleDC(NULL);
         m_pdcPlayerMem->SelectObject(&bmpPlayer);
         pDC->BitBlt(600, 300, 150, 200, m_pdcPlayerMem,
         0, 0, SRCCOPY);
}





或类似的东西......



Or something like that ...


这篇关于如何正确处理WM_ERASEBKGND来解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆