Transparent label flicker when drawn on form

B

Bob Dankert

I am having troubles with forms that have a large number of labels with
transparent backgrounds causing a good deal of flicker while originally
drawing the form. I have created a new label class which inherits from
Label and has UserPaint and DoubleBuffer set in the control styles, and this
makes no difference. In 2.0, I set double buffering on the form and this
also made no difference.

Anyone have any suggestions on how to deal with this? A form with 100
transparent background labels should not flicker the way it does on my PC
(Athlon 64 3500, 512MB) - you can see each label being drawn individually.
I have tried my test case on numerous computers and the same thing happens
on each.

Thanks,

Bob Dankert
 
F

Frank Hileman

The solution is to create a single custom Control-derived class where you
draw the labels yourself in OnPaint. In this way all labels are updated to
the screen with a single back-to-front buffer transfer. Or you could use a
vector graphics library to get the same effect.

Regards,
Frank Hileman

check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
 
B

Bob Dankert

You suggest I draw the label text myself on hundreds of labels, on hundreds
of form's? This seems a little crazy and would take TONS of work. The
labels' text frequently update on the form's and the labels are all over the
form's - not an easy feat. (I assume you mean in the onpaint event for the
form - if not, please explain more).

Thanks,

Bob
 
F

Frank Hileman

Transparent controls will never work well in windows forms. So you must
either perform the paint yourself, or use some tool to do it for you. It is
not necessarily tons of work.

I was speaking of a single Control-derived class, docked to cover the Form.

Regards,
Frank Hileman

check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
 
J

Jeffrey Tan[MSFT]

Hi Bob,

Thanks for your post.

How do you create the transparent Label contro? Can you show us a little
sample project to demonstrate this problem? Then we can give it a good
understanding. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
B

Bob Dankert

Jeffrey,

I use standard System.Windows.Forms.Label controls and set the
Label.Background to Color.Transparent. If I create 100 of these on a form,
all with transparent backgrounds, the form gets pretty slow drawing all of
the labels. I'm not doing anything really special I don't think with this,
just real basic and simple. If there is an easier answer than drawing all
of the labels text manually in a paint event, I would certainly be
interested.

Thanks,

Bob Dankert
 
J

Jeffrey Tan[MSFT]

Hi Bob,

Thanks for your feedback.

Yes, after setting a background image of the form, and creating 100
transparent label on the form, I really got some drawing performance issue.
I found that this issue only occurs with a bitmap in the background, if we
use a color background, not an image, it does not have such performance
issue.

I will spend a little more time in this issue, and reply to you ASAP. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
B

Bob Dankert

Thanks a lot Jeffrey, I will look at this and will post back if I have any
problems.

No problem on the wait - I've spent months with the problem and have not had
time to try to fix it until now.

Thanks again,

Bob Dankert
 
J

Jeffrey Tan[MSFT]

Ok, if you have any further question, please feel free tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
B

Bob Dankert

Jeffrey,

I have noticed that this project is much slower in the 2.0 framework. If
you change the form WindowState to maximized and change the for loop to draw
from 0->10 to 0->33 for both loops, you will notice this is much, much
faster in .net 1.1 than in .net 2.0. Any ideas on how to get the 2.0
version of this close to the 1.1 speeds?

Thanks,

Bob Dankert
 
J

Jeffrey Tan[MSFT]

Hi Bob,

Thanks for your feedback. Yes, I can reproduce this behavior on Whidbey. I
will spend some more time in this issue. I will update you ASAP. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Bob,

Sorry for letting you wait.

Oh, it seems that I missed some optimal code in my test sample.

Currently, I have created a sample project in Whidbey with the same sample
code, which works as the same performance as the VS.net2003 sample.

Also, I have created an app.config file for the VS.net2003 project, which
uses <requiredRuntime> element to force it use the .Net2.0 runtime. It
behaves the same performance as using the .Net1.1 runtime.

So it seems that I can not reproduce out your problem on my side.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

The app.config I used is listed below:
<configuration>
<startup>
<supportedRuntime version="v2.0.50727">
</startup>
</configuration>

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
B

Bob Dankert

Jeffrey,

I will play with this to see if I can eliminate the performance difference
in the sample you sent. I will let you know if I am not able to get this
working in 2.0 as well as it does in 1.1.

Thanks,

Bob
 
J

Jeffrey Tan[MSFT]

Ok, if you have any further issue, please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top