Click here to Skip to main content
15,902,939 members
Home / Discussions / C#
   

C#

 
GeneralRe: Opacity Control Pin
led mike21-Jun-06 7:59
led mike21-Jun-06 7:59 
GeneralRe: Opacity Control Pin
Cubzfan21-Jun-06 8:07
Cubzfan21-Jun-06 8:07 
GeneralRe: Opacity Control Pin
led mike21-Jun-06 9:29
led mike21-Jun-06 9:29 
QuestionRe: Opacity Control Pin
Dustin Metzgar21-Jun-06 8:33
Dustin Metzgar21-Jun-06 8:33 
AnswerRe: Opacity Control Pin
Cubzfan21-Jun-06 9:31
Cubzfan21-Jun-06 9:31 
GeneralRe: Opacity Control Pin
Dustin Metzgar21-Jun-06 10:04
Dustin Metzgar21-Jun-06 10:04 
GeneralRe: Opacity Control Pin
Cubzfan21-Jun-06 10:10
Cubzfan21-Jun-06 10:10 
GeneralRe: Opacity Control Pin
Alexander Wiseman21-Jun-06 11:59
Alexander Wiseman21-Jun-06 11:59 
Tom,

I was glancing several times at this thread today, and something about the "black flicker" was sounding familiar. Anyway, I think I've figured out a solution, so I'll take a crack at it.

Slight disclaimer: I've only done one test with this, and I think it works, but I cannot be sure. Please let me know if it doesn't work.

Basically the solution is this: don't use the OptimizedDoubleBuffer and AllPaintingInWmPaint styles for the form which you are making more or less opaque. I was reading a short article on another site about Transparent Windows Forms Controls (you can look at it here[^] - some of the images are broken, but the article text is all that matters). On that page, the author notes that, when making truly transparent controls, you cannot use double buffering, because "The memory bitmap which is provided to your code has an opaque background and does not allow the carefully retained parent pixels to show through". This makes sense when you think about how double-buffering is done: basically, you are drawing to a buffer which is never displayed, and so I would imagine there is no previously drawn pixels on that buffer (which is necessary for transparency, because you need your pixels to be blended with the pixels which are behind them).

Give that a try on your Form, and see what happens. That is, in your Form's constructor (the one whose opacity you are changing) take out the two styles OptimizedDoubleBuffer and AllPaintingInWmPaint. I'm not sure why AllPaintingInWmPaint does not work properly, but in my test it gave a black flicker when it was set, even without the double-bufferring. I suspect it has to do with OnPaintBackground not being called when that style is set, and therefore the proper blending does not occur with the form background.

As a side note, I can make the background flicker black when I minimize and then restore my form. You did not mention this before, but I thought it might help to mention it so that you can check if your code produces the same effects as I have been throughout.

Hope that helps!

Sincerely,
Alexander Wiseman
GeneralRe: Opacity Control Pin
Cubzfan21-Jun-06 12:17
Cubzfan21-Jun-06 12:17 
GeneralRe: Opacity Control Pin
Alexander Wiseman21-Jun-06 13:11
Alexander Wiseman21-Jun-06 13:11 
GeneralRe: Opacity Control Pin
Cubzfan21-Jun-06 13:52
Cubzfan21-Jun-06 13:52 
GeneralRe: Opacity Control Pin
Cubzfan22-Jun-06 3:58
Cubzfan22-Jun-06 3:58 
GeneralRe: Opacity Control Pin
Dustin Metzgar22-Jun-06 4:24
Dustin Metzgar22-Jun-06 4:24 
GeneralRe: Opacity Control Pin
Cubzfan22-Jun-06 4:40
Cubzfan22-Jun-06 4:40 
GeneralRe: Opacity Control Pin
Dustin Metzgar22-Jun-06 5:00
Dustin Metzgar22-Jun-06 5:00 
GeneralRe: Opacity Control Pin
Alexander Wiseman22-Jun-06 5:08
Alexander Wiseman22-Jun-06 5:08 
JokeRe: Opacity Control Pin
Dustin Metzgar22-Jun-06 5:14
Dustin Metzgar22-Jun-06 5:14 
GeneralRe: Opacity Control Pin
Alexander Wiseman22-Jun-06 5:24
Alexander Wiseman22-Jun-06 5:24 
GeneralRe: Opacity Control Pin
Cubzfan22-Jun-06 5:11
Cubzfan22-Jun-06 5:11 
GeneralRe: Opacity Control Pin
Dustin Metzgar22-Jun-06 5:35
Dustin Metzgar22-Jun-06 5:35 
GeneralRe: Opacity Control Pin
Dustin Metzgar22-Jun-06 6:48
Dustin Metzgar22-Jun-06 6:48 
QuestionGraph to image Pin
Abel Castillo21-Jun-06 6:03
Abel Castillo21-Jun-06 6:03 
AnswerRe: Graph to image Pin
mikanu21-Jun-06 6:32
mikanu21-Jun-06 6:32 
GeneralRe: Graph to image Pin
Abel Castillo21-Jun-06 7:08
Abel Castillo21-Jun-06 7:08 
GeneralRe: Graph to image Pin
mikanu21-Jun-06 8:09
mikanu21-Jun-06 8:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.