gpt4 book ai didi

c++ - "BeginPaint"函数如何知道更新区域-windows编程?

转载 作者:可可西里 更新时间:2023-11-01 10:55:51 28 4
gpt4 key购买 nike

我是 Windows 编程的新手,我有一个关于绘制窗口的问题,特别是关于 BeginPaint 函数的问题

当我在 MSDN 上阅读它时上面写着

Start the painting operation by calling the BeginPaint function. This function fills in the PAINTSTRUCT structure with information on the repaint request. The current update region is given in the rcPaint member of PAINTSTRUCT.

我的问题是,当我在 wndproc 中处理 WM_PAINT 消息并开始调用 BeginPaint 函数时,我没有提供此函数关于我收到的特定消息或需要绘制的更新区域的任何数据,那么这个函数如何填充 PAINTSTRUCT 包括无效的 rect“rcPaint成员(member)”?!

    case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
// All painting occurs here, between BeginPaint and EndPaint.
EndPaint(hwnd, &ps);
}

当我在 MSDN 上引用 BeginPaint 函数时, 它说

An application should not call BeginPaint except in response to a WM_PAINT message

我的猜测可能是此函数从 Windows 内部获取此信息通过请求此信息和发送到窗口的最后一个 WM_PAINT 消息,我将它的句柄“`hwnd'”作为函数的第一个参数。对吗?

提前致谢。

最佳答案

我怀疑这在任何地方都有记录,因为它是一个与程序员无关的实现细节,但我很确定更新区域是与 HWND 一起存储的内部数据结构。您可以看出,因为有几个函数仅基于 HWND 对更新区域进行操作:[In]ValidateRect、[In]ValidateRgn、GetUpdateRgn、BeginPaint 等。

关于c++ - "BeginPaint"函数如何知道更新区域-windows编程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31529606/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com