CreateWindow失败,

bsnry 2012-05-31 03:36:35

CreateWindow后, 调用showWindow失败,猜测是CreateWindow导致的




BOOL CWnd::ShowWindow(int nCmdShow)
{
ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));

if (m_pCtrlSite == NULL)
return ::ShowWindow(m_hWnd, nCmdShow);
else
return m_pCtrlSite->ShowWindow(nCmdShow); //这里失败
}






//以下是用的DirectUI ,里有 ShowWindow函数, 大家看看
CWinApp::InitInstance();

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
// To create the main window, this code creates a new frame window
// object and then sets it as the application's main window object
CMainFrame* pFrame = new CMainFrame;
if (!pFrame)
return FALSE;
m_pMainWnd = pFrame;

//////////////////////////////////////////////////////////////////////////
char szAppPath[MAX_PATH];
GetModuleFileName(GetModuleHandle(NULL), szAppPath, MAX_PATH);
char *pXmlFile = strrchr(szAppPath, '\\');
if (pXmlFile)
{
*pXmlFile = '\0';
pXmlFile = strrchr(szAppPath, '\\');
if (pXmlFile)
{
pXmlFile++;
*pXmlFile = '\0';

#if _MSC_VER >= 1400
strcat_s(szAppPath, "skin\\NewYear\\config.xml");
#else
strcat(szAppPath, "skin\\NewYear\\config.xml");
#endif

BodSoftDirectUIVerify();
m_pWindowManager = (duWindowManager *)duLoadStyle(szAppPath);
}
}


// create and load the frame with its resources
pFrame->Create(NULL, _T("FirstUI"));

// The one and only window has been initialized, so show and update it
pFrame->ShowWindow(SW_SHOW);
pFrame->UpdateWindow();
// call DragAcceptFiles only if there's a suffix
// In an SDI app, this should occur after ProcessShellCommand





以下是CreateWindow的代码:


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{

if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;

if ( !theApp.m_pWindowManager->duAttach(m_hWnd, "mainframe") )
return -1;

duWindow *pWindow = theApp.m_pWindowManager->duGetWindow(m_hWnd);
if (pWindow == NULL)
return -1;

return 0;
}













...全文
180 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wutongsana 2012-06-01
  • 打赏
  • 举报
回复
看得不是很懂,帮你顶一下。

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