⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scintillamfc.cpp

📁 一个可以提供语法高亮显示的编辑器
💻 CPP
字号:
// scintillamfc.cpp : Legt das Klassenverhalten f黵 die Anwendung fest.
//

#include "stdafx.h"
#include "scintillamfc.h"

#include "MainFrm.h"
#include "ChildFrm.h"
#include "scintillamfcDoc.h"
#include "scintillamfcView.h"
#include "ScintillaWnd.h"
#include "Tokenizer.h"
#include "FileVersion.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CScintillamfcApp

BEGIN_MESSAGE_MAP(CScintillamfcApp, CWinApp)
	//{{AFX_MSG_MAP(CScintillamfcApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// HINWEIS - Hier werden Mapping-Makros vom Klassen-Assistenten eingef黦t und entfernt.
		//    Innerhalb dieser generierten Quelltextabschnitte NICHTS VER腘DERN!
	//}}AFX_MSG_MAP
	// Dateibasierte Standard-Dokumentbefehle
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// Standard-Druckbefehl "Seite einrichten"
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScintillamfcApp Konstruktion

CScintillamfcApp::CScintillamfcApp()
{
	// ZU ERLEDIGEN: Hier Code zur Konstruktion einf黦en
	// Alle wichtigen Initialisierungen in InitInstance platzieren
}

/////////////////////////////////////////////////////////////////////////////
// Das einzige CScintillamfcApp-Objekt

CScintillamfcApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CScintillamfcApp Initialisierung

BOOL CScintillamfcApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standardinitialisierung
	// Wenn Sie diese Funktionen nicht nutzen und die Gr鲞e Ihrer fertigen 
	//  ausf黨rbaren Datei reduzieren wollen, sollten Sie die nachfolgenden
	//  spezifischen Initialisierungsroutinen, die Sie nicht ben鰐igen, entfernen.

#ifdef _AFXDLL
	Enable3dControls();			// Diese Funktion bei Verwendung von MFC in gemeinsam genutzten DLLs aufrufen
#else
	Enable3dControlsStatic();	// Diese Funktion bei statischen MFC-Anbindungen aufrufen
#endif

	// 膎dern des Registrierungsschl黶sels, unter dem unsere Einstellungen gespeichert sind.
	// ZU ERLEDIGEN: Sie sollten dieser Zeichenfolge einen geeigneten Inhalt geben
	// wie z.B. den Namen Ihrer Firma oder Organisation.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Standard INI-Dateioptionen laden (einschlie遧ich MRU)

	// Dokumentvorlagen der Anwendung registrieren. Dokumentvorlagen
	//  dienen als Verbindung zwischen Dokumenten, Rahmenfenstern und Ansichten.

	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_SCINTITYPE,
		RUNTIME_CLASS(CScintillamfcDoc),
		RUNTIME_CLASS(CChildFrame), // Benutzerspezifischer MDI-Child-Rahmen
		RUNTIME_CLASS(CScintillamfcView));
	AddDocTemplate(pDocTemplate);


   m_hDll = CScintillaWnd::LoadScintillaDll();
// try to get version from lexer dll
   if (m_hDll != NULL)
   {
      TCHAR szFilename[256];
      ::GetModuleFileName(m_hDll, szFilename, 256);
      CFileVersion ver;
      ver.Open (szFilename);
      m_strVersionScintilla = ver.GetFixedFileVersion();
      m_strProductScintilla = ver.QueryValue (_T("ProductName"));
      m_strFileScintilla = szFilename;
      ver.Close();
   }
// load last find/replacestrings from registry
   int nCount = GetProfileInt(_T("EDIT"), _T("FINDSTRINGCOUNT"), 0);
   for (int i=0;i<nCount && i<100;i++)
   {
      CString strEntry;
      strEntry.Format(_T("FINDSTRING%d"), i);
      strEntry = GetProfileString(_T("EDIT"), strEntry, _T(""));
      strEntry.TrimLeft();
      if (strEntry.GetLength() > 0)
         m_strFindstrings.Add(strEntry);
   }
   nCount = GetProfileInt(_T("EDIT"), _T("REPLACESTRINGCOUNT"), 0);
   for (i=0;i<nCount && i<100;i++)
   {
      CString strEntry;
      strEntry.Format(_T("REPLACESTRING%d"), i);
      strEntry = GetProfileString(_T("EDIT"), strEntry, _T(""));
      strEntry.TrimLeft();
      if (strEntry.GetLength() > 0)
         m_strReplacestrings.Add(strEntry);
   }

	// Haupt-MDI-Rahmenfenster erzeugen
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Befehlszeile parsen, um zu pr黤en auf Standard-Umgebungsbefehle DDE, Datei offen
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Verteilung der in der Befehlszeile angegebenen Befehle
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// Das Hauptfenster ist initialisiert und kann jetzt angezeigt und aktualisiert werden.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();

	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg-Dialog f黵 Info 黚er Anwendung

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialogdaten
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	CString	m_strCopyright;
	CString	m_strProduct;
	CString	m_strVersion;
	//}}AFX_DATA

	// 躡erladungen f黵 virtuelle Funktionen, die vom Anwendungs-Assistenten erzeugt wurden
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV-Unterst黷zung
	//}}AFX_VIRTUAL

// Implementierung
protected:
	//{{AFX_MSG(CAboutDlg)
		// Keine Nachrichten-Handler
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	m_strCopyright = _T("");
	m_strProduct = _T("");
	m_strVersion = _T("");
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Text(pDX, IDC_COPYRIGHT, m_strCopyright);
	DDX_Text(pDX, IDC_PRODUCT, m_strProduct);
	DDX_Text(pDX, IDC_VERSION, m_strVersion);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// Keine Nachrichten-Handler
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// Anwendungsbefehl zum Ausf黨ren des Dialogfelds
void CScintillamfcApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
   aboutDlg.m_strCopyright = m_strFileScintilla;
   aboutDlg.m_strProduct = m_strProductScintilla;
   aboutDlg.m_strVersion = m_strVersionScintilla;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CScintillamfcApp-Nachrichtenbehandlungsroutinen

int CScintillamfcApp::ExitInstance() 
{
// save find and replace strings
   WriteProfileInt(_T("EDIT"), _T("FINDSTRINGCOUNT"), m_strFindstrings.GetSize());
   for (int i=0;i<m_strFindstrings.GetSize();i++)
   {
      CString strEntry;
      strEntry.Format(_T("FINDSTRING%d"), i);
      WriteProfileString(_T("EDIT"), strEntry, m_strFindstrings.GetAt(i));
   }
   WriteProfileInt(_T("EDIT"), _T("REPLACESTRINGCOUNT"), m_strReplacestrings.GetSize());
   for (i=0;i<m_strReplacestrings.GetSize();i++)
   {
      CString strEntry;
      strEntry.Format(_T("REPLACESTRING%d"), i);
      WriteProfileString(_T("EDIT"), strEntry, m_strReplacestrings.GetAt(i));
   }
   m_strFindstrings.RemoveAll();
   m_strReplacestrings.RemoveAll();
// unload scintilla dll
   if (m_hDll != NULL)
      AfxFreeLibrary(m_hDll);
	return CWinApp::ExitInstance();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -