简体   繁体   中英

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?

The parent does receive WM_CTLCOLOR, but I want to paint evertything inside my subclassed WM_PAINT message.

I assume calling InvalidateRect after calling WM_SETTEXT is the way to go?

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).

If your class is such that setting the text should invalidate you could always add something like the following to your subclass' 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM