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!