事件通知数据结构。在Windows中,Scintilla将向它的父窗口发送WM_NOTIFY消息;在GTK+中,Scintilla将向它的父窗口发送notify信号。
struct NotifyHeader { // 与WIN32数据结构NMHDR相同
void *hwndFrom; // 发送通知的窗口句柄
uptr_t idFrom; // 发送通知的控件ID
unsigned int code; // SCN_*通知事件代码
};
struct SCNotification {
struct NotifyHeader nmhdr;
// SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_DWELLSTART,
// SCN_DWELLEND, SCN_CALLTIPCLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK
int position;
int ch; // SCN_CHARADDED, SCN_KEY
// SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK
int modifiers;
int modificationType; // SCN_MODIFIED
// SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION
const char *text;
int length; // SCN_MODIFIED
int linesAdded; // SCN_MODIFIED
int message; // SCN_MACRORECORD
uptr_t wParam; // SCN_MACRORECORD
sptr_t lParam; // SCN_MACRORECORD
int line; // SCN_MODIFIED, SCN_DOUBLECLICK
int foldLevelNow; // SCN_MODIFIED
int foldLevelPrev; // SCN_MODIFIED
int margin; // SCN_MARGINCLICK
int listType; // SCN_USERLISTSELECTION, SCN_AUTOCSELECTION
int x; // SCN_DWELLSTART, SCN_DWELLEND
int y; // SCN_DWELLSTART, SCN_DWELLEND
};
与MFC的集成
对于MFC应用程序向导创建的多文档程序,只需添加很少的代码,就可以将Scintilla控件嵌入到View中。假设工程名为EasyEdit,则相关的类分别为CEasyEditApp、CEasyEditDoc、CEasyEditView、CChildFrame。
首先,在CEasyEditApp中添加私有成员变量HMODULE m_hmodule和虚函数int ExitInstance(),并增加加载DLL代码和释放DLL代码:
BOOL CEasyEditApp::InitInstance()
{
m_hmodule = LoadLibrary(_T("SciLexer.dll"));
if (NULL == m_hmodule)
{
::MessageBox(NULL, _T("The Scintilla DLL could not be loaded."),
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-53178-2.html
都是印发股票的人发大财了