将 WM_NCCALCSIZE 计算出的 RECT 存储在 class 成员 RECT 变量中并稍后在 WM_NCPAINT 中使用它是否安全?

is it safe to store the calculated RECT from a WM_NCCALCSIZE in a class member RECT variable and use it later in WM_NCPAINT?

我需要知道从 WM_NCCALCSIZE 消息并稍后在 WM_NCPAINT 中使用它,而无需在 WM_NCPAINT!?

中再次执行整个重新计算过程

WM_NCPAINT 总是在 WM_NCCALCSIZE 之后立即调用吗?

我需要省去在 WM_NCPAINT 消息中进行重新计算过程的麻烦,因为 DefWindowProc 来自 WM_NCCALCSIZE 已经完成了我需要开始计算的所有事情

TIA。

i.e. is WM_NCPAINT always called immediately after WM_NCCALCSIZE?

我测试了这个krsi提供的,可以发现WM_NCCALCSIZE总是在WM_NCPAINT之前被调用,但这并不意味着在WM_NCPAINT之前没有调用其他消息中间。比如测试的时候,收到WM_NCCALCSIZE后,会先调用WM_PAINT,然后再调用WM_NCPAINT

你好像在自定义non-client区,我觉得你可以先看看Nonclient Area

In general, processing these messages for standard windows is not recommended, because the application must be able to draw all the required parts of the nonclient area for the window. For this reason, most applications pass these messages to DefWindowProc for default processing.

An application that creates custom nonclient areas for its windows must process these messages. When doing so, the application must use a window device context to carry out drawing in the window. The window device context enables the application to draw in all portions of the window, including the nonclient area. An application retrieves a window device context by using the GetWindowDC or GetDCEx function and, when drawing is complete, must release the window device context by using the ReleaseDC function.

如果你只是考虑在调用WM_NCPAINT时自定义客户区的大小是否会发生变化,我无法给出合适的答案,因为我没有看到你的代码,我不知道你需要完成什么样的项目。

刚刚在另一个link测试了样本,non-client区域会一直保持4pixel的边框大小,计算也是在WM_NCCALCSIZE.