Click to See Complete Forum and Search --> : SendMessage to RichTextBox


bill brave
August 3rd, 2001, 03:58 AM
Please tell me why the following code works on Win2K Server but not in Win9x.

I use the same version of Richtx32.ocx, riched32.dll and riched20.dll.


public Type CHARFORMAT2
.....
.....
End Type

dim charf as CHARFORMAT2
......
charf.cbSize = LenB(charf)
charf.dwMask = CFM_BACKCOLOR
charf.crBackColor = nColor

ret = SendMessageLong(rtfText1.hwnd, EM_SETCHARFORMAT, SCF_SELECTION, VarPtr(charf))
.....

Cimperiali
August 3rd, 2001, 04:08 AM
Is it a typo or it exists a SendMessageLong function or you have subclassed SendMessage.
Try with:
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

bill brave
August 3rd, 2001, 04:15 AM
Thank you for your reply.
I declared function as :


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

Cimperiali
August 3rd, 2001, 04:43 AM
Matter is I found no information about SendMessageLong...

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

bill brave
August 3rd, 2001, 05:00 AM
Thanks.
But that code runs on Win2K

Cimperiali
August 3rd, 2001, 05:07 AM
Yes, as you provided the alias "SendmessageA". Have a try declaring it like I posted (even if I am afraid this is not the matter: some differences may exist on parameters type in win2K and win9x) .

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater