Author Topic: [VB6] RTB Colors, SendMessage  (Read 4528 times)

0 Members and 1 Guest are viewing this topic.

Offline Hdx

  • The Hdx!
  • Full Member
  • ***
  • Posts: 311
  • <3 Java/Cpp/VB/QB
    • View Profile
[VB6] RTB Colors, SendMessage
« on: April 24, 2006, 12:09:41 pm »
Well, I kinda have a problem, I'm trying to append a rich text box, The text gets sent, but it is always the color of the background, so I can't see it.

How would you specify the color of the text when using SendMessage() to append it.
Code: [Select]
Dim X As CharFormat
X.cbSize = LenB(X)
X.crTextColor = vbRed
X.dwMask = CFM_COLOR

A = SendMessage(Z, WM_GETTEXTLENGTH, 0, 0) + 1
SendMessage Z, EM_SETSEL, A, 1
SendMessage Z, EM_SETCHARFORMAT, SCF_SELECTION, ByVal X
SendMessage Z, EM_REPLACESEL, 0, ByVal "Testing" & vbNewLine
SendMessage Z, EM_SCROLL, SB_LINEDOWN, 0
All of the constants are there proper formats, as far as I know:
Code: [Select]
Private Const WM_GETTEXTLENGTH As Long = &HE
Private Const EM_SETSEL& = &HB1
Private Const EM_REPLACESEL& = &HC2
Private Const EM_SCROLL& = &HB5
Private Const SB_LINEDOWN& = 1
Private Const SCF_SELECTION& = 1
Private Const EM_SETCHARFORMAT& = &H444
Private Const EM_GETCHARFORMAT& = &H43A
Private Const CFM_COLOR& = &H40000000

Private Type CharFormat
    cbSize As Long
    dwMask As Long
    dwEffects As Long
    yHeight As Long
    yOffset As Long
    crTextColor As Long
    bCharSet As Byte
    bPitchAndFamily As Byte
    szFaceName(32) As Byte
End Type
Z of corse is the handle for the RTB.
But please, Don't think I don't know how to use .SelColor -.- its not the point of this program, the point is to do it via sendmessage, for experiance.

Unless you know a way of Java using the SendMessage/FindWindow/FindWindowEx APis, it needs to be in VB, BTW, it does NOT have to be cross platform of corse :P
~-~(HDX)~-~
« Last Edit: April 24, 2006, 12:12:26 pm by HdxBmx27 »
http://img140.exs.cx/img140/6720/hdxnew6lb.gif
09/08/05 - Clan SBs @ USEast
 [19:59:04.000] <DeadHelp> We don't like customers.
 [19:59:05.922] <DeadHelp> They're assholes
 [19:59:08.094] <DeadHelp> And they're never right.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [VB6] RTB Colors, SendMessage
« Reply #1 on: April 24, 2006, 01:03:50 pm »
I can't answer your question, but I'd just warn you that sometimes the RTB is fickle.  For example, you can't set the EM_LINK style and specify its color in RTB 2.0, and RTB 3.0 you can't set custom link data (you need to let RTB handle it) if you want to set a custom color, and in RTB 5.0, you have an undocumented rich text box.  :P

Wish I could help you but I've moved beyond trying to manipulate that control with messages.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.