示例#1
0
文件: np.cpp 项目: jetlive/skiaming
BOOL CNotepadApp::InitInstance()
{
	_tsetlocale(LC_ALL, _T(""));

	// Standard initialization

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

	// Register document templates

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CNotepadDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CNotepadView));
	AddDocTemplate(pDocTemplate);

	// open file specified on command line
	if (m_lpCmdLine[0] == 0)
		OnFileNew();
	else
		OpenDocumentFile(m_lpCmdLine);

	return TRUE;
}
示例#2
0
BOOL CDocManager::OnDDECommand( LPTSTR lpszCommand )
/**************************************************/
{
    if( _tcsncmp( lpszCommand, _DDECmdStart,
                  sizeof( _DDECmdStart ) / sizeof( TCHAR ) - 1 ) != 0 ) {
        return( FALSE );
    }
    lpszCommand += sizeof( _DDECmdStart ) / sizeof( TCHAR ) - 1;

    LPTSTR lpszEnd = _tcsstr( lpszCommand, _DDECmdEnd );
    if( lpszEnd == NULL ) {
        return( FALSE );
    }
    *lpszEnd = _T('\0');

    CWinApp *pApp = AfxGetApp();
    ASSERT( pApp != NULL );
    CWnd *pMainWnd = pApp->m_pMainWnd;
    ASSERT( pMainWnd != NULL );
    if( !pMainWnd->IsWindowVisible() ) {
        pMainWnd->ShowWindow( SW_SHOW );
    }
    
    OpenDocumentFile( lpszCommand );
    
    return( TRUE );
}
示例#3
0
BOOL CWinApp::OnOpenRecentFile( UINT nID )
/****************************************/
{
    ASSERT( m_pRecentFileList != NULL );
    OpenDocumentFile( (*m_pRecentFileList)[nID - ID_FILE_MRU_FILE1] );
    return( TRUE );
}
示例#4
0
BOOL CPaletteApp::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.

	SetDialogBkColor();        // set dialog background color to gray
	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.

	AddDocTemplate(new CSingleDocTemplate(IDR_MAINFRAME,
			RUNTIME_CLASS(CPaletteDoc),
			RUNTIME_CLASS(CMainFrame),     // main SDI frame window
			RUNTIME_CLASS(CPaletteView)));



	// simple command line parsing
	if (m_lpCmdLine[0] == '\0')
	{
		// create a new (empty) document
		OnFileNew();
	}
	else
	{
		// open an existing document
		OpenDocumentFile(m_lpCmdLine);
	}

	return TRUE;
}
示例#5
0
void CDocManager::OnFileOpen()
/****************************/
{
    CString strFileName;
    if( DoPromptFileName( strFileName, AFX_IDS_OPENFILE,
                          OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, TRUE, NULL ) ) {
        if( OpenDocumentFile( strFileName ) == NULL ) {
            AfxMessageBox( AFX_IDP_FAILED_TO_OPEN_DOC );
        }
    }
}
示例#6
0
文件: sepedt.cpp 项目: mingpen/OpenNT
BOOL CDrawApp::InitInstance()
{
	// Initialize OLE 2.0 libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

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

	Enable3dControls();     // enable 3d controls in dialogs
	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.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CDrawDoc),
		RUNTIME_CLASS(CMainFrame),
		RUNTIME_CLASS(CDrawView));
	pDocTemplate->SetContainerInfo(IDR_SEPEDTTYPE_CNTR_IP);
	AddDocTemplate(pDocTemplate);

	// enable file manager drag/drop and DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes();

	// simple command line parsing
	if (m_lpCmdLine[0] == '\0')
	{
		// create a new (empty) document
		OnFileNew();
	}
	else
	{
		// open an existing document
		OpenDocumentFile(m_lpCmdLine);
	}

	m_pMainWnd->DragAcceptFiles();

	OnIdle(0);  // updates buttons before showing the window

	return TRUE;
}
示例#7
0
//================================================================
// Function : COcafApp::OnFileOpen()
///Purpose  : 
//================================================================
void COcafApp::OnFileOpen() 
{
	CFileDialog aDlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,
	   "OCAFSample(STD) (*.std)|*.std|OCAFSample(XML) (*.xml)|*.xml|OCAFSample(Binary) (*.cbf)|*.cbf||");

	if (aDlg.DoModal() != IDOK) 
        return;


    int strLength = aDlg.GetPathName().GetLength()+1;
	LPTSTR lpszFileName = new TCHAR[strLength];
	strcpy_s(lpszFileName, strLength, aDlg.GetPathName() );
	
	OpenDocumentFile(lpszFileName);
}
示例#8
0
void CWordPadApp::OnFileOpen()
{
	// prompt the user (with all document templates)
	CString newName;
	int nType = RD_DEFAULT;
	if (!PromptForFileName(newName, AFX_IDS_OPENFILE,
	  OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, TRUE, &nType))
		return; // open cancelled

	if (nType == RD_OEMTEXT)
		m_bForceOEM = TRUE;
	OpenDocumentFile(newName);
	m_bForceOEM = FALSE;
	// if returns NULL, the user has already been alerted
}
示例#9
0
文件: APPUI.CPP 项目: willpoon/wcwp
BOOL CWinApp::OnOpenRecentFile(UINT nID)
{
    ASSERT_VALID(this);
    ASSERT(m_pRecentFileList != NULL);

    ASSERT(nID >= ID_FILE_MRU_FILE1);
    ASSERT(nID < ID_FILE_MRU_FILE1 + (UINT)m_pRecentFileList->GetSize());
    int nIndex = nID - ID_FILE_MRU_FILE1;
    ASSERT((*m_pRecentFileList)[nIndex].GetLength() != 0);

    TRACE2("MRU: open file (%d) '%s'.\n", (nIndex) + 1,
           (LPCTSTR)(*m_pRecentFileList)[nIndex]);

    if (OpenDocumentFile((*m_pRecentFileList)[nIndex]) == NULL)
        m_pRecentFileList->Remove(nIndex);

    return TRUE;
}
示例#10
0
BOOL CDocTemplateEx::OnOpenRecentFile(UINT nID)
{
	ASSERT_VALID(this);
	ASSERT(m_pRecentFileList != NULL);

	ASSERT(nID >= m_nMenuId);
	ASSERT(nID < m_nMenuId + (UINT)m_pRecentFileList->GetSize());
	int nIndex = nID - m_nMenuId;
	ASSERT((*m_pRecentFileList)[nIndex].GetLength() != 0);

	TRACE2("MRU: open file (%d) '%s'.\n", (nIndex) + 1,
			(LPCTSTR)(*m_pRecentFileList)[nIndex]);

	if (OpenDocumentFile((*m_pRecentFileList)[nIndex]) == NULL)
		m_pRecentFileList->Remove(nIndex);

	return TRUE;
}
示例#11
0
BOOL CWinApp::ProcessShellCommand( CCommandLineInfo &rCmdInfo )
/*************************************************************/
{
    if( rCmdInfo.m_nShellCommand == CCommandLineInfo::FileNew ) {
        if( !OnCmdMsg( ID_FILE_NEW, 0, NULL, NULL ) ) {
            OnFileNew();
        }
        if( m_pMainWnd == NULL ) {
            return( FALSE );
        }
    } else if( rCmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen ||
               rCmdInfo.m_nShellCommand == CCommandLineInfo::FilePrint ||
               rCmdInfo.m_nShellCommand == CCommandLineInfo::FilePrintTo ) {
        AfxMessageBox(rCmdInfo.m_strFileName);
        CDocument *pDoc = OpenDocumentFile( rCmdInfo.m_strFileName );
        if( pDoc == NULL ) {
            return( FALSE );
        }
    } else if( rCmdInfo.m_nShellCommand == CCommandLineInfo::FileDDE ) {
        m_nCmdShow = SW_HIDE;
    }
    return( TRUE );
}
示例#12
0
   void  GuiTests::Test_DiffDocument()
   {
      if (!ScriptDocument::GetActive())
         return;

      // Get document/template
      auto doc = ScriptDocument::GetActive();
      auto templ = theApp.GetDocumentTemplate<DiffDocTemplate>();

      // Create different version
      FileStream fs(L"D:\\My Projects\\XStudio2\\Files\\add.dynamic.logic.diff", FileMode::OpenExisting, FileAccess::Read);
      auto bytes = fs.ReadAllBytes();
      auto alt = GuiString::Convert((char*)bytes.get(), CP_ACP);

      /*auto alt = doc->GetAllText();
      alt.erase(50, 15);
      alt.insert(140, L"NEW NEW NEW NEW NEW");
      alt.insert(70, L"NEW NEW NEW NEW NEW");
      alt.insert(10, L"NEW NEW NEW NEW NEW");*/

      // Open document
      templ->OpenDocumentFile(*doc, alt);
   }
