CreateWindowEx error in VC 6 port to VC 2008

CreateWindowEx error in VC 6 port to VC 2008

I have a Windows App that I ported from VC 6 to VC 2008.  However, it fails to start.

The code is basically this,
m_pMainWnd = new CMainFrame();
 
if (FALSE == m_pMainWnd->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL))
  return false;

As far as I can debug into it, it is failing on this call to AfxCtxCreateWindowEx in wincore.cpp (which appears to be a wrapper for CreateWindowExA).  The returned hWnd is null and GetLastError returns 0.

HWND hWnd = ::AfxCtxCreateWindowEx(cs.dwExStyle, cs.lpszClass,
   cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy,
   cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);


I checked out this related article, but it doesn't appear to resolve it.

Hi Cobaia01,

I have tested following code in my side:


 CMainFrame* pMainFrame = new CMainFrame;
 //if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
 if (FALSE == pMainFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL))
 {
  delete pMainFrame;
  return FALSE;
 }
 m_pMainWnd = pMainFrame;
It works fine in my side. And I found you used m_pMainWnd->LoadFrame() but not pMainFrame->LoadFrame()? Does it is also typo mistake? And I can't reach AfxCtxCreateWindowEx function.

Please let me know if the steps I have done is different from yours.


I think I figured it out.  There were some missing components that weren't being built when I ported it over.  I ported and built these missing components then copied it to the debug directory and it worked.

I still don't understand the relationship between the missing components and CreateWindowEx, but right now I'm just glad it works.  Thanks for all the help.  I feel a little silly that the solution was only a change to the solution file, but relieved that it was not a compatibility issue between VC 6 and 2008.

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright