Sign in to follow this  
Followers 0
stev379

Updating labels

2 posts in this topic

Below is cut from a bigger script. The issue is getting the label to update based on what is read from the combo box. How can this be set so it just updates the label once each time a new value is selected from the combo. As is it just keeps looping through. I tried with For's, Do's etc. and keep getting the same basic result.

Any help is greatly appreciated.

#include <Constants.au3>
#include <GUIConstants.au3>


Global $Main = GUICreate("Update Labels", 650, 390, 150, 75)

$Lcl_Rd01 = "Location1"
$Lcl_Rd02 = "Location2"
$Lcl_Rd03 = "Location3"

$Name_01 = "Name1"
$Name_02 = "Name2"
$Name_03 = "Name3"
$Name_04 = "Name4"
$Name_05 = "Name5"
$Name_06 = "Name6"

$IP1_01 = "IP # 1"
$IP1_02 = "IP # 2"
$IP1_03 = "IP # 3"

$IP_lbl = GUICtrlCreateLabel($Name_01 & "'s IP will be set to " & $IP1_01, 220, 250)

GUICtrlCreateLabel("Please select a location:", 200, 100, 235, 20)
$cbo_lcl = Guictrlcreatecombo($Lcl_Rd01, 220, 120)   
GUICtrlSetData(-1,$Lcl_Rd02 & "|" & $Lcl_Rd03,$Lcl_Rd01)

$cbo_Name = Guictrlcreatecombo($Name_01, 220, 200)   
GUICtrlSetData(-1,$Name_02 & "|" & $Name_03 & "|" & $Name_04 & _
                  $Name_05 & "|" & $Name_06,$Name_01)

GUISetState()
While 1
    $msg = GUIGetMsg()
    
    Select
        
    Case GUICtrlRead($cbo_Lcl) = $Lcl_Rd01 Or GUICtrlRead($cbo_Lcl) = $Lcl_Rd02 Or _
         GUICtrlRead($cbo_Lcl) = $Lcl_Rd03
        _IPLabels()
            

        
    Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_Exit

     
        Exit
        
    EndSelect

WEnd



Func _IPLabels()
    $cbo_NMVlu = GUICtrlRead($cbo_Name)
    $cbo_lclVlu = GUICtrlRead($cbo_Lcl)
    $i = 0
    
    Do 
        
    Select
        
    Case $cbo_NMVlu = ($Name_01) And $cbo_lclVlu = ($Lcl_Rd01)      
        GUICtrlSetData($IP_lbl, $Name_01 & "'s IP will be set to " & $IP1_01)
        
    ExitLoop
    
    Case $cbo_NMVlu = ($Name_01) And $cbo_lclVlu = ($Lcl_Rd02)
        GUICtrlSetData($IP_lbl, $Name_01 & "'s IP will be set to " & $IP1_02)
        
    ExitLoop
    
    Case $cbo_NMVlu = ($Name_01) And $cbo_lclVlu = ($Lcl_Rd03)          
        GUICtrlSetData($IP_lbl, $Name_01 & "'s IP will be set to " & $IP1_03)
        
    ExitLoop
    EndSelect   
    $i = $i + 1
    Until $i = 1    
EndFunc

Thanks!!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Below is cut from a bigger script.  The issue is getting the label to update based on what is read from the combo box.  How can this be set so it just updates the label once each time a new value is selected from the combo.  As is it just keeps looping through.  I tried with For's, Do's etc. and keep getting the same basic result.

Any help is greatly appreciated.

<snip>

Thanks!!

<{POST_SNAPBACK}>

How about a flag variable? This is what I do for my timer that clicks a button to refresh my display:

Do
   Sleep(10)
    If WinActive($hwndTally) = 1 Then
        HotKeySet("{F1}","AboutMe"); set the hotkey if the window's active
    Else
        HotKeySet("{F1}"); release the key when it's not active.
    EndIf

;;;; refresh button click ONCE every 5 minutes
   If Mod(@MIN, 5) = 0 And $mod = 0 Then
      ControlClick($hwndTally, "", $buttonRefresh, $primary, 1)
      $mod = 1
   ElseIf Mod(@MIN, 5) > 0 And $mod = 1 Then
      $mod = 0
   EndIf
;;;; end button click routine

   $msg = GUIGetMsg()
   Select
      Case $msg = $buttonRefresh
       ; re-read INI and update numbers.
         $ClaimZero = IniRead($fTally, "Claims", "Zero", "0")
         $ClaimCbis = IniRead($fTally, "Claims", "CBis", "0")
         $ClaimXbis = IniRead($fTally, "Claims", "XBis", "0")
            $ClaimError = IniRead($fTally, "Claims", "Error", "0")
         $ClaimTotal = $ClaimZero + $ClaimCbis + $ClaimXbis + $ClaimError
         GUICtrlSetData($viewitemZero, "Triple Zero|" & $ClaimZero)
         GUICtrlSetData($viewitemCbis, "C-Bis|" & $ClaimCbis)
         GUICtrlSetData($viewitemXbis, "X-Bis|" & $ClaimXbis)
         GUICtrlSetData($labelTotalNum, $ClaimTotal)
.
.
.
.
Until $msg = $gui_event_close Or $msg = $itemExit Or $msg = $buttonExit
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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