Click here to Skip to main content
15,127,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All :)

I've googled this for hours but nothing came out!

You probably remember those WIN98/2000 styled progress bars that have white background and blue (and smooth) progress indicator. They also had numeric percentage shown in the middle. And when the progress indicator reaches the number arround 50% the part of the number that lies over the blue indicator becomes white, while it remains blue over the white background. And when "the blue" passes over the '%' symbol the entire number is now white over blue background.

I need that effect. How can I draw text over multi-colored background, and the parts of the text that lie over dark background to be bright colored and vice-versa. I mean even if that means that specific characters to be splitted half bright half dark colored according to the color theme below them. (just like those progress bars)

I've tried using SetROP2 mode but it didn't work at all.

Any help will be appreciated! Thanks in advance! :)
Posted

1 solution

Grab the background image as a reference and draw your text on a copy of the background in memory. Do the color inversion after the text is rendered.

Grab the portion of the bitmap of the text/background that represents your % complete, and invert it, then copy that to the screen.

If you are using winforms, this could be done in a paint event (basic) or you could create a custom control (a little more involved).

You'll need to handle updates via a background thread (you could use BackgroundWorker for this)

Cheers.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900