Jump to content

How to set default color for RichEdit text?


Recommended Posts

According to MSFT, it's possible to use a SetDefaultCharFormat function to set the default color for a RichEdit control:

Quote

You can also get and set the "default character formatting," which is the formatting applied to any subsequently inserted characters. For example, if an application sets the default character formatting to bold and the user then types a character, that character is bold. To get and set default character formatting, use the GetDefaultCharFormat and SetDefaultCharFormat member functions.

link to MSFT docs

But Au3 doesn't include these among the many RichEdit functions that it does.

What is the proper way to set the default text color for all text entered into a RichEdit control?

Thanks in advance for any help.

 

Edited by qwert
Link to post
Share on other sites
28 minutes ago, TheXman said:

Isn't that what _GUICtrlRichEdit_SetCharColor() does?

I thought so. But what I'm experiencing is that, very occasionally, text that's displayed in a control is changing to transparent text on a white background. It seems to be related to deleting some text at the end of the control ... or inserting text somewhere other than at the end. The text is there (you can view it with a Select All).

So what I'd like to do is to force the control's default color to black. Supposedly, setting the default color keeps "transparent" from ever taking effect.

Thanks for your response.

Link to post
Share on other sites

Yes, normally I would attempt to build an example script. But the case I'm encountering is so subtle that I haven't been able to isolate anything with a test script. It only occurs in my runtimes and only after dozens of uses (1 out of 50 edits?).

But I think I'm on the tail of something. It seems centered around sending a message to the rich edit control with the EM_SETCHARFORMAT parameter.

I found this reference on these forums:  forum post

(see the _SetColor() function)

And here's another level of detail from MSFT:  MSFT link

Unfortunately, I've never modified a rich edit control in this way, so the going is slow.

Thanks for responding.

 

Link to post
Share on other sites

After much testing, it seems that adding $WS_EX_TRANSPARENT to the RichEdit Create avoids the problem that I was trying to resolve on this thread (white text displayed on a white background following certain edit actions).

Unless another problem shows up, I'll sideline any further investigation ... although, ultimately, I'd like to know how to set the low-level defaults for a Rich Edit Control. I've concluded that EM_SETCHARFORMAT and EM_SETCHARFORMAT2 bring a lot to the table ... but the associated data structures and the send message calls aren't easy, at least not that I could see.

Thanks for the interest shown.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...