Jump to content

flash label


seesoe
 Share

Recommended Posts

hello,

how can i flash a labels background color, lets say every 1 second

for example, red black red black red black.....

Global $iPos = 0

Dim $aColor[2] = [0xFF0000, 0x000000]

GUICreate('MyGUI', 200, 100)
$Label = GUICtrlCreateLabel('My flash label', 10, 10, 66, 16)
GUICtrlSetColor(-1, 0xFFFFFF)
_Flash()
GUISetState()

AdlibEnable('_Flash', 1000)

Do
Until GUIGetMsg() = -3

Func _Flash()
    $iPos = 1 - $iPos
    GUICtrlSetBkColor($Label, $aColor[$iPos])
EndFunc   ;==>_Flash
Edited by Yashied
Link to comment
Share on other sites

thank you very much:) a little more complex than i imagined but fair enough :D

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include 'CommMG.au3'

#Region ### START Koda GUI section ### Form=c:\users\waseem\autoit projects\koda 1.7.2.0\forms\form1.kxf
$Form1 = GUICreate("Serial Switch", 186, 216, 455, 354)
$com_port_label = GUICtrlCreateLabel("COM Port Number", 24, 32, 90, 17)
$com_port = GUICtrlCreateInput("1", 120, 28, 41, 21)
$group_con = GUICtrlCreateGroup("Connection", 8, 72, 169, 65)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$group_settings = GUICtrlCreateGroup("Settings", 8, 8, 169, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$activate = GUICtrlCreateButton("Activate Serial Switch Box", 16, 96, 147, 25, 0)
$group_stat = GUICtrlCreateGroup("Status", 8, 144, 169, 65)
$barcode = GUICtrlCreateLabel("Barcode", 24, 168, 63, 25, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, 0x00FF00)
$data_link = GUICtrlCreateLabel("Data Link", 96, 168, 63, 25, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, 0xC0C0C0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $iPos = 0
Dim $aColor[2] = [0xFFFF00, 0xC0C0C0]
_Flash()
Func _Flash()
    $iPos = 1 - $iPos
    GUICtrlSetBkColor($data_link, $aColor[$iPos])
EndFunc

$connected = False

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        if $connected = True Then
            _Commcloseport()
        EndIf
        Exit
    EndIf

    If $msg = $activate Then
        If Not $connected Then
            Local $sportSetError
            If _CommSetPort(GUICtrlRead($com_port),$sportSetError, 4800, 8, 0, 1, 0) Then
                $connected = True
                AdlibEnable('_Flash', 300)
                GUICtrlSetBkColor($barcode,   0xC0C0C0)
                GUICtrlSetData($activate, "Deactivate Serial Switch Box")
            Else
                $connected = True
                AdlibEnable('_Flash', 300)
                GUICtrlSetBkColor($barcode,   0xC0C0C0)
                GUICtrlSetData($activate, "Deactivate Serial Switch Box")
            EndIf
        Else
            $connected = False
            AdlibDisable ( )
            GUICtrlSetBkColor($data_link, 0xC0C0C0)
            GUICtrlSetBkColor($barcode,   0x00FF00)
            GUICtrlSetData($activate, "Activate Serial Switch Box")
            _Commcloseport()
        EndIf
    EndIf
WEnd
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...