コード例 #1
0
ファイル: OnStation.cpp プロジェクト: felixcollins/onstation
BOOL COnStationApp::InitInstance()
{
	pSettings_G=new CSettings();
	// CG: This line was added by the OLE Control Containment component
	AfxEnableControlContainer();

	// CG: The following block was added by the Splash Screen component.
	{
		CCommandLineInfo cmdInfo;
		ParseCommandLine(cmdInfo);

		CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
	}
	SetRegistryKey("On Station Cave Mapping");
	m_MySettings=new CAppSettings();
	m_MySettings->ReadFromIniFile();

	// 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.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	uiCustomClipboardFormat_G=RegisterClipboardFormat("OnStationCustomFormat");
	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(COnStationDoc),
		RUNTIME_CLASS(CMainFrame),
		RUNTIME_CLASS(COnStationView));
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
//	CMainFrame* pMainFrame = new CMainFrame;
//	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
//		return FALSE;
//	m_pMainWnd = pMainFrame;

	//Make us nice and Win95 compliant
	EnableShellOpen();
	RegisterShellFileTypes();

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The main window has been initialized, so show and update it.
//	pMainFrame->ShowWindow(m_nCmdShow);
//	pMainFrame->UpdateWindow();

	// CG: This line inserted by 'Tip of the Day' component.
	Sleep(2500);
	ShowTipAtStartup();
	return TRUE;
}
コード例 #2
0
BOOL CCarlaStudioApp::InitInstance()
{
try
{
// turn this on for extra new/delete checking in debug version
//	afxMemDF |= checkAlwaysMemDF;

	if (!InitATL())
		return FALSE;

	AfxInitRichEdit( );

	//AddToRecentFileList ("x");

//AfxEnableControlContainer( );	// for using activeX

	// 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.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)
	m_recentProjectsList.ReadList();

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CMultiDocTemplate* pDocTemplate;


	// PROJECT
		pDocTemplate = new CMultiDocTemplate(
		IDR_CStudioPTYPE,
		RUNTIME_CLASS(CProjectDoc),
		RUNTIME_CLASS(CNullWindow),//
		RUNTIME_CLASS(CEditView));
	AddDocTemplate(pDocTemplate);

	// language model document
	pDocTemplate = new CMultiDocTemplate(
		IDR_CStudioLangTYPE,
		RUNTIME_CLASS(CLangModelsDoc),
		RUNTIME_CLASS(CTabbedTreeChild), // custom MDI child frame
		RUNTIME_CLASS(CWTabBar));
	AddDocTemplate(pDocTemplate);

	// ANA
	pDocTemplate = new CMultiDocTemplate(
		IDR_CStudioAnaDocType,
		RUNTIME_CLASS(CAnaInputDoc),
		RUNTIME_CLASS(CMDIChildWnd),
		RUNTIME_CLASS(CInputDocView));
		AddDocTemplate(pDocTemplate);

	// SOURCE
	pDocTemplate = new CMultiDocTemplate(
		IDR_CStudioSrcDocType,
		RUNTIME_CLASS(CSourceTextInputDoc),
		RUNTIME_CLASS(CMDIChildWnd),
		RUNTIME_CLASS(CInputDocView));
		AddDocTemplate(pDocTemplate);


	// LOG WINDOW
	pDocTemplate = new CMultiDocTemplate(
			IDR_CLogWindowType,
			RUNTIME_CLASS(CLogWindow),
			RUNTIME_CLASS(CMDIChildWnd),
			RUNTIME_CLASS(CEditView));
		AddDocTemplate(pDocTemplate);

	// QUICK PARSE
	pDocTemplate = new CMultiDocTemplate(
			IDR_QuickParseDocType,
			RUNTIME_CLASS(CQuickParseDoc),
			RUNTIME_CLASS(CMDIChildWnd),
			RUNTIME_CLASS(CQuickParseView));
		AddDocTemplate(pDocTemplate);



/*	pDocTemplate = new CMultiDocTemplate(
		IDR_CStudioPTYPE,
		RUNTIME_CLASS(CProjectDoc),
		RUNTIME_CLASS(CMDIChildWnd),
		RUNTIME_CLASS(CEditView));	// I don't what this means here, since the views are chosen in the settings child window code
	AddDocTemplate(pDocTemplate);
*/
	// create main MDI Frame window
	CStudioMainFrame* pMainFrame = new CStudioMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(FALSE);// no printing

	// this must come before the commandline parser, since it might open a project
	CProcessSequence::getAvailableProcessorList(m_pProcessTemplates);


	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;

	cmdInfo.m_bShowSplash = TRUE;

	ParseCommandLine(cmdInfo);

	if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
	{
		// this will be true when someone makes a hook object but CS wasn't
		// already running.  COM will run CS for the purpose of getting a hook object.

		// if we wanted to allow CS to run and provide com objects without
		// being visible, then we'd uncomment this line
				//return TRUE;
	}

#ifndef _DEBUG
	if( cmdInfo.m_bShowSplash )
	{
		CGuruSplash * pSplashWnd = new CGuruSplash(IDB_SPLASH,2000);
		pSplashWnd->Create();
	}
#endif

	// jdh the following code is so that we don't get a blank project by default
	// ParseCommand will have changed this to FileOpen if the user opened a project from windows file manager
	if(cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
		cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

//	OnAppAbout();

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	m_sLastOpenDir = GetProfileString( "Defaults", "LastOpenDir");

	CString sProjectPath = GetProfileString( "Defaults", "LastProjectFile");
	if(!getProject(TRUE)) // if command-line didn't open one
	{
		if(sProjectPath.GetLength())
		{
			if(askUserToFindFileIfNotFound(sProjectPath, CProjectDoc::getRegFileTypeID()))
				CProjectDoc* pDoc = (CProjectDoc*)OpenDocumentFile(sProjectPath);
		}
		else
		{
			OnFileNewProject();
		}
	}
	// The main window has been initialized, so show and update it.
	//these were above the openDocumentFIle stuff before
	//pMainFrame->ShowWindow(m_nCmdShow);
//	pMainFrame->UpdateWindow();

	}
	catch(LPCTSTR lpszError)
	{
		CString s;
		s = "CARLAStudio has encountered an unexpected condition.\n";
		s += "This is definitely a bug in CarlaStudio.\n";
#ifndef hab15a3
		s += "Please send a bug report, and include the following information:\n\n"; // hab 09/09/1999 fix typo
#else
		s += "Please sent a bug report, and include the following information:\n\n";
#endif // hab15a3
		CString sWhere;\
		sWhere.Format("Uncaught LPTSTR Exception \"%s\"", lpszError);
		s += sWhere;
		AfxMessageBox(s, MB_ICONSTOP | MB_OK);
		return FALSE;
	}
		catch(CString sError)
	{
		CString s;
		s = "CARLAStudio has encountered an unexpected condition.\n";
		s += "This is definitely a bug in CarlaStudio.\n";
#ifndef hab15a3
		s += "Please send a bug report, and include the following information:\n\n"; // hab 09/09/1999 fix typo
#else
		s += "Please sent a bug report, and include the following information:\n\n";
#endif // hab15a3
		CString sWhere;\
		sWhere.Format("Uncaught CString Exception \"%s\"", sError);
		s += sWhere;
		AfxMessageBox(s, MB_ICONSTOP | MB_OK);
		return FALSE;
	}

	// CG: This line inserted by 'Tip of the Day' component.
	ShowTipAtStartup();


	return TRUE;
}