***怎樣讓移動圖像顯示更快一些*** Hide Controls When Setting Properties to Avoid Multiple Repaints Every repaint is expensive. The fewer repaints Visual Basic must perform, the faster your application will appear. One way to reduce the number of repaints is to make controls invisible while you are manipulating them. For example, suppose you want to resize several list boxes in the Resize event for the form: Sub Form_Resize () Dim i As Integer, sHeight As Integer sHeight = ScaleHeight / 4 For i = 0 To 3 lstDisplay(i).Move 0, i * sHeight, _ ScaleWidth, sHeight Next End Sub This creates four separate repaints, one for each list box. You can reduce the number of repaints by placing all the list boxes within a picture box, and hiding the picture box before you move and size the list boxes. Then, when you make the picture box visible again, all of the list boxes are painted in a single pass: 在vb中用move方法移動圖片時,速度有些慢,當圖片很大時,這時可以用下面的方法: Sub Form_Resize () Dim i As Integer, sHeight As Integer picContainer.Visible = False picContainer.Move 0, 0, ScaleWidth, ScaleHeight sHeight = ScaleHeight / 4 For i = 0 To 3 lstDisplay(i).Move 0, i * sHeight, _ ScaleWidth, sHeight Next picContainer.Visible = True End Sub Note that this example uses the Move method instead of setting the Top and Left properties. The Move method sets both properties in a single operation, saving additional repaints.
創(chuàng)新互聯(lián)主要從事網(wǎng)站建設、網(wǎng)站制作、網(wǎng)頁設計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務。立足成都服務石阡,十載網(wǎng)站建設經(jīng)驗,價格優(yōu)惠、服務專業(yè),歡迎來電咨詢建站服務:18982081108
這個應該可以試試spy++,檢測下鼠標移動到的device,然后做出文件操作!
給你提供一個思路,
你既然知道BITBLT,基礎不會太差的,我就簡單明了的說下.
從你的問題看,最簡單的方法,其實只需要一個picturebox.
然后定義一個4*3的Image數(shù)組img(3,2).橫4縱3.
img(0,0)裝入第一張圖片,
img(1,0)裝入第二張圖片,
img(3,0)不使用.
以此類推,img(3,1)也不使用,
####但是,img(3,2)雖然不裝入圖片,
####其功能卻和你思路中的"沒圖片的picturebox"相同.
我們可以定義兩個變量x
,
y
As
Integer
初始的時候x=3,y=2,應該看出來了吧?這兩個變量用來保存空白image的位置,方便你移動圖片.
有了這種結構,剩下的工作就很簡單了.
寫一個方法來處理按鍵消息.例如:
如果此時x=1,y=1,用戶按下了"上鍵",那么img(x,y)和Image(x,y-1)交換.然后y=y-1
如果此時x=1,y=1,用戶按下了"左鍵",那么img(x,y)和image(x-1,y)交換.然后x=x-1
其實就是移動空白位置的方法.但是要注意,img(3,0),img(3,1),img(3,2)這三個特殊位置要做特殊處理.
最后,寫個for循環(huán),把img數(shù)組顯示到picturebox上面就可以了.
很簡單吧?不知道我說得是否清楚?
希望對你有所幫助.
不是語言讓圖片動起來的,而是圖片本身就能動,例如gif格式圖片本身就是動畫。如果你講的是圖片在網(wǎng)頁上移動,而不是圖片本身內(nèi)容的動作,那么不是vb.net的功能必須用java腳本來實現(xiàn)。
Public?Class?Form1
Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load
? Button1.BackgroundImage?=?My.Resources.a
End?Sub
Private?Sub?Button1_MouseEnter(ByVal?sender?As?Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.MouseEnter
? Button1.BackgroundImage?=?My.Resources.b
End?Sub
Private?Sub?Button1_MouseLeave(ByVal?sender?As?Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.MouseLeave
? Button1.BackgroundImage?=?My.Resources.a
End?Sub
End?Class
當然,你先得制作兩張大小一樣的圖片