icrEdit.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. #include "..\ide\ide.cpp"
  2. // icrEdit.cpp : Defines the class behaviors for the application.
  3. //
  4. #include "stdafx.h"
  5. #include "icrEdit.h"
  6. #include "MainFrm.h"
  7. #include "icrEditDoc.h"
  8. #include "icrEditView.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CIcrEditApp
  16. BEGIN_MESSAGE_MAP(CIcrEditApp, CWinApp)
  17. //{{AFX_MSG_MAP(CIcrEditApp)
  18. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  19. // NOTE - the ClassWizard will add and remove mapping macros here.
  20. // DO NOT EDIT what you see in these blocks of generated code!
  21. //}}AFX_MSG_MAP
  22. // Standard file based document commands
  23. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  24. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  25. // Standard print setup command
  26. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  27. END_MESSAGE_MAP()
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CIcrEditApp construction
  30. CIcrEditApp::CIcrEditApp()
  31. {
  32. // TODO: add construction code here,
  33. // Place all significant initialization in InitInstance
  34. }
  35. /////////////////////////////////////////////////////////////////////////////
  36. // The one and only CIcrEditApp object
  37. CIcrEditApp theApp;
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CIcrEditApp initialization
  40. BOOL CIcrEditApp::InitInstance()
  41. {
  42. InitCommonControls();
  43. CWinApp::InitInstance();
  44. // 初始化 OLE 库
  45. if (!AfxOleInit())
  46. {
  47. //AfxMessageBox(IDP_OLE_INIT_FAILED);
  48. return FALSE;
  49. }
  50. AfxEnableControlContainer();
  51. OleInitialize(NULL);
  52. // Change the registry key under which our settings are stored.
  53. // TODO: You should modify this string to be something appropriate
  54. // such as the name of your company or organization.
  55. SetRegistryKey(_T("iCodeRepository Editor"));
  56. LoadStdProfileSettings(6); // Load standard INI file options (including MRU)
  57. // Register the application's document templates. Document templates
  58. // serve as the connection between documents, frame windows and views.
  59. CSingleDocTemplate* pDocTemplate;
  60. pDocTemplate = new CSingleDocTemplate(
  61. IDR_MAINFRAME,
  62. RUNTIME_CLASS(CIcrEditDoc),
  63. RUNTIME_CLASS(CMainFrame), // main SDI frame window
  64. RUNTIME_CLASS(CIcrEditView));
  65. AddDocTemplate(pDocTemplate);
  66. // Parse command line for standard shell commands, DDE, file open
  67. CCommandLineInfo cmdInfo;
  68. ParseCommandLine(cmdInfo);
  69. CString strFileName = cmdInfo.m_strFileName; //传入的参数
  70. if (strFileName.IsEmpty())
  71. {
  72. // AfxMessageBox("\n本软件只能在uScada主程序中调用!\t\t");
  73. // return FALSE;
  74. }
  75. cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;
  76. // Dispatch commands specified on the command line
  77. if (!ProcessShellCommand(cmdInfo))
  78. return FALSE;
  79. // The one and only window has been initialized, so show and update it.
  80. m_pMainWnd->ShowWindow(SW_SHOW);
  81. m_pMainWnd->UpdateWindow();
  82. CString strTitle;
  83. strTitle.LoadString(IDS_TITLE);
  84. m_pMainWnd->SetWindowText(strTitle);
  85. CMainFrame *mainfrm = (CMainFrame *)AfxGetMainWnd();
  86. mainfrm->m_strFileName = strFileName;
  87. CIcrEditView *icrEditView = (CIcrEditView *)mainfrm->GetActiveView();
  88. //icrEditView->SelectLanguage(nlanguage);
  89. icrEditView->SelectLanguage(3);
  90. if(0 != strFileName.GetLength())
  91. {
  92. icrEditView->LoadFile(strFileName);
  93. }
  94. icrEditView->SetSynEditViewFont(icrEditView->GetSynEditViewFont());
  95. return TRUE;
  96. }
  97. /////////////////////////////////////////////////////////////////////////////
  98. // CAboutDlg dialog used for App About
  99. class CAboutDlg : public CDialog
  100. {
  101. public:
  102. CAboutDlg();
  103. // Dialog Data
  104. //{{AFX_DATA(CAboutDlg)
  105. enum { IDD = IDD_ABOUTBOX };
  106. //}}AFX_DATA
  107. // ClassWizard generated virtual function overrides
  108. //{{AFX_VIRTUAL(CAboutDlg)
  109. protected:
  110. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  111. //}}AFX_VIRTUAL
  112. // Implementation
  113. protected:
  114. //{{AFX_MSG(CAboutDlg)
  115. // No message handlers
  116. //}}AFX_MSG
  117. DECLARE_MESSAGE_MAP()
  118. };
  119. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  120. {
  121. //{{AFX_DATA_INIT(CAboutDlg)
  122. //}}AFX_DATA_INIT
  123. }
  124. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  125. {
  126. CDialog::DoDataExchange(pDX);
  127. //{{AFX_DATA_MAP(CAboutDlg)
  128. //}}AFX_DATA_MAP
  129. }
  130. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  131. //{{AFX_MSG_MAP(CAboutDlg)
  132. // No message handlers
  133. //}}AFX_MSG_MAP
  134. END_MESSAGE_MAP()
  135. // App command to run the dialog
  136. void CIcrEditApp::OnAppAbout()
  137. {
  138. }
  139. /////////////////////////////////////////////////////////////////////////////
  140. // CIcrEditApp message handlers
  141. BOOL CIcrEditApp::OnIdle(LONG lCount)
  142. {
  143. CMainFrame *mainfrm = (CMainFrame *)AfxGetMainWnd();
  144. mainfrm->SetMessageText(mainfrm->m_strFileName);
  145. return CWinApp::OnIdle(lCount);
  146. }
  147. int CIcrEditApp::ExitInstance()
  148. {
  149. // TODO: Add your specialized code here and/or call the base class
  150. OleUninitialize();
  151. return CWinApp::ExitInstance();
  152. }