happytc 发表于 2013-2-26 21:57:21

回复 15# zym3138


    你加上不就行了嘛,这个都还要‘这样更好了’…………

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MenuConstants.au3>
#include <WinAPI.au3>
$hgui = GUICreate("Timer show", 285, 80, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST), WinGetHandle(AutoItWinGetTitle()))
GUISetFont(50, 800)
$nHourLabel = GUICtrlCreateLabel('', 0, 0, 100, 80)
GUIctrlSetBkColor(-1,0xFFFFFF)
$nMinLabel = GUICtrlCreateLabel('', 100, 0, 100, 80)
GUIctrlSetBkColor(-1,0xFFFFFF)
$nSecALabel = GUICtrlCreateLabel('', 200, 0, 40, 80)
GUIctrlSetBkColor(-1,0xFFFFFF)
$nSecBLabel = GUICtrlCreateLabel('', 235, 0, 50, 80)
GUIctrlSetBkColor(-1,0xFFFFFF)
GUISetState(@SW_SHOW, $hgui)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xFFFFFF, 255)
AdlibRegister("_Timer", 1000)

While True
        Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
            Exit
      Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_MOVE + $HTCAPTION, 0)
    EndSwitch
WEnd

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


My2009 发表于 2013-3-3 10:45:37

我的代码如下:Local $Dtime,$Date
GUICreate("Timer show", 300, 100)
GUISetFont(50, 800)
_DT()
GUISetState()
Do
Until GUIGetMsg() == -3

Func _DT()
    GUISetFont(18, 800, 1)
        $Date = GUICtrlCreateLabel(@YEAR & "-" & @MON & "-" & @MDAY & " " &@HOUR & ":" & @MIN & ":" & @SEC , 10, 10, 250, 25)
    ;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetColor(-1, 0x0B1746)
        AdlibRegister("date", 1000)
EndFunc

Func date()
    Dim $Dtime = GUICtrlSetData($Date, @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC)
EndFunc使用后会出现闪动的现象,原理与上面的两位是一样的,只是采集的方式有所不同

w49395950 发表于 2013-3-21 10:29:08

最后一位好且实用 方便!

h20040606 发表于 2013-3-21 12:46:24

太好了,14楼,7楼的方法

h20040606 发表于 2013-3-21 12:46:56

太好了,14楼,7楼的方法

asionwu 发表于 2013-3-22 00:08:13

用GDI比较好点

haijie1223 发表于 2013-3-22 07:51:35

还是想看看楼主的代码,好分析问题

烟雨 发表于 2013-3-23 13:33:42

顶14楼代码

sh1536 发表于 2020-2-24 15:24:09

happytc 发表于 2013-2-25 21:27
回复 7# 3mile




拖动窗口时间会停,请问有没有解决方法?

tubaba 发表于 2020-2-25 14:57:07

#include <Date.au3>

Local $Dtime,$Date
GUICreate("Timer show", 300, 100)
GUISetFont(50, 800)
_DT()
GUISetState()
Do
Until GUIGetMsg() == -3

Func _DT()
    GUISetFont(18, 800, 1)
      $Date = GUICtrlCreateLabel('' , 10, 10, 250, 25)
    ;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
      GUICtrlSetColor(-1, 0x0B1746)
      AdlibRegister("date", 50)
EndFunc

Func date()
        Local Static $g_sTime
        Local $sTime = $g_sTime
        $g_sTime = _Now()
        If $sTime <> $g_sTime Then GUICtrlSetData($Date, $g_sTime)
EndFunc
页: 1 [2]
查看完整版本: 动态显示时间,有时字体有抖动的感觉