Reputation: 645
I have two Cedit and one CCombobox.
you can see the under code, I set the text color to yellow.
then I use a transparent text background, also a transparent background.
It works perfectly fine for Cedit (I don't care the change when I type something in it).
But I notice that the pDC->SetBkMode(TRANSPARENT);
do nothing to my CCombobox.
I really don't want to subclass CComboBox to accomplish the transparent background.
or do I need to use drawitem???
HBRUSH CValueInputDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hBrush = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_EDIT)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(RGB(255, 255, 0));
hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
}
return hBrush;
}
Upvotes: 0
Views: 763
Reputation: 2239
I don't think you're gonna be able to get a good result without subclassing or doing some more work. Transparent controls in MFC are not an easy thing.
Anyway, if you want to get the transparent background on the drop-down list of the combo you need to use CTLCOLOR_LISTBOX instead of CTLCOLOR_EDIT. And CTLCOLOR_BTN for the drow-down button.
Upvotes: 2