Jump to content

GUI Code


anixon
 Share

Recommended Posts

I have a number of issues with some code that I have written which someone might be able to help me with.

In order to display an inputbox and have it process input I have had to write code which requires two appearances of the GUICtrlCreateInput

statement

First appearance is in :

; Processing Buttons

Second appearance is in:

; Func locationstatus()

Is this correct?

The second issue is that after inputing location text and processing using the "Ok" button when you click on the input box again the previous input

has not been cleared. To how do you clear the previous text input in this box after it has been processed?

Help is very much appreciated Ant..

CODE
#include <GUIConstants.au3>

#include<String.au3>

;Window

;

gUICreate("LOCATION",370,340)

;Processing Buttons

;

$l1 = GuiCtrlCreateButton ("L1",46,180,30,25)

$l2 = GuiCtrlCreateButton ("L2",46,210,30,25)

$l3 = GuiCtrlCreateButton ("L3",46,240,30,25)

$l4 = GuiCtrlCreateButton ("L4",46,270,30,25)

$l5 = GuiCtrlCreateButton ("L5",46,300,30,25)

$l6 = GuiCtrlCreateButton ("L6",215,180,30,25)

$l7 = GuiCtrlCreateButton ("L7",215,210,30,25)

$l8 = GuiCtrlCreateButton ("L8",215,240,30,25)

$l9 = GuiCtrlCreateButton ("L9",215,270,30,25)

$l10= GuiCtrlCreateButton ("L10",215,300,30,25)

$newloc = GUICtrlCreateInput ( "", 125, 80, 150, 20)

$exitbutton = GuiCtrlCreateButton ("Exit",200,340,70,20)

$btn = GUICtrlCreateButton ("Ok", 280, 80, 30, 20)

$sav = GuiCtrlCreateButton ("S",15,60,15,15)

;Variables

;

global $savprocess = 0

global $lid = 0

Global $font = "times new roman"

Global $loc = ""

;Set Window State

;

GuiSetState()

; Call Menu Window

;

locationstatus()

;Location Status

;

Func locationstatus()

Global $cloc = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "current", "loc", "0"), "password", 1))

Global $loc1 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc1", "Not Known"), "password", 1))

Global $loc2 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc2", "Not Known"), "password", 1))

Global $loc3 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc3", "Not Known"), "password", 1))

Global $loc4 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc4", "Not Known"), "password", 1))

Global $loc5 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc5", "Not Known"), "password", 1))

Global $loc6 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc6", "Not Known"), "password", 1))

Global $loc7 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc7", "Not Known"), "password", 1))

Global $loc8 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc8", "Not Known"), "password", 1))

Global $loc9 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc9", "Not Known"), "password", 1))

Global $loc10 = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", "loc10", "Not Known"), "password", 1))

Global $font = "times new roman"

GUISetFont (10, 600, 4, $font)

GuiCtrlCreateLabel("LOCATIONS",46,15, 150,55)

GUISetFont (9, 400, 1, $font)

GuiCtrlCreateLabel("Desktop ID:",46,40, 150, 55)

GuiCtrlCreateLabel("Your Location: "& $cloc,46,60, 300, 55)

GuiCtrlCreateLabel("New Location: ",46,80, 300, 55)

GUICtrlCreateInput ( "", 125, 80, 150, 20)

GUICtrlCreateButton ("Ok", 280, 80, 30, 20)

GuiCtrlCreateLabel($loc1,85,187,130,55)

GuiCtrlCreateLabel($loc2,85,217,130,55)

GuiCtrlCreateLabel($loc3,85,247,130,55)

GuiCtrlCreateLabel($loc4,85,277,130,55)

GuiCtrlCreateLabel($loc5,85,307,130,55)

GuiCtrlCreateLabel($loc6,251,187,130,55)

GuiCtrlCreateLabel($loc7,251,217,130,55)

GuiCtrlCreateLabel($loc8,251,247,130,55)

GuiCtrlCreateLabel($loc9,251,277,130,55)

GuiCtrlCreateLabel($loc10,251,307,130,55)

GUISetFont (8, 400, 1, $font)

processor()

EndFunc

;Set or Save Current Location

;

Func locationprocessor()

If $savprocess = 0 Then

$location = (_StringEncrypt(0, IniRead(@scriptdir&"\inifiles\loc.ini", "registered", $loc , "Not Known"), "password", 1))

$locini = (_StringEncrypt(1, $location, "password", 1))

iniwrite(@scriptdir&"\inifiles\loc.ini", "current","loc", $locini)

locationstatus()

Else

$locini = (_StringEncrypt(1, $cloc, "password", 1))

iniwrite(@scriptdir&"\inifiles\loc.ini", "registered", $loc, $locini)

$savprocess = 0

locationstatus()

EndIf

EndFunc

Func newlocprocessor()

If $newloc = "" Then

locationstatus()

Else

$data = GUICtrlRead($newloc)

$locini = (_StringEncrypt(1, $data, "password", 1))

iniwrite(@scriptdir&"\inifiles\loc.ini", "current","loc", $locini)

locationstatus()

EndIf

EndFunc

;Buttons Processor

;

Func Processor()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $exitbutton

ExitLoop

Case $msg = $l1

$loc = "loc1"

locationprocessor()

Case $msg = $l2

$loc = "loc2"

locationprocessor()

Case $msg = $l3

$loc = "loc3"

locationprocessor()

Case $msg = $l4

$loc = "loc4"

locationprocessor()

Case $msg = $l5

$loc = "loc5"

locationprocessor()

Case $msg = $l6

$loc = "loc6"

locationprocessor()

Case $msg = $l7

$loc = "loc7"

locationprocessor()

Case $msg = $l8

$loc = "loc8"

locationprocessor()

Case $msg = $l9

$loc = "loc9"

locationprocessor()

Case $msg = $l10

$loc = "loc10"

locationprocessor()

Case $msg = $sav

$savprocess = 1

Case $msg = $btn

newlocprocessor()

EndSelect

WEnd

lexit()

EndFunc

;Exit

;

Func lexit()

;Do something

GUIDelete()

Exit

EndFunc

I have resolved the third issue with the GUICtrlCreateGroup function

Ant...

I have resolved all my issues simply by changing "Func" into Nested "While" routines. So much to learn so little time

Cheers Ant.......

Edited by anixon
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...