示例#1
0
	BOOL InitInstance()
	{
		Session::InitDB();
		MainDialog dlg;
		m_pMainWnd = &dlg;
		dlg.DoModal();
		return TRUE;
	}
示例#2
0
BOOL CalculatorApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();


	AfxEnableControlContainer();

	// Create the shell manager, in case the dialog contains
	// any shell tree view or shell list view controls.
	CShellManager *pShellManager = new CShellManager;

	// Activate "Windows Native" visual manager for enabling themes in MFC controls
	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

	// 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("Calculator-Framebassman"));

	MainDialog dlg;
	m_pMainWnd = &dlg;
    dlg.DoModal();
	return FALSE;
}
BOOL AudioQualityIdentificationApp::InitInstance()
{
    assert(!atExit);
    atExit = new base::AtExitManager;

    SetErrorMode(SEM_NOGPFAULTERRORBOX);
    SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);

    // InitCommonControlsEx() is required on Windows XP if an application
    // manifest specifies use of ComCtl32.dll version 6 or later to enable
    // visual styles.  Otherwise, any window creation will fail.
    INITCOMMONCONTROLSEX initControls;
    initControls.dwSize = sizeof(initControls);

    // Set this to include all the common control classes you want to use
    // in your application.
    initControls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&initControls);

    CWinApp::InitInstance();

    MainDialog dialog;
    m_pMainWnd = &dialog;
    INT_PTR response = dialog.DoModal();
    if (response == IDOK) {
        // TODO: Place code here to handle when the dialog is
        // dismissed with OK
    } else if (response == IDCANCEL) {
        // TODO: Place code here to handle when the dialog is
        // dismissed with Cancel
    }

    // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
}
BOOL Application::InitInstance()
{
  // 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。  否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

  HANDLE hMutex = CreateMutex(NULL, TRUE, APPID);
  if (hMutex == NULL) {
    AfxMessageBox(IDS_PROMPT_APP_INIT_FAILED, MB_ICONERROR | MB_OK);
    return FALSE;
  }
  if (GetLastError() == ERROR_ALREADY_EXISTS) {
    // application already running.
    return FALSE;
  }

	AfxEnableControlContainer();


	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO:  应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("ZMVision"));

  CoInitialize(NULL);

  if (!GuiResources::GetInstance()->Init()) {
    AfxMessageBox(IDS_PROMPT_APP_INIT_FAILED, MB_OK | MB_ICONERROR);
    return FALSE;
  }

  for (int i = 1; i < __argc; i++) {
    if (_tcscmp(__targv[i], _T("-skipupdate")) == 0) {
      skipUpdate_ = true;
    }
  }

  if (WorkingParameters::GetInstance()->IsFTPInfoBlank())
  {
	  CInputNameKey inputDlg;
	  if (inputDlg.DoModal() != IDOK)
	  {
		  return FALSE;
	  }
  }

  SplashScreen splash;
  if (splash.DoModal() != IDOK) {
    return FALSE;
  }

  LoginDialog login;
  if (login.DoModal() != IDOK) {
    return FALSE;
  }

  if (!DebugLogger::GetInstance()->Init()) {
    AfxMessageBox(IDS_PROMPT_APP_INIT_FAILED, MB_OK | MB_ICONERROR);
    return FALSE;
  }

	MainDialog dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO:  在此放置处理何时用
		//  “确定”来关闭对话框的代码
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO:  在此放置处理何时用
		//  “取消”来关闭对话框的代码
	}
	else if (nResponse == -1)
	{
		TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
	}


	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
	//  而不是启动应用程序的消息泵。
	return FALSE;
}