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

📄 scintilladlg.cpp

📁 一个可以提供语法高亮显示的编辑器
💻 CPP
字号:
// ScintillaDlg.cpp: Implementierungsdatei
//

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

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

/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CScintillaDlg 


CScintillaDlg::CScintillaDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CScintillaDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CScintillaDlg)
		// HINWEIS: Der Klassen-Assistent f黦t hier Elementinitialisierung ein
	//}}AFX_DATA_INIT
}


void CScintillaDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CScintillaDlg)
		// HINWEIS: Der Klassen-Assistent f黦t hier DDX- und DDV-Aufrufe ein
	DDX_Control(pDX, IDC_SCINCTRL, m_ScinCtrl);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CScintillaDlg, CDialog)
	//{{AFX_MSG_MAP(CScintillaDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f黵 Nachrichten CScintillaDlg 

BOOL CScintillaDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_ScinCtrl.Init();
	m_ScinCtrl.SetDisplayLinenumbers(TRUE);
   m_ScinCtrl.SetDisplayFolding(TRUE);
   m_ScinCtrl.SetLexer(SCLEX_CPP);
   m_ScinCtrl.SendMessage(SCI_SETKEYWORDS, 0, (long)_T("and and_eq asm auto bitand bitor bool break case catch char class compl const const_cast continue default delete do double dynamic_cast else enum explicit export extern false float for friend goto if inline int long mutable namespace new not not_eq operator or or_eq private protected public register reinterpret_cast return short signed sizeof static static_cast struct switch template this throw true try typedef typeid typename union unsigned using virtual void volatile wchar_t while xor xor_eq"));
   m_ScinCtrl.SetText(_T("int i=0;\nwhile(i<10)\n{\ni++;\n}\n"));
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zur點kgeben
}
/////////////////////////////////////
// @mfunc menu handler - find previous bookmark from the caret line
// @rvalue BOOL | TRUE if we handled the message - FALSE if message should be processed further
//
BOOL CScintillaDlg::OnNotify( 
                                 WPARAM wParam,       //@parm not used
                                 LPARAM lParam,       //@parm pointer to notification structure
                                 LRESULT* pResult )   //@parm result
{
   NMHDR *phDR;
   phDR = (NMHDR*)lParam;
// does notification come from my scintilla window?
   if (phDR != NULL && phDR->hwndFrom == m_ScinCtrl.m_hWnd)
   {
      SCNotification *pMsg = (SCNotification*)lParam;
      switch (phDR->code)
      {
         case SCN_STYLENEEDED:
         break;
         case SCN_CHARADDED:
         break;
         case SCN_SAVEPOINTREACHED:
         break;
//       called when the document is changed - mark document modified
         case SCN_SAVEPOINTLEFT:
         break;
         case SCN_MODIFYATTEMPTRO:
         break;
         case SCN_KEY:
         break;
         case SCN_DOUBLECLICK:
         break;
//       called when something changes and we want to show new indicator state or brace matching
         case SCN_UPDATEUI:
         {
            m_ScinCtrl.UpdateUI();
         }
         break;
         case SCN_MODIFIED:
         break;
         case SCN_MACRORECORD:
         break;
//       user clicked margin - try folding action
         case SCN_MARGINCLICK:
         {
            m_ScinCtrl.DoDefaultFolding(pMsg->margin, pMsg->position);
         }
         break;
         case SCN_NEEDSHOWN:
         break;
         case SCN_PAINTED:
         break;
         case SCN_USERLISTSELECTION:
         break;
         case SCN_URIDROPPED:
         break;
         case SCN_DWELLSTART:
         break;
         case SCN_DWELLEND:
         break;
      }
      return TRUE; // we processed the message
   }
   return CDialog::OnNotify(wParam, lParam, pResult);
}

⌨️ 快捷键说明

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