I am writing my own subclass of CStatic right now, and I am a little stuck on how to change its background color.
From my previous experience, I’m used to reacting to the message “CTLCOLORSTATIC” with the color I want.
However, this is my subclass at the moment:
class LocationPane : public CWindowImpl<LocationPane, CStatic>
{
DECLARE_WND_CLASS(L"LocationPane");
public:
BEGIN_MSG_MAP_EX(LocationPane)
MSG_WM_PAINT(OnPaint)
MSG_WM_CTLCOLORSTATIC(OnCtlColorStatic);
END_MSG_MAP()
LocationPane();
~LocationPane();
private:
HBRUSH OnCtlColorStatic(CDCHandle cd, CWindow wnd);
void OnPaint(CDCHandle dc);
};
I tried to listen to the specified message, but I do not receive it at all. However, I am getting a paint message, so I cannot blame my user control for not working at all.
Is it a legal decision to try to process the background color in a paint routine? I don’t like to solve this, but I don’t get another message that I’m used to working with.
If you need additional code, do not hesitate to ask, I will gladly provide you with additional resources.
Thanks in advance.