关于字体滚动(已解决)
本帖最后由 shenrenba 于 2010-9-21 21:43 编辑帮忙修改下问题1:滚动不自然问题2:如何获取字符占的总长度(不是字符的长度,比如像窗体的宽度100这样的数字)
要是能有其他精简的更好
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $y = 500
#Region ### START Koda GUI section ### Form=
GUICreate("测试", 500, 20, -1, 20, $WS_VISIBLE + $WS_POPUP, $WS_EX_TOOLWINDOW)
WinSetOnTop("测试", "", 1)
WinSetTrans("测试", "", 170)
$Label1 = GUICtrlCreateLabel("只是测试,即将开始", 0, 0, 500, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()
#EndRegion ### END Koda GUI section ###
AdlibRegister("gd", 300)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func gd()
Global $a
Local $sData = InetRead('http://www.verycd.com/statics/title.saying')
Local $sR = StringRegExp(BinaryToString($sData, 4), "'(.+?)\'", 3)
For $a = 0 To UBound($sR) - 2
$y = $y - 3
GUICtrlSetPos($Label1, $y, 0)
If $y < -200 Then
$y = 500
GUICtrlSetData($Label1, $sR[$a])
EndIf
Next
EndFunc ;==>gd 在读取网页源代码的时候会浪费一些时间,如果网速不好的话会使字幕滚动不自然,做了一下修改,你现优化一下吧
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $y = 500
Global $sR
Global $a
#Region ### START Koda GUI section ### Form=
GUICreate("测试", 500, 20, -1, 20, $WS_VISIBLE + $WS_POPUP, $WS_EX_TOOLWINDOW)
WinSetOnTop("测试", "", 1)
WinSetTrans("测试", "", 170)
$Label1 = GUICtrlCreateLabel("只是测试,即将开始", 0, 0, 500, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()
#EndRegion ### END Koda GUI section ###
jj()
AdlibRegister("gd", 100)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func jj()
Local $sData = InetRead('http://www.verycd.com/statics/title.saying')
Global $sR = StringRegExp(BinaryToString($sData, 4), "'(.+?)\'", 3)
EndFunc
Func gd()
For $a = 0 To UBound($sR) - 2
$y = $y - 1
GUICtrlSetPos($Label1, $y, 0)
If $y < -200 Then
$y = 500
jj()
GUICtrlSetData($Label1, $sR[$a])
EndIf
Next
EndFunc ;==>gd
Exit 关于获取字符总宽,论坛里有这样的例子,尤其是A版还专门写了这方面的函数,你可以查一下 在读取网页源代码的时候会浪费一些时间,如果网速不好的话会使字幕滚动不自然,做了一下修改,你现优化一下 ...
xyold1 发表于 2010-9-21 19:36 http://www.autoitx.com/images/common/back.gif
gd() 里面的 for循环不要.. 本帖最后由 xyold1 于 2010-9-21 19:59 编辑
回复 4# afan
{:face (460):}没细看,汗
附一修改后的
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $y = 500
Global $sR
Global $a=0
#Region ### START Koda GUI section ### Form=
GUICreate("测试", 500, 20, -1, 20, $WS_VISIBLE + $WS_POPUP, $WS_EX_TOOLWINDOW)
WinSetOnTop("测试", "", 1)
WinSetTrans("测试", "", 170)
$Label1 = GUICtrlCreateLabel("只是测试,即将开始", 0, 0, 500, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()
#EndRegion ### END Koda GUI section ###
jj()
AdlibRegister("gd", 5)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func jj()
Local $sData = InetRead('http://www.verycd.com/statics/title.saying')
Global $sR = StringRegExp(BinaryToString($sData, 4), "'(.+?)\'", 3)
EndFunc
Func gd()
;~ For $a = 0 To UBound($sR) - 2
$y = $y - 3
GUICtrlSetPos($Label1, $y, 0)
If $y < -200 Then
$y = 500
If $a>UBound($sR) - 2 Then
jj()
$a=0
EndIf
GUICtrlSetData($Label1, $sR[$a])
$a=$a+1
EndIf
;~ Next
EndFunc ;==>gd
Exit 用LABEL就是闪动,除非画出来。。
页:
[1]