VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)

VB爱好者乐园(VBGood)

 找回密码
 立即注册
搜索
123
返回列表 发新帖
楼主: qinbuer

[讨论] 制作语法加亮的文本编辑器出现的问题,附源代码

[复制链接]
发表于 2012-3-30 15:36:04 | 显示全部楼层
本帖最后由 ycyhjj2865 于 2012-3-31 11:26 编辑

2012年回复一下,不算晚吧~~
其实不是不支持,是你没有找到设置的方法。
看看下面的代码吧:
Private Const SC_CP_UTF8 = 65001
Private Const SCI_SETCODEPAGE = 2037
Private Declare Function SendMessage Lib "USER32" _
    Alias "SendMessageA" (ByVal hWnd As Long, _
    ByVal msg As Long, ByVal wp As Long, _
    ByVal lp As Long) As Long

'在你需要的过程或函数体中加入下面的语句即可:
SendMessage sci, SCI_SETCODEPAGE, SC_CP_UTF8, 0

'+-----------------------------------------------------
'   注意sci不是枕善居代码中的被包装后类对象
'+-----------------------------------------------------
'  请参考如下代码:

'出处:http://www.scintilla.org/SciTry.vb

Private Const WS_CHILD = &H40000000
Private Const WS_VISIBLE = &H10000000
Private Const WS_EX_CLIENTEDGE = &H200
Private Const SCI_START = 2000
Private Const SCI_ADDTEXT = SCI_START + 1
Private Const SCI_SETSELBACK = SCI_START + 68
Private Declare Function CreateWindowEx Lib "USER32" _
    Alias "CreateWindowExA" (ByVal dwExStyle As Long, _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String, _
    ByVal dwStyle As Long, ByVal x As Long, _
    ByVal y As Long, ByVal nWidth As Long, _
    ByVal nHeight As Long, ByVal hWndParent As Long, _
    ByVal hMenu As Long, ByVal hInstance As Long, _
    lpParam As Any) As Long
Private Declare Function LoadLibrary Lib "Kernel32" _
    Alias "LoadLibraryA" (ByVal lpLibFileName As String) _
    As Integer
Private Declare Function SendMessage Lib "USER32" _
    Alias "SendMessageA" (ByVal hWnd As Long, _
    ByVal msg As Long, ByVal wp As Long, _
    ByVal lp As Long) As Long
Private Declare Function SendMessageString Lib "USER32" _
    Alias "SendMessageA" (ByVal hWnd As Long, _
    ByVal msg As Long, ByVal wp As Long, _
    ByVal lp As Any) As Long
Private Declare Function SetWindowPos Lib "USER32" _
    (ByVal hWnd As Long, ByVal m As Long, _
    ByVal left As Long, ByVal top As Long, _
    ByVal width As Long, ByVal height As Long, _
    ByVal flags As Long) As Long
Dim sci As Long

Private Sub Form_Load()
    LoadLibrary ("SciLexer.DLL")
    sci = CreateWindowEx(WS_EX_CLIENTEDGE, "Scintilla", _
        "TEST", WS_CHILD Or WS_VISIBLE, 0, 0, 200, 200, _
        Form1.hWnd, 0, App.hInstance, 0)
    SendMessage sci, SCI_SETSELBACK, 1, &HFFEFD0
    SendMessageString sci, SCI_ADDTEXT, 16, "Hello non-Python"
End Sub

Private Sub Form_Resize()
    SetWindowPos sci, 0, 2, 2, Form1.width / 15 - 12, _
        Form1.height / 15 - 30, 0
End Sub

'---------------------------------------------------------

评分

参与人数 1威望 +5 人气 +1 收起 理由
qinbuer + 5 + 1 很给力!

查看全部评分

回复 支持 反对

使用道具 举报

 楼主| 发表于 2012-8-14 16:14:49 | 显示全部楼层
非常感谢,永远不晚。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

文字版|手机版|小黑屋|VBGood  

GMT+8, 2022-11-28 10:07

VB爱好者乐园(VBGood)
快速回复 返回顶部 返回列表