动态显示时间,有时字体有抖动的感觉
用AdlibRegister("date", 1000)动态显示时间时,有时随着时间的跳动,字体有抖动的感觉,让人觉的很不舒服,不知高手们有没有碰到过此类问题?? 上你的代码,不然怎么知道你那里写得不对 动态显示时间有很多的,为什么要用AdlibRegister? 看过使用图片更新的方法动态显示时间哈 还有GDIPLUS实现的平滑动态显示时间的哈。。 动态显示时间有很多的,为什么要用AdlibRegister?jinefo 发表于 2013-2-24 05:20 http://www.autoitx.com/images/common/back.gif
这里的原因并非 AdlibRegister() #include <ComboConstants.au3>
#include <Date.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <ButtonConstants.au3>
Global Const $iW = 350
Global Const $iH = 81
Global Const $gW = 464
Global Const $gH = 288
Global Const $hGUI = GUICreate("", $gW, $gH)
Global Const $bgc = "F0F0F0"
GUISetBkColor("0x" & $bgc, $hGUI)
Global Const $idPic = GUICtrlCreatePic("", 72, 40, $iW, $iH)
Global Const $bExit= GUICtrlCreateButton("Exit", 256, 150, 139,45)
GUICtrlSetImage(-1,"shell32.dll",15)
GUISetState(@SW_SHOW)
Global $nMsg
_GDIPlus_Startup()
Global $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int",0x0026200A, "ptr", 0, "int*", 0)
$hBitmap = $hBitmap
Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hContext, 2)
DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hContext, "int", 4)
_GDIPlus_GraphicsClear($hContext, "0xFF" & $bgc)
Timer()
AdlibRegister("Timer", 1000)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $bExit
AdlibUnRegister("Timer")
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
Exit
EndSwitch
WEnd
Func Timer()
_GDIPlus_GraphicsDrawString($hContext, _NowTime(), 0, 0, "Arial", 50)
Local $hHBITAMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_WinAPI_DeleteObject(GUICtrlSendMsg($idPic, 0x0172, 0, $hHBITAMP))
_WinAPI_DeleteObject($hHBITAMP)
_GDIPlus_GraphicsClear($hContext, "0xFF" & $bgc)
EndFunc 顶7楼的代码 代码上再加个皮肤就更好了 7楼的代码直接收下,谢谢. 回复 7# 3mile
收下备用! 回复 7# 3mile
DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int",0x0026200A, "ptr", 0, "int*", 0)
$ghGDIPDll函数是哪里来的 DLL知识? 7楼的代码我想加入个时间判断,一加入就失败 本帖最后由 happytc 于 2013-2-25 21:38 编辑
回复 7# 3mile
呵,效果不错!
就是略显复杂了点。我试了下传统思维做法,其实也能接受的效果的。
GUICreate("Timer show", 300, 100)
GUISetFont(50, 800)
$nHourLabel = GUICtrlCreateLabel('', 10, 10, 100, 80)
$nMinLabel = GUICtrlCreateLabel('', 110, 10, 100, 80)
$nSecALabel = GUICtrlCreateLabel('', 210, 10, 40, 80)
$nSecBLabel = GUICtrlCreateLabel('', 245, 10, 50, 80)
GUISetState()
AdlibRegister("_Timer", 1000)
Do
Until GUIGetMsg() == -3
Func _Timer()
Local Static $iSecA, $iSecB, $iMin, $iHour
If StringTrimRight(@SEC, 1) <> $iSecA Then
GUICtrlSetData($nSecALabel, StringTrimRight(@SEC, 1))
$iSecA = StringTrimRight(@SEC, 1)
EndIf
If StringTrimLeft(@SEC, 1) <> $iSecB Then
GUICtrlSetData($nSecBLabel, StringTrimLeft(@SEC, 1))
$iSecB = StringTrimLeft(@SEC, 1)
EndIf
If @MIN <> $iMin Then
GUICtrlSetData($nMinLabel,@MIN & ':')
$iMin = @MIN
EndIf
If @HOUR <> $iHour Then
GUICtrlSetData($nHourLabel,@HOUR & ':')
$iHour = @HOUR
EndIf
EndFunc
7楼,14楼都做得很好啊,不知能否把标题栏去了,背景透明了,这样更好啊。
页:
[1]
2