示例#13
0
BOOL CTheApp::InitInstance()
{
	Enable3dControls();
	SetDialogBkColor();
	LoadStdProfileSettings();

	// start RSI
	if (rsiInit())
		return FALSE;
	
	//rsiGetUser(&user);

	AddDocTemplate
	(
		new CMultiDocTemplate(IDR_TEXTTYPE,
		RUNTIME_CLASS(CPadDoc),
		RUNTIME_CLASS(CMDIChildWnd),
		RUNTIME_CLASS(CPadView))
	);
	m_pMainWnd = new CMainFrame;
	((CFrameWnd*)m_pMainWnd)->LoadFrame(IDR_MAINFRAME);
	m_pMainWnd->ShowWindow(m_nCmdShow);

	// enable file manager drag/drop and DDE Execute open
	m_pMainWnd->DragAcceptFiles();
	EnableShellOpen();
	RegisterShellFileTypes();

#ifndef _MAC
	// open file specified on command line
	if (m_lpCmdLine[0])
		OpenDocumentFile(m_lpCmdLine);
#endif
		
	return TRUE;
}
示例#14
0
文件: wed.cpp 项目: akavel/wed-editor
BOOL 	CWedApp::InitInstance()

{
	CString str;
	char *ptr;

	//SetDialogBkColor(0x00ff0000, 0xffffff);

	WaitCursor = AfxGetApp()->LoadStandardCursor(IDC_WAIT);
	NormalCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);

	GetModuleFileName(AfxGetInstanceHandle(), approot, MAX_PATH);

	CTime ct = CTime::GetCurrentTime();
	CString datestr = ct.Format("%A, %B %d, %Y - %I:%M %p");

	C2N();
	P2N("\r\nStarted WED application at %s\r\n", datestr);
	//P2N("AppRoot=%s\r\n", approot);

	//CString desktop;
	//GetSpecialFolder(CSIDL_DESKTOPDIRECTORY, desktop);
	//desktop += "wed";

	//P2N("Desktop special: %s\r\n", desktop);

	// Create initial desktop xcpt folder
	//if(access(desktop, 0) == -1)
	//	{
	//	P2N("Making %s\r\n", desktop);
	//	//message("Created desktop folder.");
	//	_mkdir(desktop);
	//	}

	ptr = strrchr(approot, '\\');
	if(ptr)
		*(ptr+1) = '\0';

	//dataroot = (CString)approot + "wed\\";

	GetSpecialFolder(CSIDL_PERSONAL, dataroot);
	dataroot += "WedData\\";

	P2N("Wed user data directory: %s\r\n", dataroot);

	if(access(dataroot, 0))
		{
		if(mkdir(dataroot))
			{
			//P2N("Cannot create data root dir\r\n");
			}
		}

	//////////////////////////////////////////////////////////////////////
	// Create data dirs

	str = dataroot; str += "data";

	// Check if data dir is in order
	if(access(str, 0))
		{
		if(mkdir(str))
			{
			//P2N("Cannot create data dir\r\n");
			}
		}
	str = dataroot; str += "macros";
	// Check if data dir is in order
	if(access(str, 0))
		{
		if(mkdir(str))
			{
			//P2N("Cannot create macro dir\r\n");
			}
		}
	str = dataroot; str += "holdings";
	// Check if data dir is in order
	if(access(str, 0))
		{
		if(mkdir(str))
			{
			//P2N("Cannot create holders dir\r\n");
			}
		}
	str = dataroot; str += "coco";
	// Check if coco dir is in order
	if(access(str, 0))
		{
		if(mkdir(str))
			{
			//P2N("Cannot create coco dir\r\n");
			}
		}
	str = dataroot; str += "backup";
	// Check if state dir is in order
	if(access(str, 0))
		{
		if(mkdir(str))
			{
			//P2N("Cannot create state dir\r\n");
			}
		}
	str = dataroot; str += "template";
	// Check if state dir is in order
	if(access(str, 0))
		{
		if(mkdir(str))
			{
			//P2N("Cannot create template dir\r\n");
			}
		}

	//P2N("Started Application: %s %s\r\n",
	//		m_pszAppName, approot);

	getcwd(str.GetBuffer(MAX_PATH), MAX_PATH);
	str.ReleaseBuffer();

	//P2N("Initial dir: %s\r\n", str);

	if (!AfxSocketInit())
		{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
		}

	// Initialize OLE 2.0 libraries
	if (!AfxOleInit())
		{
		AfxMessageBox("Failed OLE library init, OLE functions will not be available");
		}
	AfxEnableControlContainer();

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

	// Change the registry key under which our settings are stored.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.

	SetRegistryKey(_T("RobotMonkeySoftware"));

	LoadStdProfileSettings(6);  // 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.

	pDocTemplate = new CMultiDocTemplate(
			IDR_WEDTYPE,
				RUNTIME_CLASS(CWedDoc),
					RUNTIME_CLASS(CChildFrame), // custom MDI child frame
						RUNTIME_CLASS(CWedView));
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	pMainFrame = new CMainFrame;

	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;

	// Global
	m_pMainWnd = pMainFrame;

	// Get resources we need:
	// 1. Fonts

	CString fontname = 	GetProfileString(strConfig, strFontName, "Courier");
	int size    =  		GetProfileInt(strConfig,  strFontSize, 10);
	int weight  =  		GetProfileInt(strConfig, strFontWeight, 0);
	int italic  =  		GetProfileInt(strConfig, strFontItalic, 0);

	if(!ff.CreateFont(size, 0, 0, 0, weight, italic, 0, 0,
				0, 0, 0, 0, FIXED_PITCH, fontname))
		{
		AfxMessageBox("Cannot set font");
		}
	if(!ff.GetLogFont(&fflf))
		{
		AfxMessageBox("Cannot get font parameters");
		}

	// 2. Printer fonts
	if(!pp.CreateFont(80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                FF_MODERN, "system"))
		{
		MessageBox(NULL, "Cannot set font", "Wed", 0);
		}
	if(!pp.GetLogFont(&pplf))
		{
		MessageBox(NULL, "Cannot get font parameters", "Wed", 0);
		}

	// Get colors
	bgcol 	=  GetProfileInt(strConfig,  strColorBg, 	bgcol);
	fgcol 	=  GetProfileInt(strConfig,  strColorFg, 	fgcol);
	selcol 	=  GetProfileInt(strConfig,  strColorSel , 	selcol );
    cselcol =  GetProfileInt(strConfig,  strColorCSel, 	cselcol);
    cadd    =  GetProfileInt(strConfig,  strColorAdd , 	cadd   );
    cdel    =  GetProfileInt(strConfig,  strColorDel , 	cdel   );
    cchg    =  GetProfileInt(strConfig,  strColorChg , 	cchg   );
    comm    =  GetProfileInt(strConfig,  strColorComm, 	comm   );
    srcc    =  GetProfileInt(strConfig,  strColorSrc , 	srcc   );
    clng    =  GetProfileInt(strConfig,  strColorLong, 	clng   );

	// Bimaps
	caret.LoadBitmap(IDB_BITMAP1);
    backwrap  =  GetProfileInt(strConfig,  strBackWrap , 0);
    Tab2Space =  GetProfileInt(strConfig,  strTab2Space, 0);
    tabstop   =  GetProfileInt(strConfig,  strTabStop, 4);

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

	if(cmdInfo.m_strFileName != "")
		{
		comline = TRUE;
		OpenDocumentFile(cmdInfo.m_strFileName);
		}
	else
		{
   		// DON'T display a new MDI child window during startup!!!
		cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
		}

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

	// Key settings

	// Figure out last usage time ...
	int last = GetProfileInt(strConfig, "strLastUsage", 0);
	use = GetProfileInt(strConfig, "strUsage", 	0);
	//P2N("Usage count %d \r\n", use);

	// First time ever, display initial file
	if(!use)
		{
		OpenDocumentFile("Welcome.txt");
		comline  = TRUE;
		if(currentedit)
			{
			}
		}

	use++;
	CTime tt = CTime::GetCurrentTime();
	CTimeSpan t(tt.GetTime() - (time_t)last);

	//P2N("Time diff of last fire %d -- %d \r\n",
	//	t.GetTotalSeconds(), (int)tt.GetTime());

	YieldToWin() ;

	// Show sign banner only if more then 60 seconds passed
	//if(t.GetTotalSeconds() > 60)
		{
		spp.Create(IDD_DIALOG5, NULL);
 		spp.Show();
		}

	YieldToWin() ;

	//if(GetKeyState(VK_SHIFT))
	//	{
	//	AfxMessageBox("SHIFT HELD on startup\r\n");
	//	return(TRUE);
	//	}

	// The main window has been initialized ...
	// Show and update it.
	m_nCmdShow = GetProfileInt(strConfig, "WindowState", 1);
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	int num = GetProfileInt(strSection, strIntItem, 0);

	// De-serialize hash map
	CMap < int, int&, CString, CString& > HashMap;
	CFile cf;
	CString fname;
	fname.Format("%s%s", dataroot, "macros\\hashes.000");
	if( cf.Open( fname, CFile::modeRead))
		{
		CArchive ar( &cf, CArchive::load);
		HashMap.Serialize(ar);
		}
	else
		{
		//P2N("Cannot open hash map file: %s\r\n", fname);
		}
	POSITION rpos;
	rpos = HashMap.GetStartPosition();
	while(rpos)
		{
		int key;
		CString val;
		HashMap.GetNextAssoc(rpos, key, val);
		//P2N("In Hashlist: %x %s\r\n", key, val);
		}

	if(!comline)
		{
		// Reopen old documents:
		CString buf2, file;
		for(int count1 = 1; count1 <= num; count1++)
			{
			CWedDoc *doc = NULL;
			buf2.Format("%d", count1);
			file = GetProfileString(strSection, strStringItem + buf2);
			//P2N("Reloading file: '%s' at %s\r\n", file, buf2);

			// Empty file, no action
			if(file == "")
				continue;

			doc = (CWedDoc*)OpenDocumentFile(file);

			if(YieldToWinEx())
				break;

			//P2N("After Reloading file: %s at %s\r\n", file, buf2);

			if(doc)
				{
				ASSERT_VALID(doc);

				// Document had an error
				if(doc->ssel.m_err)
					break;

				int lrow, lcol;

				lrow = GetProfileInt(strSection,
					strStringItem + buf2 + "row", 0);

				lcol = GetProfileInt(strSection,
					strStringItem + buf2 + "col", 0);

				// Update cursor positions ...
				POSITION pos = doc->GetFirstViewPosition();
				for(;;)
					{
					if(!pos)
						break;
					CWedView *cv = (CWedView*)doc->GetNextView(pos);
					if(cv)
						{
						ASSERT_VALID(cv);
						cv->row = lrow;  cv->col = lcol;
						cv->SyncCaret();
						YieldToWin() ;
						}
					}
				// This happens after load, set it again
				doc->UpdateAllViews(NULL);
				}
			}

	// Try figure out last current directory
	int idx;
	if( (idx = file.ReverseFind('\\')) != -1)
		{
		file = file.Left(idx + 1);
		}
	P2N("CWedApp::InitInstance Chdir: '%s'\r\n", file);
	_chdir(file);
	targdir = srcdir = file;
    }

	message ("Loading macros ...");
	LoadMacros();

	message ("Loading holdings ...");
	LoadHoldings();

	message("");

	return TRUE;
}
示例#15
0
BOOL CKLinePrintApp::InitInstance()
{
#if 0

	//	维持网络连接/会话
	Net net("192.168.1.1:8080");
	net.start();

	//	执行命令
	CommandExecutor ce(&net);
	string ret = ce.Execute("login");

	//	接收数据
	DataHandler dh(&net);
	

	//	初始化网络连接
	//	创建线程,发起并维持连接
	//	

	CLoginDialog loginDlg;

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

	CommandExecutor ce();

	string result = ce.Execute("login:oscar,12345,sr");



#endif

	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();

	// 初始化 OLE 库
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	AfxEnableControlContainer();
	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("Oscar"));
	LoadStdProfileSettings(4);  // 加载标准 INI 文件选项(包括 MRU)

	InitContextMenuManager();

	InitKeyboardManager();

	// 注册应用程序的文档模板。文档模板
	// 将用作文档、框架窗口和视图之间的连接
	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CKLinePrintDoc),
		RUNTIME_CLASS(CMainFrame),       // 主 SDI 框架窗口
		RUNTIME_CLASS(CKLinePrintView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	// 分析标准外壳命令、DDE、打开文件操作的命令行
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// 调度在命令行中指定的命令。如果
	// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	CalendarGenerator cg;
	cg.Generate("C:\\FutureData\\ZZ", m_cal);

	//	读入账户/品种信息
	EXCHANGE.SetBalance(Utility::ReadBalance());
	TP = Utility::ReadExchangeConfig();

	//	设置默认交易日志文件
	EXCHANGE.SetLogFile(Utility::GetProgramPath() + "log\\manual.log.txt");

	srand(time(0));

	//	加载回放配置并生成日历
	m_PlaybackConfig = Utility::ReadPlaybackConfig();
	LoadPlaybackCalendar(m_PlaybackConfig);

	//	自动打开上次的文件
	char path[MAX_PATH];

	::GetPrivateProfileStringA("Files","Current","", 
							path, sizeof(path), 
							(Utility::GetProgramPath() + "klinep.ini").c_str());

	CKLinePrintDoc* pDoc = NULL;

	if(strlen(path))
	{
		pDoc = (CKLinePrintDoc*)OpenDocumentFile(CString(path));
		pDoc->LoadNextDay();
	}

	// 唯一的一个窗口已初始化,因此显示它并对其进行更新
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();
	// 仅当具有后缀时才调用 DragAcceptFiles
	//  在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生
	return TRUE;
}
示例#16
0
BOOL CMyglApp::InitInstance()
{

#ifdef _KATMAI
	if (!KatmaiInit()) {
#if 0
		::MessageBox(NULL, "This version requires an Intel Pentium III processor \n Program will be terminated"  
			, _PROGRAM " System Message" , MB_OK | MB_ICONINFORMATION | MB_SYSTEMMODAL | MB_TOPMOST);

		//AfxMessageBox("This version requires an Intel Katmai processor \n Program will be terminated ");
		return FALSE;
#endif

	}
#endif

 	/*
	// Initialize COM Library (for RSX)
	*/
	m_coResult = CoInitialize(NULL);

#ifdef _COM
	// Initialize the ATL Module
	_Module.Init(ObjectMap,m_hInstance);

#endif


	// 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.
	m_ChoosePixelFormat = 0;
	m_ActiveView = 0;


#ifndef _NSPLUGIN
	Enable3dControls();	// VC 2.0
#endif

	//SetDialogBkColor();	     // set dialog background color to gray
	LoadStdProfileSettings();  // Load standard INI file options (including MRU)


	GReporter::SetCurrent(new GReporter);

    // make sure Gv VRML  database is init !!!
    GvDB::init();

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

   AddDocTemplate(pTemplate=new CSingleDocTemplate(IDR_MAINFRAME,
			RUNTIME_CLASS(CMyglDoc),
			RUNTIME_CLASS(CMainFrame),     // main SDI frame window
			RUNTIME_CLASS(CMyglView)));

	// command line processing here
	{
	CString fileArg;
	
	// there is a utility function 
	if (m_lpCmdLine[0] != '\0')
	{
		char *p,*p1;

		p=m_lpCmdLine;
		while (*p) {

		 while (isspace(*p)) p++;
		 
		 if ((*p == '-') || (*p == '/')) { // Option start
		 p++;
		 switch (*p++) {
		 case 'X' :
		 case 'x' :
				m_ChoosePixelFormat = 1;
				break;
		 default :
			Reporter.Error("Unknown commandline option '%c' in %s",*p,m_lpCmdLine);
			break;
		 }
		}
		else {	// file argument
#if 0
			if (fileArg.GetLength()>0) {
				Reporter.Error("too many commandline arguments in %s",m_lpCmdLine);
 				while (!isspace(*p)) { if (!*p) break;p++;}
			}		 
		 	else while (!isspace(*p)) {
		   		if (!*p) break;
		   		fileArg += *p;
		   		p++;
		 	}
#else
			if (*p == '"') {
			    p++;
				while (*p != '"') {
		   			if (!*p) break;
		   			fileArg += *p;
		   			p++;
		 		}
				if (*p == '"') p++;
			    while (isspace(*p)) p++;
				break;
				// to do: rest of commandline
			}
			else 
			   fileArg = p;
			break;
#endif

			}
		
		}
	}

	if (fileArg.GetLength() > 0)
	 	OpenDocumentFile(fileArg);	// directly load a file
	else 
	  // create a new (empty) document
	  OnFileNew();
	}


	RegisterShellFileTypes();

	// register all extensions
	{
	CString strFilterExt,strFileTypeName; //strFileTypeId
	if (pTemplate->GetDocString(strFileTypeId,
	   CDocTemplate::regFileTypeId) && !strFileTypeId.IsEmpty())
		{
			// enough info to register it
			if (!pTemplate->GetDocString(strFileTypeName,
			   CDocTemplate::regFileTypeName))
				strFileTypeName = strFileTypeId;    // use id name

	}

	} // for all extensions
	

	// enable file manager drag/drop and DDE Execute open
	m_pMainWnd->DragAcceptFiles();

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

#ifdef _EVALUATION
    // increment runcount 
    int runCount = GetProfileInt("GLView","RunCount",0);
    runCount++;
    WriteProfileInt("GLView","RunCount",runCount);
#endif

    int version = GetProfileInt("GLView","Version",0);
    if (version == 0 || version<_VERSION_INT) {
        version = _VERSION_INT;
        WriteProfileInt("GLView","Version",version);
// Date  WriteProfileInt("GLView","Version",version);
        // increment run-count
    }
	return TRUE;
}
afx_msg void CWinHTTrackApp::OnFileNew( ) {
  OpenDocumentFile("");
}
BOOL CGrannyViewerApp::InitInstance()
{
	try {
		std::string config_file = "xml\\config.xml";

		if(!nConfig::Init(config_file)) {
			MessageBox(NULL, config_file.c_str(), "Can't Open File", MB_OK|MB_ICONERROR);
			return FALSE;
		}
	} catch (...) {
		return FALSE;
	}

	InitCommonControls();

	CWinApp::InitInstance();

	// OLE 라이브러리를 초기화합니다.
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	AfxEnableControlContainer();

	SetRegistryKey(_T("Harkon"));
	LoadStdProfileSettings(4);  
	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CGrannyViewerDoc),
		RUNTIME_CLASS(CMainFrame),
		RUNTIME_CLASS(CGrannyViewerView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	ReadConfig();

	std::string granny_file = nConfig::aos ? "xml/granny_aos.xml" : "xml/granny.xml";

	CStringArray arOpt;
	GetCmdOpt(m_lpCmdLine, arOpt);

	for (int i = 0; i < arOpt.GetSize(); i++)
	{
		//if (arOpt[i] == "-id" && (i+1) < arOpt.GetSize())
		if (arOpt[i] == "-imm")
			nConfig::useVertexArray = false;
		else
			granny_file = arOpt[i];
	}

	if (!OpenDocumentFile(granny_file.c_str()))
		return FALSE;

//	m_iModelID = -1;

	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();

	GfxLog("OpenGL Render Mode : %s\n", nConfig::useVertexArray ? "vertex array" : "immediate");

#if 0
	cGrannyFile f;
	if (!f.import("data/aa.smd"))
		return FALSE;
#endif

	return TRUE;
}
示例#19
0
BOOL CGalileoApp::InitInstance()
{
	char iometer_path[MAX_PATH];
	char *p;

	test_state = TestIdle;
	login_state = closed;

	// 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.
#if _MSC_VER < 1300
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
#endif

	//init file version strings
	GetAppFileVersionString(&m_pVersionString, &m_pVersionStringWithDebug);

	SetRegistryKey( "Intel" );	// Stores information in the registry under
								// HKEY_CURRENT_USER\Software\Intel.

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

	//
	// Check to see if the end user license agreement should be displayed.
	// If the current version is not stored in the registry, disply the EULA.
	//
#ifndef	_DEBUG
	if ( GetProfileString( "Settings", "Version" ) != m_pVersionString )
	{
		CLegalBox legalDlg;					// Display EULA.
		if ( legalDlg.DoModal() == IDOK )
			// User agrees to terms, so store the version in the registry.
			WriteProfileString( "Settings", "Version", m_pVersionString );
		else
			return FALSE;	// User does not agree to terms so exit.
	}
#endif

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

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CGalileoDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CGalileoView));
	AddDocTemplate(pDocTemplate);

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);

	//
	// Pass the command line info to cmdline.ParseParam().
	// Here is the expected syntax:
	//
	// iometer ?
	// iometer [config_file [result_file [timeout_value]]]
	// iometer [/c config_file] [/r results_file] [/t timeout_value]
	//
	//    ? - show Iometer version number and command line syntax
	//
	//    config_file - the name of the Iometer configuration file to restore
	//       when Iometer starts (must be a valid .icf file)
	//
	//    results_file - the name of a writable text file to which the test
	//       results should be appended.  If the file doesn't exist, it will be
	//       created.
	//
	//    timeout_value - the number of seconds to wait for managers to log in
	//       when restoring a config file.
	//
	//    If both config_file and results_file are specified, Iometer will
	//    attempt to run the test in batch mode, requiring no user intervention
	//    to load the config file, start the tests, stop the tests (if a run time
	//    was specified in the Test Setup tab), and close Iometer.  Batch mode
	//    can be canceled by aborting the manager waiting list dialog or by
	//    manually stopping a test while it is running.
	//
	CWinApp::ParseCommandLine(cmdline);

	// If the command line parser had any trouble, kill the program.
	if ( cmdline.m_bFail )
		return FALSE;

	if ( !OnCmdMsg(ID_FILE_NEW, 0, NULL, NULL) )
	{
		OnFileNew();
	}
	if (m_pMainWnd == NULL)
	{
		ErrorMessage("Error creating application's main frame.  "
			"Please report this as an Iometer bug.");
		return FALSE;
	}

	// Fill in the local address strings.
	IdentifyLocalAddresses();

	// Set the status bar.
	CRect rect;
	m_wndStatusBar.GetWindowRect( &rect );
	int* widths;
	widths = (int*)malloc( sizeof(int) * 3 );
	widths[0] = rect.Width() - 300;
	widths[1] = rect.Width() - 150;
	widths[2] = -1;
	m_wndStatusBar.GetStatusBarCtrl().SetParts( 3, widths );
	free( widths );

	// Set status bar text.
	pView->ClearStatusBar();

	// Disable most buttons.
	pView->ButtonReset();

	// make sure CGalileoApp::OnIdle() gets called at least once in a while
	pView->SetTimer( IDLE_TIMER, IDLE_DELAY, NULL );

	// Get the full pathname for Iometer.exe.
	if ( !GetModuleFileName( NULL, iometer_path, sizeof( iometer_path ) ) )
	{
		ErrorMessage( "Could not get Iometer.exe pathname!" );

		// Set iometer_path to a null string; this will make NEW_WORKER_COMMAND
		// search for Dynamo in the current directory and $PATH
		iometer_path[0] = '\0';
	}

	// Find the last backslash in the pathname, if any
	if ( p = strrchr( iometer_path, '\\' ) )
	{
		// Terminate the string right after the last backslash, leaving
		// the full pathname of the directory containing Iometer.exe.
		p++;
		*p = '\0';
	}

	// Build the command line to launch Dynamo.  We must quote the pathname in case it 
	// contains any spaces, but the "start" command (NEW_WORKER_COMMAND) assumes the
	// first quoted argument is the window title, so we must provide it twice.
	new_manager_command_line_format = (CString) NEW_WORKER_COMMAND 
			+ "\"" + iometer_path + NEW_WORKER_EXECUTABLE + "%s\"" + " "
			+ "\"" + iometer_path + NEW_WORKER_EXECUTABLE + "\"%s";

	if ( cmdline.GetConfigFile().IsEmpty() )
	{
#ifndef	_DEBUG
		// If the default config file exists, load it.
		if ( ::GetFileAttributes(DEFAULT_CONFIG_FILE) != 0xFFFFFFFF )
		{
			OpenDocumentFile(DEFAULT_CONFIG_FILE);
		}
		else
		{
			// If no config file was specified on the command line
			// and the default config file doesn't exist, start a
			// local manager.with no command line options.
			LaunchDynamo();
		}
#endif
	}
	else
	{
		// If a config file was specified on the command line, open it
		OpenDocumentFile( cmdline.GetConfigFile() );
	}

	return TRUE;
}
示例#20
0
//////////////////////////////////////////////////////////////////////////////
// CDemoApp initialization
BOOL CDemoApp::InitInstance()
{
	// <dave> dump memory leaks
#ifdef _DEBUG
	_CrtDumpMemoryLeaks();
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
	// Standard initialization
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	LoadStdProfileSettings(9);  // 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.
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_DEMOTYPE,
		RUNTIME_CLASS(CDemoDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CDemoView));
	demoTemplate = pDocTemplate;
	AddDocTemplate(pDocTemplate);

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

	// This code replaces the MFC created menus with 
	// the Ownerdrawn versions 
	pDocTemplate->m_hMenuShared=pMainFrame->NewMenu();
	pMainFrame->m_hMenuDefault=pMainFrame->NewDefaultMenu();
	// This simulates a window being opened if you don't have
	// a default window displayed at startup
	pMainFrame->OnUpdateFrameMenu(pMainFrame->m_hMenuDefault);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
    // Alter behaviour to not open window immediately
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
	ParseCommandLine(cmdInfo);

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

#ifdef VATI_EXTENSIONS
    // init m_text by a temporary CxImage 
	CxImage *ima = new CxImage;
	ima->InitTextInfo( &m_text );
	delete ima;
    
	//recall last used font data for Text tool
    sprintf( m_text.lfont.lfFaceName, GetProfileString ( "TextTool", "lfFaceName", "Arial") );
	m_text.lfont.lfCharSet   = GetProfileInt ( "TextTool", "lfCharSet", EASTEUROPE_CHARSET ) ;
    m_text.lfont.lfWeight    = GetProfileInt ( "TextTool", "lfWeight", 0 );
    m_text.lfont.lfItalic    = GetProfileInt ( "TextTool", "lfItalic", 0 ); 
    m_text.lfont.lfUnderline = GetProfileInt ( "TextTool", "lfUnderline", 0 ); 
    m_text.fcolor = GetProfileInt ( "TextTool", "fcolor", RGB( 255,255,160 ));
    m_text.bcolor = GetProfileInt ( "TextTool", "bcolor", RGB( 32, 96, 0 ));
    m_text.opaque = GetProfileInt ( "TextTool", "opaque", 1);
    m_text.b_opacity = (float)(GetProfileInt( "TextTool", "opacity", 0 ))/(float)100.;  
    m_text.b_round   = GetProfileInt ( "TextTool", "roundradius", 25 );

	m_optJpegQuality = GetProfileInt("Options","JpegQuality",90);

	// recall if main window was maximized on last exit
    if ( GetProfileInt ( "Screen", "maximized", 0 ))
        m_nCmdShow|=SW_MAXIMIZE;
#endif;

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

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

	// Enable open from command line
	if (*m_lpCmdLine != 0)
		OpenDocumentFile(m_lpCmdLine);

	return TRUE;
}
示例#21
0
BOOL CTestCBotApp::InitInstance()
{
//////////////////////////////////////////////
//	défini les mots clefs supplémentaires
// -------------------------------------------

	CBotProgram::Init();
 
//////////////////////////////////////////////
//	défini les fonctions "show()" et "print()"
// -------------------------------------------

	CBotProgram::AddFunction("show", rShow, cShow);
	CBotProgram::AddFunction("print", rPrint, cPrint);
	CBotProgram::AddFunction("println", rPrintLn, cPrint);


///////////////////////////////////
// définie la classe globale CPoint
// --------------------------------

	m_pClassPoint	= new CBotClass("CPoint", NULL);
	// ajoute le composant ".x"
	m_pClassPoint->AddItem("x", CBotTypFloat);
	// ajoute le composant ".y"
	m_pClassPoint->AddItem("y", CBotTypFloat);

	// ajoute le constructeur pour cette classe
	m_pClassPoint->AddFunction("CPoint", rCPoint, cCPoint);

	m_pClassPointIntr	= new CBotClass("point", NULL, TRUE);
	// ajoute le composant ".x"
	m_pClassPointIntr->AddItem("x", CBotTypFloat);
	// ajoute le composant ".y"
	m_pClassPointIntr->AddItem("y", CBotTypFloat);
	// ajoute le composant ".z"
	m_pClassPointIntr->AddItem("z", CBotTypFloat);

	// ajoute le constructeur pour cette classe
	m_pClassPointIntr->AddFunction("point", rCPoint, cCPoint);

	// défini la classe "object"
	CBotClass*	pClassObject = new CBotClass( "object", NULL ) ;
	pClassObject->AddItem( "xx", CBotTypFloat );
	pClassObject->AddItem( "position", CBotTypResult( CBotTypIntrinsic, "point" ) );
	pClassObject->AddItem( "transport", CBotTypResult( CBotTypPointer, "object" ) );
	pClassObject->AddUpdateFunc( rMajObject );

	InitClassFILE();
	
	AfxEnableControlContainer();

	// Standard initialization

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

	// Change the registry key under which our settings are stored.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

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

	// Register document templates

	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_TESTCBTYPE,
		RUNTIME_CLASS(CTestCBotDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CTestCBotView));
	AddDocTemplate(pDocTemplate);

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

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

	if (m_lpCmdLine[0] == 0)
	{
		CString Filename = GetProfileString(szSection, szFilename);
		if (Filename.IsEmpty()) Filename = "TstCbot.txt";
		else OpenDocumentFile(Filename);
	}
	else
		// Dispatch commands specified on the command line
		if (!ProcessShellCommand(cmdInfo))
			return FALSE;
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();


	return TRUE;
}
示例#22
0
文件: demo.cpp 项目: Sumxx/XUI
//////////////////////////////////////////////////////////////////////////////
// CDemoApp initialization
BOOL CDemoApp::InitInstance()
{
	// <dave> dump memory leaks
#ifdef _DEBUG
	_CrtDumpMemoryLeaks();
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

#if _MSC_VER <= 1200
	// Standard initialization
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
#endif

	LoadStdProfileSettings(9);  // 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.
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_DEMOTYPE,
		RUNTIME_CLASS(CDemoDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CDemoView));
	demoTemplate = pDocTemplate;
	AddDocTemplate(pDocTemplate);

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

	// This code replaces the MFC created menus with 
	// the Ownerdrawn versions 
	pDocTemplate->m_hMenuShared=pMainFrame->NewMenu();
	pMainFrame->m_hMenuDefault=pMainFrame->NewDefaultMenu();
	// This simulates a window being opened if you don't have
	// a default window displayed at startup
	pMainFrame->OnUpdateFrameMenu(pMainFrame->m_hMenuDefault);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
    // Alter behaviour to not open window immediately
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
	ParseCommandLine(cmdInfo);

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

