void CEnvInfoSettingDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if(nIDCtl == IDC_COMBO8)
{
CString str;
if(lpDrawItemStruct->itemID >= (UINT)m_ctl_combo8.GetCount() || !m_ctl_combo8.GetCount()) return;
CDC *p_dc = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect r(lpDrawItemStruct->rcItem);
int old_mode = p_dc->SetBkMode(TRANSPARENT);
m_ctl_combo8.GetLBText(lpDrawItemStruct->itemID, str);
switch(lpDrawItemStruct->itemAction)
{
case ODA_DRAWENTIRE:
case ODA_FOCUS:
case ODA_SELECT:
if(lpDrawItemStruct->itemState & ODS_SELECTED)
{
if(strcmp(str, "DB") == 0)
p_dc->FillSolidRect(r, RGB(0, 0, 255));
else if(strcmp(str, "USER") == 0)
p_dc->FillSolidRect(r, RGB(255, 0, 0));
else
p_dc->FillSolidRect(r, RGB(0, 0, 0));
p_dc->SetTextColor(RGB(255, 255, 255));
p_dc->TextOut(r.left + 5, r.top + 1, str);
} else
{
p_dc->FillSolidRect(r, RGB(255, 255, 255));
if(strcmp(str, "DB") == 0)
p_dc->SetTextColor(RGB(0, 0, 255));
else if(strcmp(str, "USER") == 0)
p_dc->SetTextColor(RGB(255, 0, 0));
else
p_dc->SetTextColor(RGB(0, 0, 0));
p_dc->TextOut(r.left + 5, r.top + 1, str);
}
break;
}
p_dc->SetBkMode(old_mode);
}
else
CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);
}
***** 중요 포인트 *****
컨트롤 속성에서
Has Strings --> True
Owner Draw --> Fixed
로 바꿔야 위 이벤트 함수에 들어간다!!
'프로그래머의 길 > C & C++' 카테고리의 다른 글
슬라이더 컨트롤 버튼 2개 샘플 (0) | 2011.02.17 |
---|---|
CSliderCtrl Focus 테두리(점선) 없애는 방법 (0) | 2010.10.27 |
윈도우 종료 (2) | 2010.01.06 |
CStringT::Tokenize. (0) | 2009.12.02 |
complex 예제 (복소수 연산) & conj (켤레 복소수) (0) | 2009.12.01 |