擦除窗口背景 win32API

发布于 2024-10-20 17:22:44 字数 488 浏览 1 评论 0原文

我的同学开始使用 Delphi 和 pascal,但我作为 c++ 程序员必须使用 win32 API。他们正在改变背景颜色,所以我也需要知道这一点,但有一些差异。

在delphi中,每个窗体看起来都有它自己的实例,为一个窗口设置背景颜色只是更改一个值的问题。 win32 的情况并非如此,当您更改该值时,它会影响使用该类的每个窗口(更新 ofc 后)。

我需要做的是清除/删除我的窗口背景。我可以使用 FillRect(..) 做到这一点,并且工作得非常好,但我还发现 WM_ERASEBKGND 这似乎正是我所需要的。他们提到,如果这条消息得到处理,我应该返回一个非零值,但他们没有告诉如何处理它。

那么,FillRect(和类似的)还有什么可以让我用我定义的画笔而不是类的默认值来擦除窗口吗?

谢谢

My classmates started using Delphi with pascal but I as c++ porgrammer have to use win32 API. They were changing background color so I need to know this aswell but there are some differencies.

In delphi each form looks like it has it's own instance, and setting background color for one window is just a matter of changing one value. Not the case with win32 where when you change that value it affects every window using that class (after update ofc).

What I need to do is to clear/erase my window background. I can do that with FillRect(..) and it's working very nicely, but I've found also WM_ERASEBKGND which seems to be doing exactly what I need. They mentioned that if this message gets proccessed I should return a non-zero, but they didn't tell how to process it.

So could anything else then FillRect(and similliar) let me erase a window with a brush I defined and not with the default for class?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱&纷飞 2024-10-27 17:22:44

您只需擦除背景即可处理 WM_ERASEBKGND(使用 FillRect() 就可以了)。

通过返回非零值,您只是告诉 Windows 该消息已得到处理,无需采取进一步操作。没有什么比这更正式的了。

You process WM_ERASEBKGND simply by erasing the background (using FillRect() is fine).

By returning a non-zero value, you are simply telling Windows that this message has been taken care of and no further action is needed. There is nothing more formal than that.

誰認得朕 2024-10-27 17:22:44

如果您将 MFC 与 C++ 一起使用,您还可以查看该框架的 CWnd::OnEraseBkgnd 实现
http://msdn.microsoft.com/en-我们/library/a0a52fkz(v=vs.80).aspx

If you're using MFC with C++ you can also check out that framework's implementation of CWnd::OnEraseBkgnd
http://msdn.microsoft.com/en-us/library/a0a52fkz(v=vs.80).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文