简体   繁体   中英

VB6: Change focus color of RichTextBox (not SelColor)

Does anybody know if there is a way in VB6 to change the focus color in a RichTextBox? I'm referring to the color a text is surrounded with when you mark it with your cursor. I'm not talking of the SelColor property.

The focus color is black by default (different to the regular TextBox), and now that I try to realize black inverse text in the RichTextBox the default black focus color doesn't help to really show what the user has selected.

Anyone got a clue on the issue? Thanks in advance!

Artimidor

The focus color is black by default...

No, it isn't.

This isn't a "focus color" since focus means something entirely different from selection.

RichEdit controls (like the one inside the RichTextBox) show selection by complementing both the backcolor and forecolor for each character in the selection.

Black text on a white background inverts to produce the effect you refer to. But Blue text on a black background does something else entirely.

Not to complicate matters, the entire document has its own backcolor.

If you want to use white text on black, selecting it will simply invert to black on white. There isn't much you can do about that, and it is hard to imagine what you're hoping for - selected text to jump out with 3D shadowing???

Trying to intercept selections and re-color the text there probably isn't practical. I'm sure you could do it, but with a lot of effort and probably jerky results.

The SelColor property only helps set the forecolor of text. To set the backcolor (ie highlight, not to be confused with selection) requires subclassing. Easy subclassing though, no need to hook message processing as most people think subclassing involves.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM