0
votes

I have an MFC Application that show a simple dialog containing a custom control the custom create dynamic control windows. after the first child of the custom control is created the application crash after a stack overflow

this is the call stack after the crash

    Amn80Lib1.dll!TPXBitButton::GetThisMessageMap() Line 1627   C++
    Amn80Lib1.dll!TPXBitButton::GetMessageMap() Line 1627   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2181    C++
    mfc100d.dll!CWnd::ReflectChildNotify(unsigned int uMsg, unsigned int wParam, long lParam, long * pResult) Line 3408 C++
>   mfc100d.dll!CWnd::OnChildNotify(unsigned int uMsg, unsigned int wParam, long lParam, long * pResult) Line 3387  C++
    mfc100d.dll!CButton::OnChildNotify(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 91  C++
    mfc100d.dll!CWnd::SendChildNotifyLastMsg(long * pResult) Line 3327  C++
    mfc100d.dll!CWnd::ReflectLastMsg(HWND__ * hWndChild, long * pResult) Line 3365  C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3463   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]    
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    user32.dll!75d1c4e7()   Unknown
    user32.dll!75d1c5e7()   Unknown
    user32.dll!75d1c590()   Unknown
    user32.dll!75d11b31()   Unknown
    user32.dll!75d32bee()   Unknown
    mfc100d.dll!CWnd::DefWindowProcA(unsigned int nMsg, unsigned int wParam, long lParam) Line 1089 C++
    mfc100d.dll!CWnd::Default() Line 291    C++
    mfc100d.dll!CWnd::OnParentNotify(unsigned int message, long lParam) Line 3468   C++
    mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2435    C++
    mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2087  C++
    Amn80Lib1.dll!TControl::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 29  C++
    mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 257    C++
    mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 420 C++
    The maximum number of stack frames supported by Visual Studio has been exceeded.    

The message that is sent always is 528 this is 0x210 = WM_PARENTNOTIFY The wParam = 77594625, lParam = 3409408

I don't know what is the reason for that, and how to stop it, I searched the childs if any of them send any message to the parent, but there is no messages, the dialog is not shown , but it's window handle was created and the custom control also has got a handle and it's first child has got a handle then we are stuck with the crash and the other childs didn't got the chance to be created. I traced the execution and got that the crash happen after calling the create method of the child of the custom control inside the dialog. The custom control is a database navigation control that contains buttons for the next, previous, new, edit to enter record number, this custom control is inherited from TControl which is inherited from CWnd. the buttons inside it are inheriting from TButton which inherits from CButton.

UPDATE


The problem was as the following:

when I registered the custom control window class I set the windowproc to the MFC windowProc , when the MFC proc didn't find any method to eat the message it called the default proc of the window which is the MFC windowPoc that caused an open recursion, I fixed that by setting the window proc to the default one like the following

WNDCLASS wndClass;
//fill the window class data
wndClass.lpfnWndProc = ::DefWindowProc;//AfxWndProc;//this fixed it

that fixed my problem

1
Your stack dump looks as if there is some recursion going on and therefore you get a stack overfklow.Jabberwocky
yes it is a stackoverflow, from recursion in sending the same message for ever, and now I discovered the fatal mistake I've made, I'll post it as an update to my questionahmedsafan86
Don't post it as un update to your question but answer your own question.Jabberwocky
@MichaelWalz : I Added it to answerahmedsafan86

1 Answers

0
votes

I updated the answer to contain the solution of that problem, but in response to @Michael Walz I added the solution to this answer


when I registered the custom control window class I set the windowproc to the MFC windowProc , when the MFC proc didn't find any method to eat the message it called the default proc of the window which is the MFC windowPoc that caused an open recursion, I fixed that by setting the window proc to the default one like the following

WNDCLASS wndClass;
//fill the window class data
wndClass.lpfnWndProc = ::DefWindowProc;//AfxWndProc;//this fixed it
that fixed my problem