找回密码
 加入
搜索
查看: 9536|回复: 24

[AU3基础] 动态显示时间,有时字体有抖动的感觉

 火.. [复制链接]
发表于 2013-2-23 21:20:31 | 显示全部楼层 |阅读模式
用AdlibRegister("date", 1000)动态显示时间时,有时随着时间的跳动,字体有抖动的感觉,让人觉的很不舒服,不知高手们有没有碰到过此类问题??
发表于 2013-2-23 21:34:47 | 显示全部楼层
上你的代码,不然怎么知道你那里写得不对
发表于 2013-2-24 05:20:07 | 显示全部楼层
动态显示时间有很多的,为什么要用AdlibRegister?
发表于 2013-2-24 12:16:59 | 显示全部楼层
看过使用图片更新的方法动态显示时间哈
发表于 2013-2-24 12:17:34 | 显示全部楼层
还有GDIPLUS实现的平滑动态显示时间的哈。。
发表于 2013-2-24 13:05:07 | 显示全部楼层
动态显示时间有很多的,为什么要用AdlibRegister?
jinefo 发表于 2013-2-24 05:20



    这里的原因并非 AdlibRegister()
发表于 2013-2-24 13:26:40 | 显示全部楼层
#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[6]
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
发表于 2013-2-24 17:22:53 | 显示全部楼层
顶7楼的代码
发表于 2013-2-24 17:43:03 | 显示全部楼层
代码上再加个皮肤就更好了
发表于 2013-2-25 07:42:20 | 显示全部楼层
7楼的代码直接收下,谢谢.
发表于 2013-2-25 16:00:46 | 显示全部楼层
回复 7# 3mile


    收下备用!
发表于 2013-2-25 17:48:21 | 显示全部楼层
回复 7# 3mile

DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int",  0x0026200A, "ptr", 0, "int*", 0)
$ghGDIPDll函数是哪里来的 DLL知识?
发表于 2013-2-25 19:33:26 | 显示全部楼层
7楼的代码我想加入个时间判断,一加入就失败
发表于 2013-2-25 21:27:13 | 显示全部楼层
本帖最后由 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
发表于 2013-2-26 12:08:18 | 显示全部楼层
7楼,14楼都做得很好啊,不知能否把标题栏去了,背景透明了,这样更好啊。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-27 05:53 , Processed in 0.086020 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表