惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - 陈锐

微软社区发布会总结(多图杀猫) 微软 Visual Studio 2008 社区发布全国巡展长沙站预报 让微软出钱捐助难民吧 能够下载时改名的文件权限管理 你的博客的性别是什么? 湖南微软开发者俱乐部成立大会顺利召开 湖南微软.NET俱乐部 成立大会事宜 在VB.NET中如何使在Webbrowser中实现标签页中打开新链接 RichTextBox技巧之插入图片(转载) RichTextBox技巧之插入表格(转载) RichTextBox技巧之插入上标和下标(转载) RichTextBox技巧之插入带格式文本(转载) VB 2005的写作进度 再VB 2005的拖放式数据绑定时遇到的问题 有些问题稍微想一下就明白了 写作进度(7月30日) Charles Petzold给撰书人的建议(from 思归的博客) 运行cl.exe编译发生:没有找到 mspdb80.dll 的解决办法 在VSTO 2005下创建的Office CommandBarButton不能定义在过程内
RichTextBox技巧之显示自定义高亮显示(转载)
陈锐 · 2006-09-06 · via 博客园 - 陈锐

Public Sub HighLight(RTB As RichTextBox, lColor As Long)
'add new color to color table
'
add tags \highlight# and \highlight0
'
where # is new color number
Dim iPos As Long
Dim strRTF As String
Dim bkColor As Integer

    
With RTB
        iPos 
= .SelStart
        
'bracket selection
        .SelText = Chr(&H9D) & .SelText & Chr(&H81)
        strRTF 
= RTB.TextRTF
'add new color
        bkColor = AddColorToTable(strRTF, lColor)
'add highlighting
         strRTF = Replace(strRTF, "\'9d""\up1\highlight" & CStr(bkColor) & "")
         strRTF 
= Replace(strRTF, "\'81""\highlight0\up0 ")

         .TextRTF 
= strRTF
        .SelStart 
= iPos
       
End With

End Sub

Function AddColorToTable(strRTF As String, lColor As LongAs Integer
Dim iPos As Long, jpos As Long

Dim ctbl As String
Dim tagColors
Dim nColors As Integer
Dim tagNew As String
Dim i As Integer
Dim iLen As Integer
Dim split1 As String
Dim split2 As String

    
'make new color into tag
    tagNew = "\red" & CStr(lColor And &HFF) & _
        
"\green" & CStr(Int(lColor / &H100) And &HFF) & _
        
"\blue" & CStr(Int(lColor / &H10000))
    
    
'find colortable
    iPos = InStr(strRTF, "{\colortbl")
    
    
If iPos > 0 Then 'if table already exists
        jpos = InStr(iPos, strRTF, ";}")
        
'color table
        ctbl = Mid(strRTF, iPos + 12, jpos - iPos - 12)
        
'array of color tags
        tagColors = Split(ctbl, ";")
        nColors 
= UBound(tagColors) + 2
        
'see if our color already exists in table
        For i = 0 To UBound(tagColors)
            
If tagColors(i) = tagNew Then
                AddColorToTable 
= i + 1
                
Exit Function
            
End If
        
Next i
'{\fonttbl{\f0\fnil\fcharset0 Verdana;}}
'
{\colortbl ;\red0\green0\blue0;\red128\green0\blue255;}
        
        split1 
= Left(strRTF, jpos)
        split2 
= Mid(strRTF, jpos + 1)
        strRTF 
= split1 & tagNew & ";" & split2
        AddColorToTable 
= nColors
    
    
Else
        
'color table doesn't exists, let's make one
        iPos = InStr(strRTF, "{\fonttbl"'beginning of font table
        jpos = InStr(iPos, strRTF, ";}}"+ 2 'end of font table
        split1 = Left(strRTF, jpos)
        split2 
= Mid(strRTF, jpos + 1)
        strRTF 
= split1 & "{\colortbl ;" & tagNew & ";}" & split2
        AddColorToTable 
= 1
    
End If

End Function