Click to See Complete Forum and Search --> : Transparency effect


Ecuador -=[NM]=-
May 2nd, 2004, 02:37 AM
Hi there,

I shortly wrote a progressbar using start 'n end colors to create a gradient bar. This works out fine, but I have a problem when it comes to displaying the text as soon as the bar reaches 50%.

At start ( < 50% ) the bkColor = 0,0,0 and opaque, but when I change it to transparent and the bar increases, the text displayed gets messed up, because it does not update and remove the prior text display.

My workaround was to keep the background opaque and then rip out the latest color values and apply it to the bkColor. The
problem then is that the bar "pops out" meaning that the 50% display gets colored before the bar reaches, say 51 or 52% that would cover this color popup.

Is there any possibility to create the text transparent without using Invalidate() or Update() ? If I do so, the bar doesn't get painted anymore...

:mad:

Marc G
May 2nd, 2004, 06:52 AM
I don't know how you are drawing your code, but the best thing is that you redraw your entire bar each time.
So when the % value changes, you do an invalidate, and in your OnPaint handler you draw the entire progress bar.

Ecuador -=[NM]=-
May 2nd, 2004, 07:04 AM
yea I know you're right, coz I use two different methods to advance the progress bar. One time with pb_1->Advance(); the other with pb_1->SetPosition(int x);

while the SetPosition will redraw the bar due to the loop integrated to calculate the color fade, the advance method does not. Yea, surely I could remove the Advance function but when I use the SetPosition only, the screen sometimes flickers which does not look that professional. Is there any possibility to turn the flickering off or at least reduce it ?

thx for now

ecu@dor :)

Marc G
May 2nd, 2004, 10:28 AM
To reduce flickering, you should use a memory device context. Draw your entire progressbar (including text) into this memory device context and then blit this memDC to the actual screen DC.

Ecuador -=[NM]=-
May 2nd, 2004, 11:13 AM
ummm - yea, you were right... now it draws perfectly and no flickering occurs. So I saved one function :)... thanks a lot !!!

:D

Greets

ecu@dor

Marc G
May 2nd, 2004, 02:40 PM
You are welcome :wave: