问题
I want to avoid flickering in a panel of my application, after googling from 4 monthgs ago, after trying subclassed panels, after asking here two or three times, after asking in other forums... nobody has the solution but today I've found the solution by a miracle in this last answer: Is their a way to stop the picturebox from flickering when being resized?
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H2000000
Return cp
End Get
End Property 'CreateParams
Now I want to know what really does that lines of code., I need to understand what is doing that code to my application,
is a good way to get avoid of flickering?
MSDN says :
"The CreateParams property should not be overridden and used to adjust the properties of your derived control"
but why not?, that is the only way I found to really get out my panel flickering so that's why I want to know more about the code I posted above, I want to understand all the orders, also the beneffits of that sub and the negatives, all things are welcome...
Someone can explain me more about that code?
UPDATE:
I've tested the "flickering solution" in all my applications and yes its a flickering solution... but has the negative point 'cause my programs turns around -200% speed more slow, I mean when using that override sub the programs turns awesomelly more slow like x6 times more slow so is not a good idea to use the override sub as is.
Someone knows if I can avoid the flickering without ralentize my application?
回答1:
Every time you redraw a control, You also have to redraw the background; an operation that your application might not have claimed resources to accomplish. The solution that you're using basically sets a flag to indicate that you want your form and everything it draws to be double buffered. You can consume an unnecessary amount of resources with this. Instead, you could set the double buffered property to true on each object that is involved in your image re-size. Computers have limited resources and you should preserve as many as possible. This is the reason why Microsoft predefined so many parameters and resource freeing procedures.
Edit: PictureBox is double buffered by default to handle the onpaint event. You still require double buffer on the background objects.
来源:https://stackoverflow.com/questions/16455305/flickering-and-createparams