#ifdef VATI_EXTENSIONS
    // init m_text by a temporary CxImage 
	CxImage *ima = new CxImage;
	ima->InitTextInfo( &m_text );
	delete ima;
    
	//recall last used font data for Text tool
    _stprintf( m_text.lfont.lfFaceName, GetProfileString ( _T("TextTool"), _T("lfFaceName"), _T("Times New Roman")) );
	m_text.lfont.lfCharSet   = (BYTE)GetProfileInt ( _T("TextTool"), _T("lfCharSet"), EASTEUROPE_CHARSET ) ;
    m_text.lfont.lfWeight    = GetProfileInt ( _T("TextTool"), _T("lfWeight"), 0 );
    m_text.lfont.lfItalic    = (BYTE)GetProfileInt ( _T("TextTool"), _T("lfItalic"), 0 ); 
    m_text.lfont.lfUnderline = (BYTE)GetProfileInt ( _T("TextTool"), _T("lfUnderline"), 0 ); 
    m_text.fcolor = GetProfileInt ( _T("TextTool"), _T("fcolor"), RGB( 255,255,160 ));
    m_text.bcolor = GetProfileInt ( _T("TextTool"), _T("bcolor"), RGB(   0, 80,160 ));
    m_text.opaque = (BYTE)GetProfileInt ( _T("TextTool"), _T("opaque"), 1);
    m_text.b_opacity = (float)(GetProfileInt( _T("TextTool"), _T("opacity"), 0 ))/(float)100.;  
    m_text.b_round   = (BYTE)GetProfileInt ( _T("TextTool"), _T("roundradius"), 25 );
    m_text.smooth    = (BYTE)GetProfileInt ( _T("TextTool"), _T("antialias"), 1 );

	m_optJpegQuality = GetProfileInt(_T("Options"),_T("JpegQualityI"),90) + 0.001f * GetProfileInt(_T("Options"),_T("JpegQualityF"),0);
	m_optJpegOptions = GetProfileInt(_T("Options"),_T("JpegOptions"),0);

	m_optRawOptions = GetProfileInt(_T("Options"),_T("RawOptions"),0);

	nDocType = GetProfileInt(_T("General"),_T("DocType"),0);

	BCMenu::SetMenuDrawMode(GetProfileInt(_T("General"),_T("MenuStyle"),1));

	m_FloodColor.rgbBlue = 255;
	m_FloodColor.rgbGreen = 255;
	m_FloodColor.rgbRed = 255;
	m_FloodColor.rgbReserved = 0;
	m_FloodTolerance = 0;
	m_FloodOpacity = 255;
	m_FloodSelect = 0;

	int i;
	for(i=0;i<25;i++) m_Filters.Kernel5x5[i]=1;
	for(i=0;i<9;i++) m_Filters.Kernel3x3[i]=1;
	m_Filters.kSize = 3;
	m_Filters.kBias = 0;
	m_Filters.kDivisor = 9;

	m_Filters.RotateAngle = 12.345f;
	m_Filters.RotateMethod = 1;
	m_Filters.RotateOverflow = 0;
	m_Filters.RotateKeepsize = 1;

	m_Filters.ResampleSizemode = 1;
	m_Filters.ResampleFactor = 2;
	m_Filters.ResampleW = 100;
	m_Filters.ResampleH = 100;
	m_Filters.ResampleKeepRatio = 1;
	m_Filters.ResampleMethod = 2;

	m_Filters.SkewPivotX = 0;
	m_Filters.SkewPivotY = 0;
	m_Filters.SkewX =  5.5f;
	m_Filters.SkewY = -5.0f;
	m_Filters.SkewInterp = 1;

	m_Filters.DitherMethod = 0;

	m_Filters.ThreshLevel = 128;
	m_Filters.ThreshPreserveColors = 0;

	m_Filters.ColorMode = 0;
	m_Filters.ColorHSL.rgbBlue = 50;
	m_Filters.ColorHSL.rgbGreen = 12;
	m_Filters.ColorHSL.rgbRed = 50;
	m_Filters.ColorHSL.rgbReserved = 0;
	m_Filters.ColorBlue = -50;
	m_Filters.ColorGreen = 0;
	m_Filters.ColorRed = 50;
	m_Filters.ColorSolarLevel = 128;
	m_Filters.ColorSolarLink = 1;

	m_Filters.GammaLevel = 1.23f;
	m_Filters.GammaR = 0.9f;
	m_Filters.GammaG = 1.1f;
	m_Filters.GammaB = 1.2f;
	m_Filters.GammaLink = 0;

	m_Filters.IncBppBPP = 24;
	m_Filters.DecBppBPP = 4;
	m_Filters.DecBppPalMethod = 1;
	m_Filters.DecBppErrDiff = 0;
	m_Filters.DecBppLimitColors = 0;
	m_Filters.DecBppMaxColors = 256;

	m_Filters.CanvasMode = 0;
	m_Filters.CanvasW = 800;
	m_Filters.CanvasH = 600;
	m_Filters.CanvasLeft = 20;
	m_Filters.CanvasRight = 20;
	m_Filters.CanvasTop = 10;
	m_Filters.CanvasBottom = 10;
	m_Filters.CanvasCenterH = 1;
	m_Filters.CanvasCenterV = 1;
	m_Filters.CanvasKeepRatio = 0;
	m_Filters.CanvasUseImageBkg = 0;
	m_Filters.CanvasBkg = RGB(255,255,255);

	m_Filters.ShadowX = -5;
	m_Filters.ShadowY = 5;
	m_Filters.ShadowR = 7;
	m_Filters.ShadowColor = RGB(0,0,0);
	m_Filters.ShadowBkg = RGB(255,255,255);
	m_Filters.ShadowIntensity = 128;
	m_Filters.ShadowRelative = 0;

	// recall if main window was maximized on last exit
    if ( GetProfileInt ( _T("Screen"), _T("maximized"), 0 ))
        m_nCmdShow|=SW_MAXIMIZE;
#endif;

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

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

	// Register our Clipboard format name
	m_CF = ::RegisterClipboardFormat(_T("CF_CXIMAGE"));

	// Enable open from command line
	if (*m_lpCmdLine != 0)
		OpenDocumentFile(m_lpCmdLine);

	return TRUE;
}
示例#23
0
文件: bibedt.cpp 项目: stievie/bibedt
BOOL CBibedtApp::OnDDECommand(LPTSTR lpszCommand)
{
	// Server: bibedt
	// Topic: System
	if (CWinApp::OnDDECommand(lpszCommand))
		return TRUE;

   // Handle any DDE commands recognized by your application
   // and return TRUE.  See implementation of CWinApp::OnDDEComand
   // for example of parsing the DDE command string.

	CString	strCommand(lpszCommand);
	CString	strFileName(lpszCommand);	

	CString	itemKey;
	CMainFrame* main = dynamic_cast<CMainFrame*>(AfxGetMainWnd());
	if (main == NULL)
		return FALSE;
	CBibedtDoc* doc = dynamic_cast<CBibedtDoc*>(main->GetActiveDocument());
	if (doc == NULL)
		return FALSE;
	int	nStart, nEnd;
	if (strCommand.Left(7).CompareNoCase(_T("[goto(\"")) == 0) {
		// handle goto command => [goto("filepath", "itemkey")]

		// get file name
		nStart = strCommand.Find(_T('"'));
		nEnd = strCommand.Find(_T('"'), nStart + 1);
		if (nStart == -1 || nEnd == -1 || nEnd - nStart <= 1)
			return FALSE;

		strFileName = strCommand.Mid(nStart + 1, nEnd - (nStart + 1));

		// get key
		nStart = strCommand.Find(_T('"'), nEnd + 1);
		nEnd = strCommand.Find(_T('"'), nStart + 1);
		if (nStart == -1 || nEnd == -1 || nEnd - nStart <= 1)
			return FALSE;

		itemKey = strCommand.Mid(nStart + 1, nEnd - (nStart + 1));

		// open the document
		OpenDocumentFile(strFileName);
		doc->SetSelected(itemKey);
		return TRUE;
	} else if (strCommand.Left(8).CompareNoCase(_T("[focus(\"")) == 0) {
		// [focus("key")]
		// get key
		nStart = strCommand.Find(_T('"'));
		nEnd = strCommand.Find(_T('"'), nStart + 1);
		if (nStart == -1 || nEnd == -1 || nEnd - nStart <= 1)
			return FALSE;
		itemKey = strCommand.Mid(nStart + 1, nEnd - (nStart + 1));
		doc->SetSelected(itemKey);
		return TRUE;
	} else if (strCommand.Left(7).CompareNoCase(_T("[find(\"")) == 0) {
		// [find("str")]
		nStart = strCommand.Find(_T('"'));
		nEnd = strCommand.Find(_T('"'), nStart + 1);
		if (nStart == -1 || nEnd == -1 || nEnd - nStart <= 1)
			return FALSE;
		itemKey = strCommand.Mid(nStart + 1, nEnd - (nStart + 1));
		main->SetQuicksearchText(itemKey);
		doc->DoQuickSearch(itemKey, main->GetQuicksearchFields(), TRUE);
		return TRUE;
	} else if (strCommand.Left(9).CompareNoCase(_T("[filter(\"")) == 0) {
		// [filter("name")]
		nStart = strCommand.Find(_T('"'));
		nEnd = strCommand.Find(_T('"'), nStart + 1);
		if (nStart == -1 || nEnd == -1 || nEnd - nStart <= 1)
			return FALSE;
		itemKey = strCommand.Mid(nStart + 1, nEnd - (nStart + 1));
		CBibItem* filter = doc->m_BibFile->Find(STR_FILTER);
		if (filter) {
			CField* flt = filter->Find(itemKey);
			if (flt) {
				main->SelectFilter(flt);
				doc->SetFilter(flt);
				return TRUE;
			}
		}
	}

   // Return FALSE for any DDE commands you do not handle.
   return FALSE;
}
示例#24
0
BOOL CMakeSetConfigApp::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);

	CWinAppEx::InitInstance();


	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	EnableTaskbarInteraction(FALSE);

	// AfxInitRichEdit2() is required to use RichEdit control	
	// AfxInitRichEdit2();

	// 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("CoolFormat"));
	LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
	SetRegistryBase(_T("Settings"));

	InitContextMenuManager();

	InitKeyboardManager();

	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CMakeSetConfigDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CMakeSetConfigView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);


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



	// Dispatch commands specified on the command line.  Will return FALSE if
	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The one and only window has been initialized, so show and update it
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();

	if (m_pRecentFileList && m_pRecentFileList->GetSize() > 0)
	{
		if (!m_pRecentFileList->m_arrNames[0].IsEmpty())
		{
			OpenDocumentFile(m_pRecentFileList->m_arrNames[0]);
		}
	}
	return TRUE;
}
示例#25
0
BOOL CWinApp::ProcessShellCommand(CCommandLineInfo& rCmdInfo)
{
	BOOL bResult = TRUE;
	switch (rCmdInfo.m_nShellCommand)
	{
	case CCommandLineInfo::FileNew:
		if (!AfxGetApp()->OnCmdMsg(ID_FILE_NEW, 0, NULL, NULL))
			OnFileNew();
		if (m_pMainWnd == NULL)
			bResult = FALSE;
		break;

		// If we've been asked to open a file, call OpenDocumentFile()

	case CCommandLineInfo::FileOpen:
		if (!OpenDocumentFile(rCmdInfo.m_strFileName))
			bResult = FALSE;
		break;

		// If the user wanted to print, hide our main window and
		// fire a message to ourselves to start the printing

	case CCommandLineInfo::FilePrintTo:
	case CCommandLineInfo::FilePrint:
		m_nCmdShow = SW_HIDE;
		ASSERT(m_pCmdInfo == NULL);
		OpenDocumentFile(rCmdInfo.m_strFileName);
		m_pCmdInfo = &rCmdInfo;
		m_pMainWnd->SendMessage(WM_COMMAND, ID_FILE_PRINT_DIRECT);
		m_pCmdInfo = NULL;
		bResult = FALSE;
		break;

		// If we're doing DDE, hide ourselves

	case CCommandLineInfo::FileDDE:
		m_pCmdInfo = (CCommandLineInfo*)m_nCmdShow;
		m_nCmdShow = SW_HIDE;
		break;

	// If we've been asked to unregister, unregister and then terminate
	case CCommandLineInfo::AppUnregister:
		{
			UnregisterShellFileTypes();
			BOOL bUnregistered = Unregister();

			// if you specify /EMBEDDED, we won't make an success/failure box
			// this use of /EMBEDDED is not related to OLE

			if (!rCmdInfo.m_bRunEmbedded)
			{
				if (bUnregistered)
					AfxMessageBox(AFX_IDP_UNREG_DONE);
				else
					AfxMessageBox(AFX_IDP_UNREG_FAILURE);
			}
			bResult = FALSE;    // that's all we do

			// If nobody is using it already, we can use it.
			// We'll flag that we're unregistering and not save our state
			// on the way out. This new object gets deleted by the
			// app object destructor.

			if (m_pCmdInfo == NULL)
			{
				m_pCmdInfo = new CCommandLineInfo;
				m_pCmdInfo->m_nShellCommand = CCommandLineInfo::AppUnregister;
			}
		}
		break;
	}
	return bResult;
}
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;
}