RichTextBox vb.net 关键词高亮
来源:互联网 发布:notepad怎么运行python 编辑:程序博客网 时间:2024/03/29 03:50
Imports HWND = System.IntPtr
Public Class Form_Rules
Private Const WM_SETREDRAW As Integer = &HB
Private Shared Function SendMessage(ByVal hwnd As HWND, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer
End Function
Dim index As Integer = 0
Private Sub Form_Rules_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
RichTextBox.WordWrap = False
End Sub
Private Sub RichTextBox_TextChanged(sender As System.Object, e As System.EventArgs) Handles RichTextBox.TextChanged
SendMessage(RichTextBox.Handle, WM_SETREDRAW, 0, IntPtr.Zero)
RichTextBox.SelectAll()
RichTextBox.SelectionColor = Color.Black
Dim keystr As String = "and,end,if,then,or,else,+,true,false"
For i = 0 To UBound(keystr.Split(",")) - 1
Call GetKey(keystr.Split(",")(i), RichTextBox.Text)
RichTextBox.Select(index, 0)
RichTextBox.SelectionColor = Color.Black
Next
SendMessage(RichTextBox.Handle, WM_SETREDRAW, 1, IntPtr.Zero)
' RichTextBox.Refresh()
End Sub
Public Function GetKey(ByVal P As String, ByVal S As String) As Integer
Dim CNT As Integer = 0
Dim M As Integer = P.Length
Dim N As Integer = S.Length
Dim SS As Char() = S.ToCharArray()
Dim PP As Char() = P.ToCharArray()
If M > N Then Return 0
For I = 0 To N - M + 1
Dim J As Integer = 0
For J = 0 To M
Try
If SS(I + J) <> PP(J) Then
Exit For
End If
Catch ex As Exception
End Try
If J = P.Length Then
RichTextBox.Select(I, P.Length)
RichTextBox.SelectionColor = Color.Red
CNT = CNT + 1
End If
Next
Next
Return CNT
End Function
Public Class Form_Rules
Private Const WM_SETREDRAW As Integer = &HB
Private Shared Function SendMessage(ByVal hwnd As HWND, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer
End Function
Dim index As Integer = 0
Private Sub Form_Rules_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
RichTextBox.WordWrap = False
End Sub
Private Sub RichTextBox_TextChanged(sender As System.Object, e As System.EventArgs) Handles RichTextBox.TextChanged
SendMessage(RichTextBox.Handle, WM_SETREDRAW, 0, IntPtr.Zero)
RichTextBox.SelectAll()
RichTextBox.SelectionColor = Color.Black
Dim keystr As String = "and,end,if,then,or,else,+,true,false"
For i = 0 To UBound(keystr.Split(",")) - 1
Call GetKey(keystr.Split(",")(i), RichTextBox.Text)
RichTextBox.Select(index, 0)
RichTextBox.SelectionColor = Color.Black
Next
SendMessage(RichTextBox.Handle, WM_SETREDRAW, 1, IntPtr.Zero)
' RichTextBox.Refresh()
End Sub
Public Function GetKey(ByVal P As String, ByVal S As String) As Integer
Dim CNT As Integer = 0
Dim M As Integer = P.Length
Dim N As Integer = S.Length
Dim SS As Char() = S.ToCharArray()
Dim PP As Char() = P.ToCharArray()
If M > N Then Return 0
For I = 0 To N - M + 1
Dim J As Integer = 0
For J = 0 To M
Try
If SS(I + J) <> PP(J) Then
Exit For
End If
Catch ex As Exception
End Try
If J = P.Length Then
RichTextBox.Select(I, P.Length)
RichTextBox.SelectionColor = Color.Red
CNT = CNT + 1
End If
Next
Next
Return CNT
End Function
End Class
防止闪烁:
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As IntPtr) As IntPtr
LockWindowUpdate(RichTextBox.Handle)
LockWindowUpdate(0)
- RichTextBox vb.net 关键词高亮
- [VB.NET]richtextbox控件
- vb.net 逐行读取RichTextBox内容
- [VB.NET]如何实现对 RichTextBox 内容的选定、复制?
- [VB.NET]关于RichtextBox的DetectUrls属性和LinkClicked事件
- VB.Net程序设计:格式化XML文件,扩展新RichTextBox控件。
- 章鱼哥—VB.NET RichTextBox.AllowDrop属性的实例
- 高亮显示关键词
- 关键词高亮显示
- RichTextBox 语法高亮的一些links
- C#实现TextBox、RichTextBox语法高亮
- RichTextBox指定文本高亮显示
- html页面高亮关键词
- 高亮关键词,仿淘宝
- richTextBox自适应行高
- vb.net 教程 3-4 窗体编程 公共控件8 RichTextBox
- 使用 javascript 标记高亮关键词
- js高亮关键词系列方法
- 禁止访问某文件
- J2EE规范
- Android Alarm manager 定时闹钟开发详解
- 批处理for命令详解
- 拨号基础知识
- RichTextBox vb.net 关键词高亮
- 免费增加带宽 一解眼福畅游【乡巴佬】
- VC++常规错误之22:warning LNK4204缺少引用模块的调试信息;正在链接对象,如同没有调试信息一样
- 【ArcGIS 10.2新特性】Portal for ArcGIS新特性
- zedgraph实现跨点连线
- 当webview遇到了Slidingmenu,webView出现卡白,解决方案
- 如何在SharePoint 2013 的Master page 中引入Jquery
- 用Sencha Touch SDK TOOLS 编译Sencha touch 2 程序
- 转载:个图形爱好者的书架.-也来介绍一下我的藏书.