technofantasy
博客园
首页
新随笔
联系
订阅
管理
22 Posts :: 16 Stories :: 62 Comments :: 1 Trackbacks
与我联系
发短消息
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的新闻
最新评论
我的标签
留言簿
(22)
给我留言
查看留言
我参与的团队
北京.NET俱乐部(0/1360)
湖南.NET俱乐部(0/594)
Office专业开发团队(0/65)
MVP团队(0/498)
随笔分类
ASP.NET(2)
Atlas研究
RichTextBox技巧(5)
VB 2005写作进度(2)
VB.NET(1)
杂类(12)
随笔档案
2008年6月 (1)
2008年5月 (1)
2007年3月 (2)
2006年12月 (1)
2006年10月 (3)
2006年9月 (6)
2006年8月 (2)
2006年7月 (4)
2006年1月 (1)
2005年12月 (1)
文章分类
ASP.NET(3)
Atlas研究(2)
Merlion(2)
VB.NET(1)
Visual Basic(1)
VSTO(1)
Webcasts(6)
相册
Microsoft visual studo 2008巡展长沙站
VB.NET
朋友的BLOG
发条木偶的Blog
美女苏胖墩的BLOG
我的网站
AppleVB
搜索
最新评论
1. re: 微软社区发布会总结(多图杀猫)
看得的确辛苦
--萧寒
2. re: 微软社区发布会总结(多图杀猫)
图片好大啊,可以缩小一下啊
--啊不才
3. re: 微软社区发布会总结(多图杀猫)
看得挺辛苦的
--王孟军!
4. re: 微软社区发布会总结(多图杀猫)
向高手致敬...
--伊狼
5. re: 微软社区发布会总结(多图杀猫)
早知道这么多PLMM去了,我说什么也得去啊,呵呵
--ken_sniper
阅读排行榜
1. 在VB.NET中如何使在Webbrowser中实现标签页中打开新链接(2392)
2. 运行cl.exe编译发生:没有找到 mspdb80.dll 的解决办法(2247)
3. 如何使得ShowModalDialog打开的页面自动刷新(1499)
4. RichTextBox技巧之插入表格(转载)(688)
5. RichTextBox技巧之插入图片(转载)(619)
评论排行榜
1. 湖南微软开发者俱乐部成立大会顺利召开(20)
2. VB 2005的写作进度(9)
3. 微软社区发布会总结(多图杀猫)(6)
4. 让微软出钱捐助难民吧(5)
5. 湖南微软.NET俱乐部 成立大会事宜(4)
RichTextBox技巧之显示自定义高亮显示(转载)
Public
Sub HighLight()
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()
Function
AddColorToTable(strRTF
As
String
, lColor
As
Long
)
As
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
posted on 2006-09-06 17:08
陈锐
阅读(246)
评论(0)
编辑
收藏
所属分类:
RichTextBox技巧
社区
新闻
新用户注册
刷新评论列表
标题
姓名
主页
Email
(只有博主才能看到)
验证码
*
看不清,换一张
[
登录
][
注册
]
内容(请不要发表任何与政治相关的内容)
Remember Me?
登录
使用高级评论
新用户注册
返回页首
恢复上次提交
[使用Ctrl+Enter键可以直接提交]
另存
打印
所属分类的其他文章:
·
RichTextBox技巧之插入图片(转载)
·
RichTextBox技巧之插入表格(转载)
·
RichTextBox技巧之插入上标和下标(转载)
·
RichTextBox技巧之显示自定义高亮显示(转载)
·
RichTextBox技巧之插入带格式文本(转载)
最新IT新闻:
·
金山:360的免费杀毒只能是短期行为
·
江民科技回应杀毒软件免费说 没病不能乱吃药
·
WCG2008中国区总决赛打响
·
新型的编程语言:eC
·
免费的BitDefender能复制卡巴斯基的成功吗?
博客园新闻频道
博客园首页
社区
Powered by:
博客园
Copyright © 陈锐