无闪烁移动
Picture控件+Timer控件=无闪烁移动。
事例:
form = picture1 + timer1
设置 timer1.间隔=50
复制下面代码看效果
事例:
form = picture1 + timer1
设置 timer1.间隔=50
复制下面代码看效果
- VBScript code
-
'*******************cike技术交流群***********************
'
'BitBlt 目标hDC, 目标X, 目标Y, 图像高, 图像宽, 源hDC, 源X, 源Y, 光栅运算常数
'【函数】
'BitBlt
'【操作系统】
'Win9X: Yes
'WinNT: Yes
'【声明】
'BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
'【说明】
'将一幅位图从一个设备场景复制到另一个?源和目标DC相互间必须兼容
'【返回值】
'Long,非零表示成功,零表示失败。会设置GetLastError
'【其它】
'在NT环境下,如在一次世界传输中要求在源设备场景中进行剪切或旋转处理,这个函数的执行会失败
'如目标和源DC的映射关系要求矩形中像素的大小必须在传输过程中改变,那么这个函数会根据需要自动伸缩、旋转、折叠、或切断,以便完成最终的传输过程
'【参数表】
'hDestDC -------- Long,目标设备场景
'x,y ------------ Long,对目标DC中目标矩形左上角位置进行描述的那个点。用目标DC的逻辑坐标表示
'nWidth,nHeight - Long,欲传输图象的宽度和高度
'hSrcDC --------- Long,源设备场景。如光栅运算未指定源,则应设为0
'xSrc,ySrc ------ Long,对源DC中源矩形左上角位置进行描述的那个点。用源DC的逻辑坐标表示
'dwRop ---------- Long,传输过程要执行的光栅运算
'
'=================== --- cike技术交流群 16874787---===================
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Const speed As Byte = 1
Dim wid%
Dim hei%
Dim dc&
Const text = " cike技术交流群 16874787 "
Private Sub Form_load()
dc = Picture1.hDC
Picture1.CurrentX = 0
Picture1.CurrentY = 0
Picture1.Print text
Picture1.ScaleMode = vbPixels
wid = Picture1.TextWidth(text)
hei = Picture1.TextHeight(text)
Picture1.Width = wid * Screen.TwipsPerPixelX
Picture1.Height = hei * Screen.TwipsPerPixelY
End Sub
Private Sub Timer1_Timer()
Dim i%
For i = 0 To speed
BitBlt dc, wid + 1, hei + 1, 1, hei, dc, 0, 0, &HCC0020 ' &hcc0020 is equvilent to vbSrcCopy
BitBlt dc, 0, 0, wid, hei, dc, 1, 0, &HCC0020
BitBlt dc, wid, 0, 1, hei, dc, wid + 1, hei + 1, &HCC0020
Next i
Picture1.Refresh
End Sub
成功者找方法,失败者找借口!