程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> Winform下無閃爍走馬燈效果實現(1)

Winform下無閃爍走馬燈效果實現(1)

編輯:關於C語言

最近需要在Winform項目中實現一個走馬燈的效果,一開始用了一些辦法比如移動Label控件,效果總是不太好,移動文本時總有閃爍的現象。後來找了一個國外的開源控件,應用了一下,效果還不錯。仔細閱讀了一下代碼,發現還有一些地方值得改進,現把代碼以及改動說明貼出來,和大家分享。

控件出處:http://www.codeproject.com/KB/miscctrl/ScrollingTextControlArtic.ASPx

我的改動:

1、DoubleBuffer 的設置

原代碼中用的是 this.SetStyle(ControlStyles.DoubleBuffer, true); 但一些網友反映這個標志在.net 2.0 以上版本無效。說句老實話,我也不是特別確信,MSDN上也沒有說明這一點。在我的.Net 2.0 系統中,兩種設置的效果似乎沒有太多區別。在一個國外網站上找到他們的區別,下面是原文:

ControlStyles == CS

AllPaintingInWMPaint == APWMP

OptimizedDoubleBuffer = ODB

DoubleBuffer = DB

An earlIEr permutation of the design called for ODB to simply be a combinationof DB, APWMP and UserPaint. Through several design changes, the two control styles are nearly synonymous, but they still have differences. Now that we've broken that, we may considerun-deprecating CS.DB to retain . Here is a more complete summary of the current design:

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 isn't an exact replacement for DB. ControlStyle

.ODB none none No Works, but without APWMP set you'll buffer foreground and background separately and will still see flicker. Control

.DoubleBuffered sets CS.ODB, CS.APWMP none No Works for most mainstream buffering needs. Getter is peculiar in that it only checks CS.ODB.
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved