[英]Win32 C++ Subclassed label not receiving WM_PAINT after calling WM_SETTEXT
Is it normal behavior that a subclassed control does not receive WM_PAINT after you call WM_SETTEXT on it? 在子类控件上调用WM_SETTEXT后,它没有收到WM_PAINT是正常行为吗?
The parent does receive WM_CTLCOLOR, but I want to paint evertything inside my subclassed WM_PAINT message. 父级确实收到WM_CTLCOLOR,但我想在子类WM_PAINT消息中绘制所有内容。
I assume calling InvalidateRect after calling WM_SETTEXT is the way to go? 我假设调用WM_SETTEXT之后调用InvalidateRect是可行的方法?
Let me know if you want to see code. 如果您想查看代码,请告诉我。 I feel like its not necessary for this question that is why I left it out initially.
我觉得对于这个问题没有必要,这就是为什么我一开始就忽略了它。
Whether WM_PAINT is sent in response to WM_SETTEXT depends on what window class has been sub-classed, buttons for example are invalidated but list boxes are not (the window text for a list box is little more than a debugging aid as it is not shown in the UI). 是否发送WM_PAINT来响应WM_SETTEXT取决于已子类化了哪个窗口类,例如使按钮无效,但列表框无效(列表框的窗口文本仅是调试辅助工具,因为未在其中显示)。 UI)。
If your class is such that setting the text should invalidate you could always add something like the following to your subclass' WindowProc: 如果您的类使得设置文本无效,则可以始终在子类的WindowProc中添加以下内容:
case WM_SETTEXT: {
LRESULT res = CallWindowProc(lpfnParent, hWnd, WM_SETTEXT, wParam, lParam);
InvalidateRect(hWnd, nullptr, true);
return res;
}
That way you don't need to have an InvalidateRect each time you set the control text. 这样,您每次设置控件文本时都不需要InvalidateRect。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.