Owner-drawn CListBox-derived background color question
-
Hi I am creating a class derived from CListBox so I can control the fonts, color, etc2. I also want to control the background color of the listbox (not the text's background color, but the whole listbox' background color), and I am doing it by handling WM_ERASEBKGND message in OnEraseBkgnd() function. The OnEraseBkgnd() implementation is very simple, basically I just obtain the client rect and the use CDC::FillSolidRect to fill it with the background color of my choice. The problem is, the background color is correctly drawn if there is at least one item in the listbox, but when the listbox is empty, the background color is always displayed as white, even though I have stepped in the debugger and make sure that the FillSolidRect function is executed. Could someone tell me what the possible cause for this is? Thanks!
-
Hi I am creating a class derived from CListBox so I can control the fonts, color, etc2. I also want to control the background color of the listbox (not the text's background color, but the whole listbox' background color), and I am doing it by handling WM_ERASEBKGND message in OnEraseBkgnd() function. The OnEraseBkgnd() implementation is very simple, basically I just obtain the client rect and the use CDC::FillSolidRect to fill it with the background color of my choice. The problem is, the background color is correctly drawn if there is at least one item in the listbox, but when the listbox is empty, the background color is always displayed as white, even though I have stepped in the debugger and make sure that the FillSolidRect function is executed. Could someone tell me what the possible cause for this is? Thanks!
Hi this is from MSDN :
The **WM_CTLCOLORLISTBOX** message is sent to the parent window of a list box before the system draws the list box. By responding to this message, the parent window can set the text and background colors of the list box by using the specified display device context handle.
-
Hi I am creating a class derived from CListBox so I can control the fonts, color, etc2. I also want to control the background color of the listbox (not the text's background color, but the whole listbox' background color), and I am doing it by handling WM_ERASEBKGND message in OnEraseBkgnd() function. The OnEraseBkgnd() implementation is very simple, basically I just obtain the client rect and the use CDC::FillSolidRect to fill it with the background color of my choice. The problem is, the background color is correctly drawn if there is at least one item in the listbox, but when the listbox is empty, the background color is always displayed as white, even though I have stepped in the debugger and make sure that the FillSolidRect function is executed. Could someone tell me what the possible cause for this is? Thanks!
Are you calling the base class OnEraseBkgnd() ? Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)