Jump to content

GUI Simulator - There must be a better way


Recommended Posts

I am trying to create a GUI Simulator and feel there must be a better way to do it than the way I'm doing it now.

I am loading a .jpg and enabling/disabling transparent(made black for this example) labels which load a different picture when clicked.

See my code below. It works but I will be working with about 100 pictures total.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=ico\control_panel.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Users\knichols\Desktop\frmMain.kxf
$frmMain = GUICreate("Simulator", 1024, 643)
$Picture = GUICtrlCreatePic("C:\Simulator\ScreenShots\Image1.jpg", 0, 0,1024,643,$SS_BITMAP)
$lblCopy = GUICtrlCreateLabel("", 73, 169, 220, 280)
GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT
GUICtrlSetCursor(-1, 0)
$lblPrintFrom = GUICtrlCreateLabel("", 328, 169, 220, 280)
GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT
GUICtrlSetCursor(-1, 0)
$lblScanTo = GUICtrlCreateLabel("", 583, 169, 220, 280)
GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT
GUICtrlSetCursor(-1, 0)
$lblServicesHome = GUICtrlCreateLabel("", 223, 553, 42, 42)
GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT
GUICtrlSetCursor(-1, 0)
$lblJobStatus = GUICtrlCreateLabel("", 473, 553, 42, 42)
GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT
GUICtrlSetCursor(-1, 0)
$lblMachineStatus = GUICtrlCreateLabel("", 600, 553, 42, 42)
GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT
GUICtrlSetCursor(-1, 0)
$lblOK = GUICtrlCreateLabel("", 733, 124, 94, 34)
GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT
GUICtrlSetCursor(-1, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Local $bFileInstall = False
Local $sFldr = "C:\Simulator\ScreenShots\"

    If DirGetSize($sFldr) <> -1 Then
        Local $bFileInstall = False
    Else
        DirCreate($sFldr)
        FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image1.jpg", $sFldr & "Image1.jpg")
        FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image3.jpg", $sFldr & "Image3.jpg")
        FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image21.jpg", $sFldr & "Image21.jpg")
        FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image21.jpg", $sFldr & "Image22.jpg")
        FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image43.jpg", $sFldr & "Image43.jpg")
        FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image68.jpg", $sFldr & "Image68.jpg")
        FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image69.jpg", $sFldr & "Image69.jpg")
    EndIf

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $lblJobStatus
            GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image69.jpg")
            DisableLabels()

        Case $lblServicesHome
            GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image1.jpg")
            EnableLabels()

        Case $lblMachineStatus
            GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image43.jpg")
            DisableLabels()

        Case $lblCopy
            GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image3.jpg")
            DisableLabels()

        Case $lblPrintFrom
            GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image68.jpg")
            DisableLabels()

        Case $lblScanTo
            GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image21.jpg")
            GUICtrlSetState($lblOK, $GUI_ENABLE)
            DisableLabels()

        Case $lblOK
            GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image22.jpg")
            GUICtrlSetState($lblOK, $GUI_DISABLE)

    EndSwitch
WEnd

Func DisableLabels()
    GUICtrlSetState($lblCopy,$GUI_DISABLE)
    GUICtrlSetState($lblScanTo,$GUI_DISABLE)
    GUICtrlSetState($lblPrintFrom,$GUI_DISABLE)
EndFunc

Func EnableLabels()
    GUICtrlSetState($lblCopy,$GUI_ENABLE)
    GUICtrlSetState($lblScanTo,$GUI_ENABLE)
    GUICtrlSetState($lblPrintFrom,$GUI_ENABLE)
EndFunc
[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!
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

×
×
  • Create New...