none
How do I change the background color of Each item of combobox

    Question

  • i am a biginner in mfc

    I have a ComboBox in a DialogBox. How do I change the background of combobox

    Through coding. i want to change background of eachitem  inside the combobox.

    what iwant to do?

    Please help me............

     

    Wednesday, October 20, 2010 2:17 PM

Answers

  •  

    Hi

     

    OnCtlColor will not be called for the list box of a drop-down combo box because the drop-down list box is actually a child of the combo box and not a child of the window.

     

    To change the color of the drop-down list box, create a CComboBox with an override of OnCtlColor that checks for CTLCOLOR_LISTBOX in the nCtlColor parameter. In this handler, the SetBkColor member function must be used to set the background color for the text.

     

    If you still have any doubts and concerns about this issue, please let me know.

     

    Regards!

    Jesse


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, October 22, 2010 7:34 AM

All replies

  • To change the background color of an control in an MFC application, you must override the OnCtlColor() message-handling function of the window containing the edit control.

    http://support.microsoft.com/kb/117778

     

     

    Thursday, October 21, 2010 4:05 PM
  •  

    Hi

     

    OnCtlColor will not be called for the list box of a drop-down combo box because the drop-down list box is actually a child of the combo box and not a child of the window.

     

    To change the color of the drop-down list box, create a CComboBox with an override of OnCtlColor that checks for CTLCOLOR_LISTBOX in the nCtlColor parameter. In this handler, the SetBkColor member function must be used to set the background color for the text.

     

    If you still have any doubts and concerns about this issue, please let me know.

     

    Regards!

    Jesse


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, October 22, 2010 7:34 AM