The recent need to implement a merry-go effect in the WinForm project, the beginning of a number of methods such as mobile label control, the effect is always not very good, moving text always has a flicker phenomenon. Later found a foreign open source control, applied a bit, the effect is not bad. Carefully read the code, found that there are some areas worth improving, and now put the code and changes to the description, and share with you.
Source of Control: http://www.codeproject.com/KB/miscctrl/ScrollingTextControlArtic.aspx
My changes:
1, the DoubleBuffer setting
This is used in the original code. SetStyle (Controlstyles.doublebuffer, true); But some netizens have reflected that this sign is not valid for. NET 2.0 version. To tell you the truth, I'm not particularly sure that MSDN doesn't say that. In my. NET 2.0 system, the effects of the two settings do not seem to be much different. On a foreign website to find their differences, the following is the original:
ControlStyles = CS
AllPaintingInWmPaint = = APWMP
Optimizeddoublebuffer = ODB
DoubleBuffer = DB
An earlier permutation of the "design called" for ODB to simply is a combinationof DB, APWMP and UserPaint. Through several design changes, the two control styles are, nearly synonymous, but, they still have. Now so we ' ve broken that and we may considerun-deprecating CS. DB to retain. Here's a more complete summary of the:
Mechanism |
Side effects |
Other flags required to work |
Require apwmp? |
Notes |
ControlStyle
. Db |
None |
APWMP, UserPaint |
Yes |
We are considering not deprecating this flag because ODB ' t a isn for DB. |
ControlStyle
. ODB |
None |
None |
No |
Works, but without apwmp set for you ' ll-buffer foreground and background separately and'll still the flicker. |
Control
. DoubleBuffered |
Sets CS. ODB, CS. Apwmp |
None |
No |
Works for most mainstream buffering needs. The Getter is peculiar the it only checks CS. ODB. |