Jump to content

Does this label just write a new label on top of another?


 Share

Recommended Posts

My thought of this script is that it probably just creates a new label on top of an old label. I would think there should be a better way to do this. Is there?

Thanks in Advance.

#include <GUIConstants.au3>

Global $x = 0, $y = 0
#Region ### START Koda GUI section ### Form=c:\documents and settings\[]\my documents\personal\autoit\koda forms\calls counter.kxf
$Form1_1 = GUICreate("Tracking", 371, 457, 325, 163)
$Group1 = GUICtrlCreateGroup("AGroup1", 24, 16, 321, 201)
$Label1 = GUICtrlCreateLabel("0", 164, 88, 13, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Add 1", 56, 120, 97, 65, 0)
$Button2 = GUICtrlCreateButton("Minus 1", 184, 120, 105, 65, 0)
$Label2 = GUICtrlCreateLabel("Number of Calls", 104, 32, 138, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("AGroup1", 24, 229, 321, 201)
$Label3 = GUICtrlCreateLabel("0", 164, 301, 13, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("Add 1", 56, 333, 97, 65, 0)
$Button4 = GUICtrlCreateButton("Minus 1", 184, 333, 105, 65, 0)
$Label4 = GUICtrlCreateLabel("Contacts Removed", 104, 245, 163, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $Button1
            $x += 1
            $Label1 = GUICtrlCreateLabel($x, 164, 88, 13, 24)
        
        Case $Button2
            $x -= 1
            $Label1 = GUICtrlCreateLabel($x, 164, 88, 13, 24)
        
        Case $Button3
            $y += 1
            $Label3 = GUICtrlCreateLabel($y, 164, 301, 13, 24)

        Case $Button4
            $y -= 1
            $Label3 = GUICtrlCreateLabel($y, 164, 301, 13, 24)
    EndSwitch
WEnd
Link to comment
Share on other sites

GuiCtrlSetData

Aaaah yes. Thanks.

So for anyone that wanted to see the final product:

#include <GUIConstants.au3>

Global $x = 0, $y = 0
#Region ### START Koda GUI section ### Form=c:\documents and settings\[]\my documents\personal\autoit\koda forms\calls counter.kxf
$Form1_1 = GUICreate("Tracking", 371, 457, 325, 163)
$Group1 = GUICtrlCreateGroup("AGroup1", 24, 16, 321, 201)
$Label1 = GUICtrlCreateLabel("0", 164, 88, 13, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Add 1", 56, 120, 97, 65, 0)
$Button2 = GUICtrlCreateButton("Minus 1", 184, 120, 105, 65, 0)
$Label2 = GUICtrlCreateLabel("Number of Calls", 104, 32, 138, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("AGroup1", 24, 229, 321, 201)
$Label3 = GUICtrlCreateLabel("0", 164, 301, 13, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("Add 1", 56, 333, 97, 65, 0)
$Button4 = GUICtrlCreateButton("Minus 1", 184, 333, 105, 65, 0)
$Label4 = GUICtrlCreateLabel("Contacts Removed", 104, 245, 163, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $Button1
            $x += 1
            GUICtrlSetData($Label1, $x)
        
        Case $Button2
            $x -= 1
            GUICtrlSetData($Label1, $x)
        
        Case $Button3
            $y += 1
            GUICtrlSetData($Label3, $y)

        Case $Button4
            $y -= 1
            GUICtrlSetData($Label3, $y)
    EndSwitch
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...