Exemple #1
0
bool CMainFrame::MakeWave(const WAVEGEN_PARMS& Parms)
{
	POSITION	pos = theApp.GetFirstDocTemplatePosition();
	CDocTemplate	*pTpl = theApp.GetNextDocTemplate(pos);
	CWaveShopDoc	*pDoc = DYNAMIC_DOWNCAST(CWaveShopDoc, pTpl->CreateNewDocument());
	if (pDoc == NULL)
		return(FALSE);
	bool	retc, canceled;
	{
		CProgressDlg	ProgDlg;
		if (!ProgDlg.Create())	// create progress dialog
			AfxThrowResourceException();
		ProgDlg.SetWindowText(LDS(IDS_MAIN_GENERATING_AUDIO));
		retc = CWaveGenDlg::MakeWave(Parms, pDoc->m_Wave, &ProgDlg);
		canceled = ProgDlg.Canceled();
	}	// destroy progress dialog
	if (!retc) {	// if generation failed
		if (!canceled)	// if user canceled
			AfxMessageBox(IDS_MAIN_CANT_MAKE_WAVE);
		return(FALSE);
	}
	CDocument	*pEmptyDoc = pTpl->OpenDocumentFile(NULL);	// create new view
	if (pEmptyDoc == NULL || m_View == NULL)
		return(FALSE);
	CString	title = pEmptyDoc->GetTitle();
	pEmptyDoc->RemoveView(m_View);	// remove empty document from view
	pDoc->SetTitle(title);	// copy empty document's title to generated document
	pDoc->AddView(m_View);	// add generated document to view
	m_View->OnInitialUpdate();
	OnActivateView(m_View);
	// view is still linked to empty document's undo manager; must relink
	m_View->SetUndoManager(&pDoc->m_UndoMgr);	// link view to undo manager
	pDoc->m_UndoMgr.SetRoot(m_View);	// link undo manager to view
	return(TRUE);
}
Exemple #2
0
int OpenPocket(   const vector<CRossPocketItem>& UnitNos,
			  CString    Title) 
{

	CDocTemplate* tmpl = GetRossPocketTemplate();;

	CDocument* pDocument = tmpl->CreateNewDocument();

	if (pDocument == NULL)
	{
		TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		return false;
	}

    ASSERT_VALID(pDocument);

	pDocument->m_bAutoDelete = FALSE;   // don't destroy if something goes wrong
	CFrameWnd* pFrame = tmpl->CreateNewFrame(pDocument, NULL);
	pDocument->m_bAutoDelete = TRUE;
	if (pFrame == NULL)
	{
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		delete pDocument;       // explicit delete on error
		return FALSE;
	};

	ASSERT_VALID(pFrame);

	pDocument->SetPathName(CString("An entry subset by  ")+Title);
	

	// open an existing document
	tmpl->InitialUpdateFrame(pFrame, pDocument, TRUE);

	POSITION pos =  pDocument->GetFirstViewPosition();
	CPocketForm* V = (CPocketForm*)(pDocument->GetNextView(pos));
	V->m_PocketItems = UnitNos;
    V->m_WordList.InsertColumn(1,"Словарный вход", LVCFMT_LEFT, 200);
	V->m_WordList.InsertColumn(2,"Номер значения", LVCFMT_LEFT, 60);
	V->m_WordList.InsertColumn(2,"Название словаря", LVCFMT_LEFT, 60);
	V->m_WordList.SetItemCountEx(UnitNos.size());
	V->m_UnitsSize.Format ("Число словарных входов : %i",    V->m_WordList.GetItemCount());
    V->UpdateData(FALSE);
    V->m_WordList.UpdateData(FALSE);
    V->m_WordList.Invalidate();	
	V->m_Title = Title;

	// установка размеров
	V->GetParent()->SetWindowPos(NULL, 0,0, 535 , 500, SWP_SHOWWINDOW|SWP_NOZORDER|SWP_NOMOVE);
	return true;
};
Exemple #3
0
void CMainFrame::OnButtonHomepage()
{
	// TODO:  在此添加命令处理程序代码
	CWinApp* pApp = AfxGetApp();

	// Get the correct document template.
	POSITION pos = pApp->GetFirstDocTemplatePosition();
	CDocTemplate* pDocTemplate = pApp->GetNextDocTemplate(pos);
	// Create a new frame.
	
	CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(
		pDocTemplate->CreateNewDocument(),
		(CFrameWnd*)AfxGetMainWnd());
	// Activate the frame.
	pDocTemplate->InitialUpdateFrame(pFrame, NULL);
	CXiYuanView* pView = (CXiYuanView*)pFrame->GetActiveView();

	pView->Navigate2(_T("http://vod.cau.edu.cn/"), NULL, NULL);
	
	//CXiYuanView *pView = (CXiYuanView*)this->GetActiveView();
	////assert(pView);
	
	//LPDISPATCH *ppDisp=NULL ;
	//pView->SetRegisterAsBrowser(TRUE);
	//*ppDisp = pView->GetApplication();
	//BOOL cancel = false;
	//pView->OnNewWindow2(ppDisp,&cancel);
	//打开爱思主页新选项卡
	// Get a pointer to the application object.
	//CWinApp* pApp = AfxGetApp();
	//
	//// Get the correct document template.
	//POSITION pos = pApp->GetFirstDocTemplatePosition();
	//CDocTemplate* pDocTemplate = pApp->GetNextDocTemplate(pos);
	//// Create a new frame.
	//CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(
	//	pDocTemplate->CreateNewDocument(),
	//	(CFrameWnd*)AfxGetMainWnd());
	//// Activate the frame.
	//pDocTemplate->InitialUpdateFrame(pFrame, NULL);
	//CXiYuanView* pView = (CXiYuanView*)pFrame->GetActiveView();
	//// Pass pointer of WebBrowser object.
	//pView->SetRegisterAsBrowser(TRUE);
	//LPDISPATCH ppDisp = pView->GetApplication();
	//
	////assert(ppDisp);
	//BOOL Cancel = TRUE;
	//pView->OnNewWindow2(&ppDisp,& Cancel);
	
	
}
//////////////////
// Load document. This function is responsible for opening the document
// and setting m_pOpenDoc to the document loaded.
BOOL CExtractImageApp::LoadDoc(LPCTSTR lpFileName)
{
	ASSERT(lpFileName!=NULL);
	CString sFileName = lpFileName;
	CDocTemplate* pDocTemplate = CanOpenDocument(sFileName);
	if (pDocTemplate) 
	{
		if(!m_pDoc) 
		{
			m_pDoc = pDocTemplate->CreateNewDocument();
			m_pDoc->m_bAutoDelete = TRUE;
		}
		if (m_pDoc)
		{
			// load content of file, code taken from MFC OnOpenDocument and modified
			/*CFileException fe;
			::CFile* pFile = m_pDoc->GetFile(sFileName,	::CFile::modeRead, &fe);
			if (pFile == NULL)
				return FALSE;*/

			m_pDoc->DeleteContents();
			return m_pDoc->OnOpenDocument(sFileName);
			/*CArchive loadArchive(pFile, CArchive::load | CArchive::bNoFlushOnDelete);
			loadArchive.m_pDocument = m_pDoc;
			loadArchive.m_bForceFlat = FALSE;
			try
			{
				if (pFile->GetLength() != 0)
					m_pDoc->Serialize(loadArchive);     // load me
				loadArchive.Close();
				m_pDoc->ReleaseFile(pFile, FALSE);
			}
			catch(CException *e)
			{
				//e->ReportError();
				m_pDoc->ReleaseFile(pFile, TRUE);
				m_pDoc->DeleteContents();   // remove failed contents
				e->Delete();
				return FALSE;
			}*/
			// return TRUE;
			//delete pDoc;
		}
	}
	return FALSE;
}
Exemple #5
0
void CMainFrame::OnButtonSport()
{
	// TODO:  在此添加命令处理程序代码
	CWinApp* pApp = AfxGetApp();

	// Get the correct document template.
	POSITION pos = pApp->GetFirstDocTemplatePosition();
	CDocTemplate* pDocTemplate = pApp->GetNextDocTemplate(pos);
	// Create a new frame.

	CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(
		pDocTemplate->CreateNewDocument(),
		(CFrameWnd*)AfxGetMainWnd());
	// Activate the frame.
	pDocTemplate->InitialUpdateFrame(pFrame, NULL);
	CXiYuanView* pView = (CXiYuanView*)pFrame->GetActiveView();

	pView->Navigate2(_T("http://vod.cau.edu.cn/index.php?mod=category&action=view&id=106"), NULL, NULL);
}
Exemple #6
0
void CMainFrame::OnButtonSearch()
{
	// TODO:  在此添加命令处理程序代码
	
	CString path;
	path=L"http://vod.cau.edu.cn/index.php?type=title&keyword="+m_search+L"&mod=content&action=search";
	// TODO:  在此添加命令处理程序代码
	CWinApp* pApp = AfxGetApp();
	// Get the correct document template.
	POSITION pos = pApp->GetFirstDocTemplatePosition();
	CDocTemplate* pDocTemplate = pApp->GetNextDocTemplate(pos);
	// Create a new frame.
	CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(
		pDocTemplate->CreateNewDocument(),
		(CFrameWnd*)AfxGetMainWnd());
	// Activate the frame.
	pDocTemplate->InitialUpdateFrame(pFrame, NULL);
	CXiYuanView* pView = (CXiYuanView*)pFrame->GetActiveView();
	pView->Navigate2(path, NULL, NULL);


}
// called by the CPageCMenu::OnWizardNext() after the page where the user chooses
//	the carla.set file so that subsequent page can show some of the information
//	(e.g. abbreviation) we'll read in that file
BOOL CProjectDoc::readCarlaMenuSettings(CString& sPath, CString& sSrcAbrev, CString& sTargAbrev, char& cCommentChar)
{
	const char* lpzPath = LPCTSTR(sPath);
	SFMFile f(lpzPath, '*'); // comment won't be found in this kind of file

	if(!f.isOpen())
	{
		CString s("Couldn't open CARLAMenu File named:");
		s += sPath;
		MessageBox( NULL, s, NULL, MB_OK);
		return FALSE;
	}

	CString sMarker, sField;
	BOOL bEnabled;

	// note that we currently don't store the abreviations or control directories
	// instead, we store paths to each file relative to the project file

	while(f.getField(sMarker, sField, &bEnabled))
	{
		try
		{	// note: within CStudio we don't really have a set
			// source and target languages; we just have languages
			// that are at any one time assigned to be the source
			// or the target during processing.
			// The following make the languages found here be the
			// source or target initially,
			// according to how they were in the CARLAMenu settings file.
			if(sMarker == "src")
			{
				sSrcAbrev = sField;
			}
			else if(sMarker == "trg")
			{
				sTargAbrev = sField;
			}
			else if(sMarker == "comm")	// notice, it's part of the whole cmenu project, not each lang as you would expect
			{
				sField.TrimLeft();
				if(sField.GetLength())
					cCommentChar = sField[0];
			}
			else if(sMarker == "lang")	// FIELD example: \lang xyz c:\srcinfo
			{							// we need to figure out if this is the src or trg lang
				CString sLang, sDir;	// and set the corresponding directory variable
				CParseStream stream(sField);
				THROW_STR_IF_NOT(stream.word(sLang, FALSE), sField);

				// for some reason, some \lang fields aren't the src or the target (see Cline:anufo).
				// I don't know what these are in there for or what to do with them

				if(sLang != sSrcAbrev && sLang != sTargAbrev)
				{
					//f.logSkip("CarlaMenu-Import",sMarker,sField, "Was neither the source nor target.");
				}
				else
				{

					if(!stream.word(sDir, FALSE))
					{								 // if the path isn't specified,
						sDir = getDirectory(lpzPath);// then expect the path to the langauge.set file to be the same as the carla.set file
					}
					// make sure the directory ends in a slash (CARLAMenu allows both ways)
					if(sDir[sDir.GetLength()-1] != '\\')	// look at last character
						sDir += "\\";

					/**** when I tried to make the langdoc this way, I get a failed assert
						  like the views weren't being setup correctly.
						CLangModelsDoc* pLangDoc = new CLangModelsDoc(sLang, sDir);
						// since we didn't do a new or open, need to create the window
						CFrameWnd* pf = ((CCarlaStudioApp*)AfxGetApp())->getLangDocTemplate()
								->CreateNewFrame( pLangDoc, NULL);
						pf->ActivateFrame();
					***/
					gsNewLangAbrev = sLang;
					gsDirContainingCarlaSet = sDir;
					CDocTemplate* pT = theApp.getDocTemplate(CLangModelsDoc::getRegFileTypeID());

					CLangModelsDoc* pLangDoc = (CLangModelsDoc*) pT->CreateNewDocument();
					ASSERTX(pLangDoc);
					gsNewLangAbrev = "";
					gsDirContainingCarlaSet = "";

					// during that previous construction the lang registered itself with this project
					if(sLang == sSrcAbrev)
						setSourceLangDoc(pLangDoc);
					else if(sLang == sTargAbrev)
						setTargetLangDoc(pLangDoc);
					else
						ASSERTX(FALSE);	// get this if a lang appeared that didn't have a corresponding \src or \trg
				}
			}

			else
				; //TRACE("CARLAMENU Skipping Field [%s]\n", sMarker);
		}
		catch(CString sError)
		{
			CString s("loadCarlaMenuFile() Couldn't parse: ");
			s += sError;
			MessageBox( NULL, s, NULL, MB_OK);
		}
	}


	return TRUE;
}