AfxWndProc and compiling a MFC app with MFC 8.0

Hi all,

I'm compiling an existing MFC (VC 6.0) in Visual Studio 2005 and after fixing so many compile and link errors finally I could run the application but I got some asserts in the AfxWndProc method of the wincore.cpp. I found a KB article on a bug in MFC about modal dialogs but didn't know if it is still there in MFC 8.0

I didn't find any other resources about the same problem but I'm getting this assert in opening many of the documents of my MDI application.

RESULT CALLBACK

AfxWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)

{

// special message which identifies the window as using AfxWndProc

if (nMsg == WM_QUERYAFXWNDPROC)

return 1;

// all other messages route through message map

CWnd* pWnd = CWnd::FromHandlePermanent(hWnd);

ASSERT(pWnd != NULL);

ASSERT(pWnd==NULL || pWnd->m_hWnd == hWnd);

if (pWnd == NULL || pWnd->m_hWnd != hWnd)

return ::DefWindowProc(hWnd, nMsg, wParam, lParam);

return AfxCallWndProc(pWnd, hWnd, nMsg, wParam, lParam);

}

 I know that I'm not giving a precise description but thought maybe there is something that I'm missing or anybody knows a good reference to a same problem.

Thanks in advance,

Shadi

 



Answer this question

AfxWndProc and compiling a MFC app with MFC 8.0

  • David Friesen, B.Eng

    The best is to evaluate how the control is created. And after the control is created if it can be found in the message map.

    To do this, get the HWND handle and check if CWnd::FromHandle returns the same pointer as your stored object.

    You can place this check arround in your code to see when the error occurs.

    Oh! There might be another problem. Is there a chance that you have mixed different MFC versions Is there a chance that you use old libraries



  • y0ngb00n

    I found it out that the asserts only show up when I'm displaying a dialog with a grid on it. The grid is an instance of CUGCtrl from Dundas so although I have access to its source I'm not fimiliar with it at all. I just can see that the grid is derived from CWnd and I searched for WM_DESTROY and there are lots of it in the Dundas project.

    How can I find the problem I'm not a MFC man!!! my experiences are all on .net!!! but I will try to understand what you are trying to tell me. so thanks a lot and your help is appreciated very much.

     


  • jessie2

    There is a window that was created or subclassed with a MFC CWnd derived class and this window is not member of the permanent window handle map. This map is used find the CWnd pointer from a window handle.

    Something is totally bogus if there is still a window using this window proc and no longer member of the map.

    Are you have some special code that directly subclasses a window using AfxWndProc If so there is a bug inside this.
    Are you posting WM_DESTROY messages by yourself, without using DestroyWindow



  • jbranton

    I'm compiling their source code with VC++ 2005 and using it in a migrated VC 6.0 project. I mean the using project and the grid DLLs are all built in VC++ 2005. Does it help
  • AfxWndProc and compiling a MFC app with MFC 8.0