请问在VB中的文本控件怎样才能实现如下的文本效果?
解决方案 »
- 打印报表的问题
- 关于《水晶报表 7.X》版本的VB调用问题
- postmessage 和 sendmessage
- 一个任何文件,比如GIF文件,用记事本打开后会看到一些类似乱码的字符,反过来如何使用这些字符,生成原来的GIF文件
- 一个VB页面显示问题
- 急!!!我的程序找不到可安装的ISAM(在线等)
- ~~关于数据库转换后的问题 ~sqlserver 转 access ~~100
- 可以利用API改变TreeView 与 ListView 的滚动条的宽度吗?
- VB如何用ADO连接ORACLE?
- COMBOBOX的问题(急)
- 跪求高手指点:求单片机(最好是freescale的32位微控制器MPC564)与PC机串行通讯软件设计,PC机上用VB编,单片机端用VC++编的,急,非常急,毕业设计要用的,我不是学计算机的!!!!!!!
- 在VB6中RichTextBox如何实现像QQ插入"/aini"等表情
Private Sub Form_Activate()
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
aa = "c:\test.txt"
RichTextBox1.LoadFile aa, 1
End SubPrivate Sub Command1_Click()
Tlen = Len(Trim(RichTextBox1.Text))
Randomize
For i = 1 To Tlen
If Mid(RichTextBox1.Text, i, 1) <> "" Then
RichTextBox1.SelStart = i
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = QBColor(Int((Rnd * 7) + 8))
End If
Next i
End Sub效果图:
http://p.blog.csdn.net/images/p_blog_csdn_net/cbm666/366646/o_Richtxt.jpg
Private Sub Form_Load()
RTBHigh.AssignControls RichTextBox1
End Sub
Private Sub Command1_Click()
RTBHigh.APIHighlightHard vbYellow
End Sub
Private Sub Command2_Click()
RTBHigh.APIHighlightHard vbBLUE
End Sub需要一个类模块 ClsAPIHighlight和一个模块1、模块内容
Public RTBHigh As New ClsAPIHighlight2、类模块 ClsAPIHighlight内容'//////////////////////这个是类模块 ClsAPIHighlight
Private m_RTB As RichTextBox
Private Const WM_USER As Long = &H400
Private Const CFM_BACKCOLOR = &H4000000
Private Const EM_GETCHARFORMAT As Long = (WM_USER + 58)
Private Const EM_SETCHARFORMAT As Long = (WM_USER + 68)
Private Const SCF_SELECTION = &H1&
Private Const LF_FACESIZE As Integer = 32Private Type CHARFORMAT2
cbSize As Integer '2
wPad1 As Integer '4
dwMask As Long '8
dwEffects As Long '12
yHeight As Long '16
yOffset As Long '20
crTextColor As Long '24
bCharSet As Byte '25
bPitchAndFamily As Byte '26
szFaceName(0 To LF_FACESIZE - 1) As Byte ' 58
wPad2 As Integer ' 60' Additional stuff supported by RICHEDIT20
wWeight As Integer ' /* Font weight (LOGFONT value) */
sSpacing As Integer ' /* Amount to space between letters */
crBackColor As Long ' /* Background color */
lLCID As Long ' /* Locale ID */
dwReserved As Long ' /* Reserved. Must be 0 */
sStyle As Integer ' /* Style handle */
wKerning As Integer ' /* Twip size above which to kern char pair*/
bUnderlineType As Byte ' /* Underline type */
bAnimation As Byte ' /* Animated text like marching ants */
bRevAuthor As Byte ' /* Revision author index */
bReserved1 As Byte
End TypePrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Sub APIHighlight(colr As Long)
Dim Ret As Long, tmpcolr As Long
Dim cf As CHARFORMAT2With cf
.cbSize = LenB(cf) 'setup the size of the character format
.dwMask = CFM_BACKCOLOR 'what to test
If .crBackColor = 0 Then
.crBackColor = colr
Else 'NOT .CRBACKCOLOR...
.crBackColor = m_RTB.BackColor
End If
Ret = SendMessage(m_RTB.hwnd, EM_SETCHARFORMAT, SCF_SELECTION, cf)
End With 'CF
End SubPublic Sub AssignControls(R As RichTextBox)'Copyright 2002 Roger Gilchrist
'lace the Call to this in Form_Load or Sub Main
'RTBLooks.AssignControls RichTextBox1, CommonDialog1Set m_RTB = REnd SubPublic Sub APIHighlightHard(BColr As Long)
APIHighlight BColrEnd Sub