Change background color of combo box's dropdown list.
-
Hello, How to change the background color of the dropdown list in combo box. I changed the back ground color of dialog box in OnCtlColor() method, this changed the color of all the items on the dialog. I could individual controls color but not able to change the dropdown list color of combo box. Below is the code snippet. if(pWnd->GetDlgCtrlID() == IDC_COMBO1) { HBRUSH g_bkcolor = CreateSolidBrush(RGB(255,255,255)); pDC->SetTextColor(RGB(0,0,0)); pDC->SetBkColor (RGB(255,255,255)); hbr = g_bkcolor; return hbr; } If someone knows how to change the color please let me know.. Thank You..
-
Hello, How to change the background color of the dropdown list in combo box. I changed the back ground color of dialog box in OnCtlColor() method, this changed the color of all the items on the dialog. I could individual controls color but not able to change the dropdown list color of combo box. Below is the code snippet. if(pWnd->GetDlgCtrlID() == IDC_COMBO1) { HBRUSH g_bkcolor = CreateSolidBrush(RGB(255,255,255)); pDC->SetTextColor(RGB(0,0,0)); pDC->SetBkColor (RGB(255,255,255)); hbr = g_bkcolor; return hbr; } If someone knows how to change the color please let me know.. Thank You..
1.Derive the Combo box class 2.Overide the WM_CREATE message i.e CBS_OWNERDRAWFIXED in Create function 3. Handel the DrawItem function of Combobox Here a. Fill the Item's rectabgle with the color you wanted to show as background b. Then drawtext on top of it. I think this much clue is sufficient.
-
1.Derive the Combo box class 2.Overide the WM_CREATE message i.e CBS_OWNERDRAWFIXED in Create function 3. Handel the DrawItem function of Combobox Here a. Fill the Item's rectabgle with the color you wanted to show as background b. Then drawtext on top of it. I think this much clue is sufficient.
Thanks for the reply. I am not that expect in MFC to get it. Could you explain it with an example? Than you once again..
-
Thanks for the reply. I am not that expect in MFC to get it. Could you explain it with an example? Than you once again..
Using colors in CEdit and CStatic[^] This article will help you to understand how to create the custom control according to requirement. After understanding those start working on your combo box.