Assertion Error in ownerdraw combobox..
-
Hi I am creating ownerdraw combobox, when I am calling create function in my CCstomCombox which is derived from CComboBox, its giving Assertion error. After debuging I got the error in below function: My Create function is : this->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|CBS_HASSTRINGS |CBS_DROPDOWNLIST|CBS_OWNERDRAWFIXED,rect,pWnd,nID); In line : (ASSERT(pWnd->m_hWnd == NULL); // only do once) In function: void AFXAPI AfxHookWindowCreate(CWnd* pWnd) { _AFX_THREAD_STATE* pThreadState = _afxThreadState.GetData(); if (pThreadState->m_pWndInit == pWnd) return; if (pThreadState->m_hHookOldCbtFilter == NULL) { pThreadState->m_hHookOldCbtFilter = ::SetWindowsHookEx(WH_CBT, _AfxCbtFilterHook, NULL, ::GetCurrentThreadId()); if (pThreadState->m_hHookOldCbtFilter == NULL) AfxThrowMemoryException(); } ASSERT(pThreadState->m_hHookOldCbtFilter != NULL); ASSERT(pWnd != NULL); ASSERT(pWnd->m_hWnd == NULL); // only do once ASSERT(pThreadState->m_pWndInit == NULL); // hook not already in progress pThreadState->m_pWndInit = pWnd; } Please help me to come out from this. Thanks..
-
Hi I am creating ownerdraw combobox, when I am calling create function in my CCstomCombox which is derived from CComboBox, its giving Assertion error. After debuging I got the error in below function: My Create function is : this->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|CBS_HASSTRINGS |CBS_DROPDOWNLIST|CBS_OWNERDRAWFIXED,rect,pWnd,nID); In line : (ASSERT(pWnd->m_hWnd == NULL); // only do once) In function: void AFXAPI AfxHookWindowCreate(CWnd* pWnd) { _AFX_THREAD_STATE* pThreadState = _afxThreadState.GetData(); if (pThreadState->m_pWndInit == pWnd) return; if (pThreadState->m_hHookOldCbtFilter == NULL) { pThreadState->m_hHookOldCbtFilter = ::SetWindowsHookEx(WH_CBT, _AfxCbtFilterHook, NULL, ::GetCurrentThreadId()); if (pThreadState->m_hHookOldCbtFilter == NULL) AfxThrowMemoryException(); } ASSERT(pThreadState->m_hHookOldCbtFilter != NULL); ASSERT(pWnd != NULL); ASSERT(pWnd->m_hWnd == NULL); // only do once ASSERT(pThreadState->m_pWndInit == NULL); // hook not already in progress pThreadState->m_pWndInit = pWnd; } Please help me to come out from this. Thanks..
-
you are creating the box one more time. If it is from a rc file, you dont need to call the constructor.
Press F1 for help or google it. Greetings from Germany
-
Hi I am creating ownerdraw combobox, when I am calling create function in my CCstomCombox which is derived from CComboBox, its giving Assertion error. After debuging I got the error in below function: My Create function is : this->Create(WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|CBS_HASSTRINGS |CBS_DROPDOWNLIST|CBS_OWNERDRAWFIXED,rect,pWnd,nID); In line : (ASSERT(pWnd->m_hWnd == NULL); // only do once) In function: void AFXAPI AfxHookWindowCreate(CWnd* pWnd) { _AFX_THREAD_STATE* pThreadState = _afxThreadState.GetData(); if (pThreadState->m_pWndInit == pWnd) return; if (pThreadState->m_hHookOldCbtFilter == NULL) { pThreadState->m_hHookOldCbtFilter = ::SetWindowsHookEx(WH_CBT, _AfxCbtFilterHook, NULL, ::GetCurrentThreadId()); if (pThreadState->m_hHookOldCbtFilter == NULL) AfxThrowMemoryException(); } ASSERT(pThreadState->m_hHookOldCbtFilter != NULL); ASSERT(pWnd != NULL); ASSERT(pWnd->m_hWnd == NULL); // only do once ASSERT(pThreadState->m_pWndInit == NULL); // hook not already in progress pThreadState->m_pWndInit = pWnd; } Please help me to come out from this. Thanks..
When you use a control in a dialogue box AND describe it in the resource template you don't create it. You only use CWnd::Create (or overidden version) when you're creating the control outside of a dialogue box. So if you're using a dialogue box instead of calling Create set up the resource template and subclass the control using DDX_Control in DoDataExchange. Cheers, Ash PS: Just seen you response to Karsten, ignore this reply except for reference! PPS: It looks like you've already created the window when you called create. You're not calling it twice by mistake by any chance?