Background color issue when Aligning text of edit control of Ownerdraw ComboBox Text in Vertically Center

  • Thread starter Thread starter sgrm123
  • Start date Start date
S

sgrm123

Guest
Hi,

I subclassed edit control of combobox and able to align the text vertically center using the link Vertical Text Centering in an Edit Control.

CVEdit m_edit; // in header file


COMBOBOXINFO cbi = { sizeof cbi};
GetComboBoxInfo(&cbi);
m_edit.SubclassWindow(cbi.hwndItem);



I am using below code in OnNCPaint().

void CVEdit::OnNcPaint()
{
Default();

CWindowDC dc(this);
CBrush Brush(GetSysColor(COLOR_WINDOW));

dc.FillRect(m_rectNCBottom, &Brush);
dc.FillRect(m_rectNCTop, &Brush);
}



now the problem I am facing is when disabling the combobox if the parent of combobox is propertysheet the background color of edit control should be white and if the parent of combobox is dialog tor CMFCTabCtrl the background color of edit control should be RGB(240,240,240).

I tried GetParent()->GetParent()->GetDC()->GetBkColor() it always gives white irrespective of dialog or cpropertypage or CMFCTabCtrl.

So I tried with below code


CDC* pDC=GetDC();
LOGBRUSH LogBrush;


HBRUSH hBrush = (HBRUSH) SendMessage(WM_CTLCOLORDLG,(WPARAM) pDC->m_hDC,
(LPARAM) m_hWnd);
::GetObject(hBrush,sizeof(LOGBRUSH),&LogBrush);




It gives background color of dialog.

How to get background color of propertypage or propetysheet whcich is by default white?

Continue reading...
 
Back
Top