创建的时候如下代码:
BOOL CLibUIDK_Demo_BaseApp::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"));
// Change the path under which your skin files are stored.
int nRet = CUIMgr::SetUIPath(_T("Skins\\libUIDK_Demo_Base\\the.xui"));
if (nRet != 0)
{
AfxMessageBox(_T("Failed to set the ui path or the ui path isn't exist!"));
return FALSE;
}
// To create the main window, this code creates a new frame window
// object and then sets it as the application's main window object.
m_pMainWndHandler = new CMainWndHandler(IDW_MAIN);
m_pMainFrame = CUIMgr::LoadFrame(IDR_MAINFRAME, WS_VISIBLE | WS_POPUP,
IDW_MAIN, m_pMainWndHandler);
if (m_pMainFrame == NULL)
{
// Search the error code in LibUIDK.h, the first error code is E_LOADBMPB.
DWORD dwLastError = m_pMainFrame->GetLastCreateError();
return FALSE;
}
m_pMainFrame->CenterWindow();
// The one and only window has been initialized, so show and update it.
m_pMainFrame->ShowWindow(SW_SHOW);
m_pMainFrame->UpdateWindow();
m_pMainWnd = m_pMainFrame;
return TRUE;
}
如果直接调用对话框,需要修改成如下的代码:
BOOL CLibUIDK_Demo_BaseApp::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"));
// Change the path under which your skin files are stored.
int nRet = CUIMgr::SetUIPath(_T("Skins\\libUIDK_Demo_Base\\the.xui"));
if (nRet != 0)
{
AfxMessageBox(_T("Failed to set the ui path or the ui path isn't exist!"));
return FALSE;
}
CTestDlg ETVMessageBoxDlg;
m_pMainWnd = &ETVMessageBoxDlg;
INT_PTR nResponse = ETVMessageBoxDlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 在此放置处理何时用
// “确定”来关闭对话框的代码
}
else if (nResponse == IDCANCEL)
{
// TODO: 在此放置处理何时用
// “取消”来关闭对话框的代码
}
else if (nResponse == -1)
{
TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
}
return TRUE;
}