Click to See Complete Forum and Search --> : You can do better !


bill brave
August 8th, 2001, 05:06 AM
Please show me where I wrong ?

When I want to use RichTextBox control, I must have richtx32.ocx ?

And richtx32.ocx can work if Riched32.dll or riched20.dll has been registered properly ?

Richtextbox control behavior does not depend on platform (win98 and win2k) if we use the same richtx32.ocx and riched20.dll?

If it correct then why I can not set background text color in Windows98 but I can in Windows2000.

(I got a sample at www.vbaccelarator.com)
Code is as follows :



public 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 Type

public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (byval hWnd as Long, byval wMsg as Long, byval wParam as Long, byval lParam as Long) as Long

Dim charf as CHARFORMAT2 'character format type for extended information
private Sub mnuFontBackColour_Click()
Dim ret as Long
on error GoTo error_cancel
charf.dwMask = CFM_BACKCOLOR
charf.cbSize = LenB(charf) 'setup the size of the character format
charf.crBackColor = vbRed
ret = SendMessageLong(rtfText1.hWnd, EM_SETCHARFORMAT, SCF_SELECTION, VarPtr(charf))
Exit Sub
error_cancel:
''MsgBox "cancel "
End Sub






Or could you show me any URL about that ?

Thank you very much.