Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,,,
while compiling im not getting any error but while debugging "debugging assertion failed" is coming ... i do no how to solve it ,,, pls help me




C#
CButton::~CButton()
{
    DestroyWindow();
}

// Helper for radio buttons
int CWnd::GetCheckedRadioButton(int nIDFirstButton, int nIDLastButton)
{
    for (int nID = nIDFirstButton; nID <= nIDLastButton; nID++)
    {
        if (IsDlgButtonChecked(nID))
            return nID; // id that matched
    }
    return 0; // invalid ID
}

// Derived class is responsible for implementing all of these handlers
//   for owner/self draw controls
void CButton::DrawItem(LPDRAWITEMSTRUCT)
{
the prob occurs here
const CString& CString::operator=(LPCTSTR lpsz)
{
ASSERT(lpsz == NULL || AfxIsValidString(lpsz));
 return TRUE;
}



BOOL CButton::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam,
    LRESULT* pResult)




<pre lang="cs">this is my call stack ,, i dono whats the problem.. if im silly ,, please forgive me ,,, pls guide me




CButton::DrawItem(tagDRAWITEMSTRUCT * 0x0012f6fc) line 72 + 25 bytes

CButton::OnChildNotify(unsigned int 43, unsigned int 1002, long 1242876, long * 0x00000000) line 84

CWnd::SendChildNotifyLastMsg(long * 0x00000000) line 2683

CWnd::ReflectLastMsg(HWND__ * 0x00840a22, long * 0x00000000) line 2721

CWnd::OnDrawItem(int 1002, tagDRAWITEMSTRUCT * 0x0012f6fc) line 1156 + 14 bytes

CWnd::OnWndMsg(unsigned int 43, unsigned int 1002, long 1242876, long * 0x0012f51c) line 1930

CWnd::WindowProc(unsigned int 43, unsigned int 1002, long 1242876) line 1585 + 30 bytes

AfxCallWndProc(CWnd * 0x0012fd98 {CComboTestDlg hWnd=???}, HWND__ * 0x001202ec, unsigned int 43, unsigned int 1002, long 1242876) line 215 + 26 bytes

AfxWndProc(HWND__ * 0x001202ec, unsigned int 43, unsigned int 1002, long 1242876) line 368

AfxWndProcBase(HWND__ * 0x001202ec, unsigned int 43, unsigned int 1002, long 1242876) line 220 + 21 bytes

USER32! 77d48709()

USER32! 77d4d297()

USER32! 77d4b743()

USER32! 77d4b7ab()

USER32! 77d605d0()

USER32! 77d761c6()

USER32! 77d5922c()

USER32! 77d5887a()

USER32! 77d48709()

USER32! 77d487eb()

USER32! 77d4c00e()

USER32! 77d4e366()

CWnd::DefWindowProcA(unsigned int 15, unsigned int 0, long 0) line 1000 + 32 bytes

CWnd::WindowProc(unsigned int 15, unsigned int 0, long 0) line 1586 + 26 bytes

AfxCallWndProc(CWnd * 0x0012fe38 {CButton hWnd=0x00840a22}, HWND__ * 0x00840a22, unsigned int 15, unsigned int 0, long 0) line 215 + 26 bytes

AfxWndProc(HWND__ * 0x00840a22, unsigned int 15, unsigned int 0, long 0) line 368

AfxWndProcBase(HWND__ * 0x00840a22, unsigned int 15, unsigned int 0, long 0) line 220 + 21 bytes

USER32! 77d48709()

USER32! 77d487eb()

USER32! 77d4b368()

USER32! 77d4b3b4()

NTDLL! 7c90e473()

USER32! 77d62719()

USER32! 77d6ec20()

USER32! 77d5fd5c()

CWnd::CreateDlgIndirect(const DLGTEMPLATE * 0x00419890, CWnd * 0x00000000 {CWnd hWnd=???}, HINSTANCE__ * 0x00400000) line 327 + 36 bytes

CDialog::DoModal() line 528 + 32 bytes

CComboTestApp::InitInstance() line 58 + 11 bytes

AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00141eff, int 1) line 39 + 11 bytes

WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00141eff, int 1) line 30

WinMainCRTStartup() line 330 + 54 bytes

KERNEL32! 7c816fe7()



thanks
Posted
Updated 22-Mar-11 18:00pm
v5

1 solution

Hi Degorio,

The Problem in your DrawItem(), This function is Called by the framework when a visual aspect of an owner-drawn button has changed

Why are you using CString::operator=(LpCSTR Lpsz), If you want to set caption of button then use this

::DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(), 
      &lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);


Check this http://msdn.microsoft.com/en-us/library/y0k9f0a4(VS.80).aspx
 
Share this answer
 
Comments
degorio 22-Mar-11 1:48am    
still im getting the same prob
LaxmikantYadav 22-Mar-11 4:30am    
Please tell me, What you want to do in DrawItem() ?
degorio 22-Mar-11 5:57am    
i must change the color of the push button,i used ownerdraw button from that while debugging im recieving the "debug assertion failure"
this is my code

void CAboutDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your message handler code here and/or call default
CDC dc;
dc.Attach(lpDrawItemStruct->hDC); //Get device context object
CRect rt;
rt = lpDrawItemStruct->rcItem; //Get button rect

dc.FillSolidRect(rt, RGB(0, 240, 120)); //Fill button with blue color


UINT uStyle = DFCS_BUTTONPUSH;




// If drawing selected, add the pushed style to DrawFrameControl.
if (lpDrawItemStruct->itemState & ODS_SELECTED)
uStyle |= DFCS_PUSHED;

// Draw the button frame.
::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem,
DFC_BUTTON, uStyle);

// Get the button's text.
CString strText;
GetWindowText(strText);

// Draw the button text using the text color red.
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);



}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900