Hi,
I am doing a program to change the colour of push button, edit, check box by choosing the colour from combo box by clicking push button. My problem is the push button colour is not changing. Please help me to change the colour of the push button using owner draw, I have no error but the output is not displaying,, It shows a pop up window stating
"Debug Assertion Failed"
Prog: D:\output\assign\debug\combotest.exe
File:winctrl1.cpp
Line 72
For information on how your program can cause an assertion failure, see the visual c++ doc on asserts (Press retry to debug the app)
Why it is coming like this? I am new to MFC. If I am very silly sorry for wasting your time, please correct my mistake.
here is my code
void CAboutDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
UINT uStyle = DFCS_BUTTONPUSH;
ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
if (lpDrawItemStruct->itemState & ODS_SELECTED)
uStyle |= DFCS_PUSHED;
::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem,
DFC_BUTTON, uStyle);
CString strText;
GetWindowText(strText);
COLORREF crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(255,0,0));
::DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(),
&lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
::SetTextColor(lpDrawItemStruct->hDC, crOldColor);
}
thank you
AJ