📄 c02ide.cpp
字号:
m_bAutoReturn = AfxGetApp()->GetProfileInt(_T("C02IDE Settings"), _T("Auto Return"), TRUE);
// CFileDialog fd(TRUE);
if(fd.DoModal()==IDCANCEL)
return;
ProjectList *curpro;
curpro=new ProjectList;
curpro=(ProjectList*)(projectinfo.GetAt(0));
CC02IDEApp *pApp = (CC02IDEApp *)AfxGetApp();
pApp->OpenDocumentFile(fd.m_ofn.lpstrFile); //用MFC的方法建立一个新视
gotoline=0;
findstring="";
findstringcurhang=0;
findstringcurlie=-1;
// strreplacewith="";
CCJMDIFrameWnd *m_pFrame = (CCJMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CCJMDIChildWnd *m_pChild = (CCJMDIChildWnd *) m_pFrame->GetActiveFrame();
FileList * m_pnewfile;
m_pnewfile=new FileList;
int n_file=curpro->proinfstru.GetSize();
//声明文件节点
struct fileitem m_pcurnode;
for (int j=0;j<=n_file-1;j++)
{
//取得文件节点信息的第j个项
m_pcurnode=fileitemarray[j];
//如果节点的窗口指针等于当前活动窗口指针
if(m_pcurnode.m_pchildf==m_pChild)
return ;
}
TCHAR* ch_wndtitle=NULL;
CString str_newfilename=_T("");
m_pChild->GetWindowText(str_newfilename);
//(ch_wndtitle;
m_pnewfile->m_pChildWnd= m_pChild;
// m_pnewfile->funcinfstru=NULL;
if(str_newfilename!=_T(""))
m_pnewfile->str_filename=str_newfilename;
else
{
str_newfilename.Format("%d",n_file);
str_newfilename="no title file"+str_newfilename;
m_pnewfile->str_filename=str_newfilename;
// pChild->SetWindowText(str_newfilename);
}
curpro->proinfstru.Add((CObject *)m_pnewfile);
projectinfo.RemoveAll();
projectinfo.InsertAt(0,(CObject *)curpro);
m_pnewfile->str_proname=_T("1");
m_mappro.SetAt(m_pChild->GetSafeHwnd(),(void*&)m_pnewfile);
// projectfile.InsertAt(0,(CObject*)curpro);
m_pDocClass->UpdateTabView();
m_pDocFile->UpdateTabView();
CMainFrame *m_pmainFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
// CWorkspaceView* m_ptab=(CWorkspaceView*)m_pmainFrame->m_wndWorkspace;
m_pfile=m_pnewfile;
m_pmainFrame->updatecomfile();
}
/*
void CC02IDEApp::OnFileSaveAs()
{
CString Filter;
Filter = "All Source files (*.c, *.cpp, *.h *.hpp, "
" *.rc)|*.c;*.cpp;*.h;*.hpp;*.rc|";
Filter += "Header Files (*.h;*.hpp)|*.h;*.hpp|";
Filter += "Source Files (*.c;*.cpp)|*.c;*.cpp|";
Filter += "Resource Files (*.rc)|*.rc|";
Filter += "Text Files (*.txt)|*.txt|";
Filter += "All Files (*.*)|*.*||";
CFileDialog cfd(false, NULL, NULL, OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT, Filter);
if (cfd.DoModal () == IDCANCEL)
return;
// GetDocument()->OnSaveDocument (cfd.m_ofn.lpstrFile);
// GetDocument()->SetPathName(cfd.m_ofn.lpstrFile, TRUE);
}
*/
void CC02IDEApp::OnFilePrintSetup()
{
CPageSetupDialog psd;
if (psd.DoModal () == IDCANCEL)
return;
CString strDev = psd.GetDeviceName ();
HANDLE hPrinter;
DWORD dwBytesNeeded, dwBytesReturned;
TCHAR szDev[128];
strcpy (szDev, (LPCSTR) strDev);
OpenPrinter (szDev, &hPrinter, NULL);
GetPrinter(hPrinter, 2, NULL, 0, &dwBytesNeeded);
PRINTER_INFO_2 *pInfo2 = (PRINTER_INFO_2*)GlobalAlloc(GPTR,
dwBytesNeeded);
if (GetPrinter(hPrinter, 2, (BYTE *)pInfo2,
dwBytesNeeded,
&dwBytesReturned) == 0)
{
GlobalFree(pInfo2);
ClosePrinter(hPrinter);
return;
}
pInfo2->pDevMode = psd.GetDevMode ();
DWORD dwResult = SetPrinter (hPrinter, 2,
(BYTE *) pInfo2, 0);
if (!dwResult)
{
TCHAR Message[256];
dwResult = GetLastError ();
if (dwResult == 5)
strcpy (Message,_T("Access to printer denied"));
else
sprintf (Message, "Error %d setting printer",
dwResult);
AfxMessageBox (Message, MB_OK);
}
ClosePrinter (hPrinter);
}
void CC02IDEApp::OnFileSaveAll()
{
// TODO: Add your command handler code here
POSITION pos = GetFirstDocTemplatePosition ();
ASSERT (pos);
CDocTemplate *pDocTempl = GetNextDocTemplate (pos);
pos = pDocTempl->GetFirstDocPosition ();
while (pos)
{
CC02IDEDoc *pDoc = (CC02IDEDoc*) pDocTempl->GetNextDoc (pos);
ASSERT (pDoc);
CString sDocPath = pDoc->GetPathName ();
if (pDoc->IsModified ())
pDoc->DoSave (sDocPath);
}
}
int CC02IDEApp::ExitInstance()
{
_CrtDumpMemoryLeaks();
// TODO: Add your specialized code here and/or call the base class
m_mappro.RemoveAll();
return CWinApp::ExitInstance();
}
void CC02IDEApp::OnUpdateFileMruFile1(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (pCmdUI->m_pSubMenu!=NULL)
{
return;
}
CWinApp::OnUpdateRecentFileMenu(pCmdUI);
return;
}
BOOL CC02IDEApp::DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags,
BOOL bOpenFileDialog, CDocTemplate* pTemplate)
{
CKSFileDialog dlgFile(bOpenFileDialog);
dlgFile.SetAppPointer(this);
dlgFile.SetStringFilter("Edit Files(*.edt)|*.edt|Rich Text Format(*.rtf)|*.rtf|Text File(*.txt)|*.txt|All Files(*.*)|*.*");
dlgFile.SetMyParent(AfxGetMainWnd());
return dlgFile.DoPromptFileName(fileName,nIDSTitle,lFlags,bOpenFileDialog, pTemplate);
}
void CC02IDEApp::OnFileNewC02()
{
OnFileNew();
CString str_FileName = _T("ExampleC02.txt");
CFileException fileException;
CStdioFile myFile;
if(!myFile.Open(str_FileName,CFile::modeRead|CFile::typeText))
return;
// myFile.Write( szBuffer, sizeof( szBuffer ) );
// myFile.Seek( 0, CFile::begin );
CCJMDIFrameWnd *pFrame = (CCJMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CCJMDIChildWnd *pChild = (CCJMDIChildWnd *) pFrame->GetActiveFrame();
CString str_get=_T("");
//获得当前活动视图
CCrystalEditView* m_pexpandview=NULL;
m_pexpandview=(CCrystalEditView*)pChild->GetActiveView();
BOOL m_bend=TRUE;
// CRichEditView *pView = (CRichEditView *)pChild->GetActiveView();
// CRichEditCtrl& m_pctrl=pView->GetRichEditCtrl();
CPoint ptCursorPos;
do
{
m_bend=myFile.ReadString(str_get);
str_get= str_get+_T("\r\n");
// str_get=szBuffer;
// VERIFY(m_pexpandview->ReplaceSelection(str_get));
ptCursorPos = m_pexpandview->GetCursorPos();
int x,y;
m_pexpandview->m_pTextBuffer->InsertText(m_pexpandview, ptCursorPos.y, ptCursorPos.x, str_get, y, x, CE_ACTION_TYPING); // [JRT]
ptCursorPos.x = x;
ptCursorPos.y = y;
m_pexpandview->SetSelection(ptCursorPos, ptCursorPos);
m_pexpandview->SetAnchor(ptCursorPos);
m_pexpandview->SetCursorPos(ptCursorPos);
m_pexpandview->EnsureVisible(ptCursorPos);
//m_pexpandview->getrich
// m_pexpandview->ReplaceSelection(str_get);
}while(m_bend!=NULL);
myFile.Close();
// m_bAutoMenuEnable=FALSE;
}
BOOL CC02IDEApp::OnOpenRecentFileEx(UINT nID)
{
CWinApp::OnOpenRecentFile( nID);
ProjectList *curpro;
curpro=new ProjectList;
curpro=(ProjectList*)(projectinfo.GetAt(0));
gotoline=0;
findstring="";
findstringcurhang=0;
findstringcurlie=-1;
// strreplacewith="";
CCJMDIFrameWnd *m_pFrame = (CCJMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CCJMDIChildWnd *m_pChild = (CCJMDIChildWnd *) m_pFrame->GetActiveFrame();
FileList * m_pnewfile;
m_pnewfile=new FileList;
int n_file=curpro->proinfstru.GetSize();
//声明文件节点
struct fileitem m_pcurnode;
for (int j=0;j<=n_file-1;j++)
{
//取得文件节点信息的第j个项
m_pcurnode=fileitemarray[j];
//如果节点的窗口指针等于当前活动窗口指针
if(m_pcurnode.m_pchildf==m_pChild)
return TRUE;
}
TCHAR* ch_wndtitle=NULL;
CString str_newfilename=_T("");
m_pChild->GetWindowText(str_newfilename);
//(ch_wndtitle;
m_pnewfile->m_pChildWnd= m_pChild;
// m_pnewfile->funcinfstru=NULL;
if(str_newfilename!=_T(""))
m_pnewfile->str_filename=str_newfilename;
else
{
str_newfilename.Format("%d",n_file);
str_newfilename="no title file";//+str_newfilename;
m_pnewfile->str_filename=str_newfilename;
// pChild->SetWindowText(str_newfilename);
}
curpro->proinfstru.Add((CObject *)m_pnewfile);
projectinfo.RemoveAll();
projectinfo.InsertAt(0,(CObject *)curpro);
m_pnewfile->str_proname=_T("1");
m_mappro.SetAt(m_pChild->GetSafeHwnd(),(void*&)m_pnewfile);
// projectfile.InsertAt(0,(CObject*)curpro);
m_pDocClass->UpdateTabView();
m_pDocFile->UpdateTabView();
CMainFrame *m_pmainFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
// CWorkspaceView* m_ptab=(CWorkspaceView*)m_pmainFrame->m_wndWorkspace;
m_pfile=m_pnewfile;
m_pmainFrame->updatecomfile();
return TRUE;
}
void CC02IDEApp::OnProjectNew()
{
CProjectNew * p_newpro;
p_newpro=new CProjectNew;
p_newpro->Create(IDD_DIALOGPROJECT);
p_newpro->ShowWindow(SW_SHOW);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -