Shoutbox

problem getting the bg color in a RichTextBox - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: problem getting the bg color in a RichTextBox (/showthread.php?tid=30123)

problem getting the bg color in a RichTextBox by Mithrandir on 08-18-2004 at 04:40 PM

I'm programming in VB6 and using the following code to retrieve the background color of the selected text in a RichTextBox:

code:
Public Function GetTextBackColor(ByVal rtfBox As RichTextBox) As Long
    Dim tCF2 As CHARFORMAT2
    tCF2.dwMask = CFM_BACKCOLOR
    tCF2.cbSize = Len(tCF2)
    Call SendMessage(rtfBox.hWnd, EM_GETCHARFORMAT, ercSetFormatSelection, tCF2)
    GetTextBackColor = tCF2.crBackColor
End Function

It works well, but when the background is not set (in that case we commonly see a white one), it returns 0; and it also returns 0 for a black background. So how can I make the difference between the two?

Please help me!
RE: problem getting the bg color in a RichTextBox by RaceProUK on 08-18-2004 at 09:53 PM

Zero would be for black yes, but in this case it appears to also be used for default... I admit this is confusing. Double-check the RichTextEdit documentation on MSDN for clarification.