Sign in to follow this  
Followers 0
rudolph

How can make a Label blinking

4 posts in this topic

Hi everyone.

I have a small question regarding label, I want to put a label in a GUI, but

It should be Blinking, I can not find in the properties or styles of a Label to get blinking,

Is it possible to do that?

I create a small example here :

CODE
#include <GUIConstants.au3>

$AForm1 = GUICreate("AForm1", 633, 447, 193, 125)

$Label1 = GUICtrlCreateLabel("Error Message Here", 192, 48, 98, 17)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Have you tried blinking your eyes real fast???

:runs: hehehehhe

Kat! Stop scaring the monkeys! (<--Valik Paraphrase there :))

Anyway...

#include <GUIConstants.au3>

$AForm1 = GUICreate("AForm1", 100, 30, -1, -1)
$Label1 = GUICtrlCreateLabel("Error Message Here", 5, 5, 98, 17)
GUISetState(@SW_SHOW)

While 1
    $Color1 = 0xFF0000;red
    $Color2 = 0xFFFFFF;White
    GUICtrlSetColor($Label1,$Color1)
    Sleep(200)
    GUICtrlSetColor($Label1,$Color2)
    Sleep(200)
WEndoÝ÷ Ù8Z·¥¹bIb쨻§´z0z÷«Ü"X+y«eÊÖ¤y¬Éúè*.¬e­æ¶*'¶)"ÙË
+·­µêðØ@t¸væî¶'ò¢çhÛaÌË*.(!·§¶Ú(¥êÚµëaz·¬¶ò¢á#­e:q/z{L¡×Ñ®+k'­:q/z{Dȧ^¢w°ØZvX¶­Âä°êëzÛ^¬¬¶f¤zz-zíè%¡¶¥½ªâi¹^±«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì)±½°ÀÌØí
½±½ÉQ½±ôÄ(ÀÌØí½É´ÄôU%
ÉÑ ÅÕ½Ðí½É´ÄÅÕ½Ðì°ÄÀÔ°ÌÔ°´Ä°´Ä¤)±½°ÀÌØí1°ÄôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíÉɽÈ5ÍÍ!ÉÅÕ½Ðì°Ô°Ô°äà°Äܤ)U%MÑMÑÑ¡M]}M!=¤)±¥¹± ÅÕ½Ðí ±¥¹¬ÅÕ½Ðì°ÈÀÀ¤()]¡¥±Ä($ÀÌØí¹5ÍôU%Ñ5Í ¤(%MÝ¥Ñ ÀÌØí¹5Í($%
ÍÀÌØíU%}Y9Q}
1=M($$%á¥Ð((%¹MÝ¥Ñ )]¹()Õ¹    ±¥¹¬ ¤($ÀÌØí
½±½ÈÄôÁáÀÀÀÀíÉ($ÀÌØí
½±½ÈÈôÁáí]¡¥Ñ($ÀÌØí
½±½ÉQ½±ô9½ÐÀÌØí
½±½ÉQ½±(%%ÀÌØí
½±½ÉQ½±ôÄQ¡¸($%U%
ÑɱMÑ
½±½È ÀÌØí1°Ä°ÀÌØí
½±½ÈĤ(%±Í($%U%
ÑɱMÑ
½±½È ÀÌØí1°Ä°ÀÌØí
½±½ÈȤ(%¹%)¹Õ¹

Enjoy, hope it helps

Edited by Paulie

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

An adaption to Paulie's code using TimerInit(), for those that don't want a main loop with sleeps.

#include <GUIConstants.au3>

Global $LabelClicked = 0, $BlinkState = 0, $BlinkStartTimer 
Global $TimerDelay = 200
Global $Color0 = 0x000000;black
Global $Color1 = 0xFF0000;red
Global $Color2 = 0xFFFFFF;White

$AForm1 = GUICreate("Click Label to toggle blinking", 300, 30, -1, -1)
$Label1 = GUICtrlCreateLabel("Click label to start Blinking", 5, 5, 200, 17)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            If $LabelClicked = 1 Then AdlibDisable()
                Exit
        Case $msg = $Label1
            If $LabelClicked = 0 Then
                $LabelClicked = 1
                AdlibEnable("BlinkLabel", $TimerDelay)
                GuiCtrlSetData($Label1, "Click label to stop Blinking")
            ElseIf $LabelClicked = 1 Then
                $LabelClicked = 0
                AdlibDisable()
                GUICtrlSetColor($Label1, $Color0)
                GuiCtrlSetData($Label1, "Click label to start Blinking")
            EndIf   
    EndSelect
WEnd

Func BlinkLabel()
    If $BlinkState = 0 And TimerDiff($BlinkStartTimer) > $TimerDelay Then 
        $BlinkStartTimer = TimerInit()
        $BlinkState = 1
        GUICtrlSetColor($Label1,$Color1)
    ElseIf $BlinkState = 1 And TimerDiff($BlinkStartTimer) > $TimerDelay Then
        $BlinkState = 0
        GUICtrlSetColor($Label1,$Color2)        
    EndIf
EndFunc

Cheers

Edit: doh Paulie beat me to it... lol

Edited by smashly

Share this post


Link to post
Share on other sites

Really Cool!!!!

Thanks so much to Paulie and smashly for helping me on this.

It works!!!!!!!!!! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0