Progress Bar with inverted text

  • Thread starter Thread starter UWWI
  • Start date Start date
U

UWWI

Guest
Hi,


I am using VS 2019 Community Edition with NET 4.8.


Currently I am trying to draw inverted text into a progress bar. The text is at the moment only the percentage, such as 35%.

I.e.: Drawing that text is not a problem at all, I do that in the "OnPaint"-event of the UserControl I am using with e.Graphics.DrawString.

But when the progress bar meter itself overlaps/intercepts the text, the text becomes invisible, as the meter colour and the text forecolor are both the same.

So, I thought, I try BitBlt or PatBlt and draw several bitmaps in memory, mix and match them, trying SCRINVERT, PATINVERT and all of that.

None worked for me, although the API functions "do something", but they do not invert the text. I understood that inversion with XOR means: If (Source-Pixel = Destination Pixel) Then Resulting Pixel = Transparent (similar to 1 XOR 1 = 0). Hence I would have expected to see the background of the progress bar then.

This is not the case, the text will simply be overdrawn/invisible.

I searched the internet for days now, the only solution that comes close to what I like to achieve is this:

https://stackoverflow.com/questions/40953598/invert-text-color-depending-on-backcolor

But also this one does not work as expected. It does change the colour, the text is still visible but it does not actually invert the colour ("inversion" in the sense mentioned above).

Is there someone out there giving me a good example on how to do that? I couldn't find any in .NET language.

Thanks a lot

Uwe

Continue reading...
 
Back
Top