博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Scintilla - An excellent source editting control
阅读量:5105 次
发布时间:2019-06-13

本文共 3301 字,大约阅读时间需要 11 分钟。

      Scintilla is a free source editing component written in c++,it's fully open source and you can distribute it anywhere 
commercially or non-commercially under its license.
      Scintilla includes features especially useful when editing and debugging source code.These includes syntax styling,error indicators,code indication and call tips.The selection can contain markers like those used in debuggers to indicate the breakpoint and the current line.Scintilla provides a huge amount of user customization .The user can make even more styling choices then other editors.including propotional fonts,bold and italics,multiple foreground and background colors and fonts.
      You can find its full information at .
      Here,I'll demo how to use it in MFC dialog program ,for more detailed usage ,please turn to its website given above.
      First,download scintilla src package and extract it somewhere as you like.Open visual c++ 6.0 and create a dialog-based application using App Wizard.Add include subfolder into ur project as well as the SciLexer.dll.
      Let's go on.Add a HMODULE member to your CWinApp derived class,suppose it's m_hScitilla.In InitInstance function,add :
1 
  m_hScitilla
=
LoadLibrary(
"
SciLexer.dll);
2 
 
if
(m_hScitilla  
==
 NULL){
3 
   
//
Quit ??   As ur will!
4 
 }
       Remember to free the library in ExitInstance funciton:
1 
if
(m_hScitilla 
!=
 NULL){
2 
  FreeLibrary(m_hScitilla);
3 
  m_hScitilla
=
NULL;
4 
}
     The DLL will register a new class called "Scitilla" if it is loaded successfully.Now you can use this new control just like any other windows controls.
1 
hWndSci 
=
 CreateWindowEx(
0
,
"
Scintilla
"
,
""
,
2 
          WS_CHILD 
|
 WS_VISIBLE 
|
 WS_TABSTOP 
|
 WS_CLIPCHILDREN,
3 
      
10
,
10
,
500
,
400
,hwndParent,(HMENU)GuiID, hInstance,NULL);
      You can control the edit by sending commands.There are two ways to do that:A simple way and a fast way.
      The simple ways is just like with any other windows.You can send messages to Scintilla Edit control and receive notifications from it ,note that the notification message is sent to its parent window.
      For example,you can use 
SendMessage(hWndScintilla,SCI_CREATEDOCUMENT, 0, 0) to ask scintilla to create a new document.
      Some of the commands will return a value and unused parameters should be set to NULL.
      The fast way to control scintilla edit control is to call message handling functions by yourself.You can retrieve the pointer of the message handling
funciton of Scintilla and call it directly to execute a command.
      You have to use SCI_GETDIRECTFUNCTION and SCI_GETDIRECTPOINTER commands to retrieve the pointer to the function and a pointer which
must be the first parameter when calling the retrieved function pointer.YOu have to do this with the SendMessage way.The whole things will be like this:
ContractedBlock.gif
ExpandedBlockStart.gif
Code
1 int (*fn)(void*,int,int,int);
2 void * ptr;
3 int canundo;
4 fn = (int (__cdecl *)(void *,int,int,int))
5       SendMessage(hwndScintilla,SCI_GETDIRECTFUNCTION,0,0);
6 ptr = (void *)SendMessage(hwndScintilla,SCI_GETDIRECTPOINTER,0,0);
7 canundo = fn(ptr,SCI_CANUNDO,0,0
      References:www.scitilla.org
  Scintilla的windows版本是一个windows控件,所以其主要编程接口都是通过消息机制来实现的.早期的Scintilla版本模仿了标准的windows Edit和RichEdit控件定义的大部分API实现,然而现代这些API在Scintilla中都被摒弃,而改用Scintilla自己的API.
  GTK版本使用了与windows版本类似的消息机制,这与一般的GTK设计方法不同但是更易于快速实现.

转载于:https://www.cnblogs.com/cmleung/archive/2009/09/19/1570031.html

你可能感兴趣的文章
MAVEN(一)中的Scope
查看>>
ABAP->内表数据下载到CSV格式(原创转载请注明)
查看>>
hdu1316 java解高精度斐波数
查看>>
jquery获取复选框checkbox的值
查看>>
SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)
查看>>
[个人原创]关于java中对象排序的一些探讨(一)
查看>>
Unix/Linux笔记全集
查看>>
转: Oracle AWR 报告 每天自动生成并发送邮箱
查看>>
让div容器中的图片水平、垂直居中
查看>>
uboot之uboot.lds文件分析
查看>>
10_android打包的过程
查看>>
MySql update inner join!MySql跨表更新 多表update sql语句?如何将select出来的部分数据update到另一个表里面?...
查看>>
我最宏大的个人愿望
查看>>
北漂周记--第5记--拼命编程
查看>>
比赛总结一
查看>>
SpringBoot项目打包
查看>>
JSP的3种方式实现radio ,checkBox,select的默认选择值
查看>>
Linux操作系统 和 Windows操作系统 的区别
查看>>
《QQ欢乐斗地主》山寨版
查看>>
文件流的使用以及序列化和反序列化的方法使用
查看>>