Jump to content

Disabled Combobox?


Ace08
 Share

Recommended Posts

uhm..... guys have another problem regarding GUIs basicaly i have a main GUI upon clicking one button(Edit)and will show me another GUI here is the code i made

Func Upit() ;in progress
    local $file, $FileCont,$perTxn, $i, $EditF,$perField,$Prev,$Next,$_Ref,$_Tdate,$_Sname,$_Sadd1,$_Sadd2,$_Sphone,$_Rname,$_Radd1,$_Radd2
    local $_Rphone,$_Rgender,$_Rbday,$_Ttype,$_Pcode,$_Bcode,$_Bname,$_Acct,$_Lcur,$_Cur,$_Amt,$_Msg1,$_Msg2,$a
    local $i = 1
    $var = FileOpenDialog ("Open File.", "C:\Autoit\Test", "File(*.*)" , 2)
    If @error Then
        WinActivate("My Gui", "")
    Else
        $file = FileOpen($var, 0)
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf
        $FileCont = FileRead($file)
        $perTxn = stringsplit($FileCont, @Cr)
        $perField = stringsplit($perTxn[$i], chr(34) & "," & chr(34),1)
        $perField[1] = stringreplace($perField[1],chr(34),"")
        $perField[1] = stringreplace($perField[1],@Cr,"")
        $perField[21] = stringreplace($perField[21],chr(34),"")
        $EditF = GUICreate("Edit Transactions", 500 ,500);Creates The GUI
        $_Ref = GUICtrlCreateLabel("RNum           " & $perField[1], 10, 30, 800)
        $_Tdate = GUICtrlCreateLabel("Date              " & $perField[2], -1, 0)
        $_Sname = GUICtrlCreateLabel("Sender Name:                   " & $perField[3], -800, 0)
        $_Sadd1 = GUICtrlCreateLabel("Sender Address 1:             " & $perField[4], -800, 0)
        $_Sadd2 = GUICtrlCreateLabel("Sender Adderss 2:             " & $perField[5], -800, 0)
        $_Sphone = GUICtrlCreateLabel("SP                  " & $perField[6], -800, 0)
        $_Rname = GUICtrlCreateLabel("Receiver Name:                " & $perField[7], -800, 0)
        $_Radd1 = GUICtrlCreateLabel("Receiver Address 1:          " & $perField[8], -800, 0)
        $_Radd2 = GUICtrlCreateLabel("Receiver Address 2:          " & $perField[9], -800, 0)
        $_Rphone = GUICtrlCreateLabel("RP/Mo " & $perField[10], -800, 0)
        $_Rgender = GUICtrlCreateLabel("Rg              " & $perField[11], -800, 0)
        $_Rbday = GUICtrlCreateLabel("RDay          " & $perField[12], -800, 0)
        $_Ttype = GUICtrlCreateLabel("TType             " & $perField[13], -800, 0)
        $_Pcode = GUICtrlCreateLabel("PC                   " & $perField[14], -800, 0)
        $_Bcode = GUICtrlCreateLabel("BC                       " & $perField[15], -800, 0)
        $_Bname = GUICtrlCreateLabel("BN                   " & $perField[16], -800, 0)
        $_Acct = GUICtrlCreateLabel("AN              " & $perField[17], -800, 0)
        $_Lcur = GUICtrlCreateLabel("Lc ", -800, 0) 
        GUICtrlCreateCombo("C1", -675, -1,100) ; create first item
        $_Cur = GUICtrlSetData(-1, "C2", $perField[18]) ; add other item snd set a new default
        $_Amt = GUICtrlCreateLabel("Lnd                " & $perField[19], -225, 0,800)
        $_Msg1 = GUICtrlCreateLabel("Message1         " & $perField[20], -800, 0)
        $_Msg2 = GUICtrlCreateLabel("Message2         " & $perField[21], -800, 0)
        $Prev = GUICtrlCreateButton("Previous", -800, 0, 100)
        $Next = GUICtrlCreateButton("Next", 0, -21, 100)
        GUISetState()
        
        while 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    GUIDelete($EditF)
                    ExitLoop
                Case $Next
                    $i = $i + 1
                    $perField = stringsplit($perTxn[$i], chr(34) & "," & chr(34),1)
                    $perField[1] = stringreplace($perField[1],chr(34),"")
                    $perField[1] = stringreplace($perField[1],@Lf,"")
                    $a = StringStripWS ($perTxn[$i], 1)
                    if $i > UBound($perTxn)-1 then
                    GUICtrlSetState($Next, $GUI_DISABLE)
                    elseif stringlen($a) <= 0 then
                        GUICtrlSetState($Next, $GUI_DISABLE)
                    else
                    GUICtrlSetState($Prev, $GUI_ENABLE)
                    $perField[21] = stringreplace($perField[21],chr(34),"")
                        GUICtrlSetData($_Ref, "RNum           " & $perField[1])
                        GUICtrlSetData($_Tdate,"Date              " & $perField[2])
                        GUICtrlSetData($_Sname ,"Sender Name:                   " & $perField[3])
                        GUICtrlSetData($_Sadd1,"Sender Address 1:             " & $perField[4])
                        GUICtrlSetData($_Sadd2,"Sender Adderss 2:             " & $perField[5])
                        GUICtrlSetData($_Sphone,"SP                  " & $perField[6])
                        GUICtrlSetData($_Rname,"Receiver Name:                " & $perField[7])
                        GUICtrlSetData($_Radd1,"Receiver Address 1:          " & $perField[8])
                        GUICtrlSetData($_Radd2 ,"Receiver Address 2:          " & $perField[9])
                        GUICtrlSetData($_Rphone ,"RP/Mo " & $perField[10])
                        GUICtrlSetData($_Rgender, "Rg              " & $perField[11])
                        GUICtrlSetData($_Rbday ,"RDay          " & $perField[12])
                        GUICtrlSetData($_Ttype,"TType             " & $perField[13])
                        GUICtrlSetData($_Pcode ,"PC                   " & $perField[14])
                        GUICtrlSetData($_Bcode,"BC                       " & $perField[15])
                        GUICtrlSetData($_Bname,"BN                   " & $perField[16])
                        GUICtrlSetData($_Acct,"AN              " & $perField[17])
                        GUICtrlSetData($_Lcur,"Lc ")    
                        GUICtrlSetData($_Cur, "C1 | C2", $perField[18]) 
                        GUICtrlSetData($_Amt,"Lnd                " & $perField[19])
                        GUICtrlSetData($_Msg1 ,"Message1         " & $perField[20])
                        GUICtrlSetData($_Msg2 ,"Message2         " & $perField[21])
                    endif
                case $Prev
                    $i = $i - 1
                    $perField = stringsplit($perTxn[$i], chr(34) & "," & chr(34),1)
                    $perField[1] = stringreplace($perField[1],chr(34),"")
                    $perField[1] = stringreplace($perField[1],@Lf,"")
                    $a = StringStripWS ($perTxn[$i], 1)
                    if $i <= 0 then
                    GUICtrlSetState($Prev, $GUI_DISABLE)
                    elseif stringlen($a) <= 0 then
                        GUICtrlSetState($Prev, $GUI_DISABLE)
                    else
                        GUICtrlSetState($Next, $GUI_ENABLE)
                        $perField[21] = stringreplace($perField[21],chr(34),"")
                        GUICtrlSetData($_Ref, "RNum           " & $perField[1])
                        GUICtrlSetData($_Tdate,"Date              " & $perField[2])
                        GUICtrlSetData($_Sname ,"Sender Name:                   " & $perField[3])
                        GUICtrlSetData($_Sadd1,"Sender Address 1:             " & $perField[4])
                        GUICtrlSetData($_Sadd2,"Sender Adderss 2:             " & $perField[5])
                        GUICtrlSetData($_Sphone,"SP                  " & $perField[6])
                        GUICtrlSetData($_Rname,"Receiver Name:                " & $perField[7])
                        GUICtrlSetData($_Radd1,"Receiver Address 1:          " & $perField[8])
                        GUICtrlSetData($_Radd2 ,"Receiver Address 2:          " & $perField[9])
                        GUICtrlSetData($_Rphone ,"RP/Mo " & $perField[10])
                        GUICtrlSetData($_Rgender, "Rg              " & $perField[11])
                        GUICtrlSetData($_Rbday ,"RDay          " & $perField[12])
                        GUICtrlSetData($_Ttype,"TType             " & $perField[13])
                        GUICtrlSetData($_Pcode ,"PC                   " & $perField[14])
                        GUICtrlSetData($_Bcode,"BC                       " & $perField[15])
                        GUICtrlSetData($_Bname,"BN                   " & $perField[16])
                        GUICtrlSetData($_Acct,"AN              " & $perField[17])
                        GUICtrlSetData($_Lcur,"Lc ")    
                        GUICtrlSetData($_Cur, "C1 | C2", $perField[18]) 
                        GUICtrlSetData($_Amt,"Lnd                " & $perField[19])
                        GUICtrlSetData($_Msg1 ,"Message1         " & $perField[20])
                        GUICtrlSetData($_Msg2 ,"Message2         " & $perField[21])
                    endif
            EndSwitch
        WEnd    
    endif
endFunc

but this one shows a combobox but i cannot choose or click it but i can choose whats in the list by pressing up or down then when i click the next or prev buttons the combobox will be completely disabled thus i cannot choose anymore. can someone tell me whats wrong? would appreciate your help on this, Thanks ;):)

Work smarter not harder.My First Posted Script: DataBase

Link to comment
Share on other sites

  • Moderators

Ace08,

The only reference to a combo in your posted code is:

GUICtrlCreateCombo("C1", -675, -1, 100) ; create first item

this one shows a combobox

Are you sure? The required coordinates are well outside the $EditF GUI you have just created. :)

You are effectively doing this:

#include <GUIConstantsEx.au3>

$EditF = GUICreate("Edit Transactions", 500, 500);Creates The GUI
GUICtrlCreateCombo("C1", -675, -1, 100) ; create first item
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Can you see that combo? ;)

And how do you expect to be able to use it if it were visible? You have not saved the returned ControlID and you make no attempt at reading it in the rest of the code you show. ;)

If you want help, you need to post some code which gives us a fighting chance of debugging it. :shocked:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

sorry Melba23 but what i realy did was this

Func Upit() ;in progress
    local $file, $FileCont,$perTxn, $i, $EditF,$perField,$Prev,$Next,$_Ref,$_Tdate,$_Sname,$_Sadd1,$_Sadd2,$_Sphone,$_Rname,$_Radd1,$_Radd2
    local $_Rphone,$_Rgender,$_Rbday,$_Ttype,$_Pcode,$_Bcode,$_Bname,$_Acct,$_Lcur,$_Cur,$_Amt,$_Msg1,$_Msg2,$a,$_Cmb
    local $i = 1
    $var = FileOpenDialog ("Open File.", "C:\Autoit\Test", "File(*.*)" , 2)
    If @error Then
        WinActivate("My Gui", "")
    Else
        $file = FileOpen($var, 0)
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf
        $FileCont = FileRead($file)
        $perTxn = stringsplit($FileCont, @Cr)
        $perField = stringsplit($perTxn[$i], chr(34) & "," & chr(34),1)
        $perField[1] = stringreplace($perField[1],chr(34),"")
        $perField[1] = stringreplace($perField[1],@Cr,"")
        $perField[21] = stringreplace($perField[21],chr(34),"")
        $EditF = GUICreate("Edit Transactions", 500 ,500);Creates The GUI
        $_Ref = GUICtrlCreateLabel("RNum " & $perField[1], 10, 30, 1000)
        $_Tdate = GUICtrlCreateLabel("Date " & $perField[2], 10, 50)
        $_Sname = GUICtrlCreateLabel("Sender Name: " & $perField[3], 10, 70)
        $_Sadd1 = GUICtrlCreateLabel("Sender Address 1: " & $perField[4], 10, 90)
        $_Sadd2 = GUICtrlCreateLabel("Sender Adderss 2: " & $perField[5], 10, 110)
        $_Sphone = GUICtrlCreateLabel("SP " & $perField[6], 10, 130)
        $_Rname = GUICtrlCreateLabel("Receiver Name: " & $perField[7], 10, 150)
        $_Radd1 = GUICtrlCreateLabel("Receiver Address 1: " & $perField[8], 10, 170)
        $_Radd2 = GUICtrlCreateLabel("Receiver Address 2: " & $perField[9], 10, 190)
        $_Rphone = GUICtrlCreateLabel("RP/Mo " & $perField[10], 10, 210)
        $_Rgender = GUICtrlCreateLabel("Rg " & $perField[11], 10, 230)
        $_Rbday = GUICtrlCreateLabel("RDay " & $perField[12], 10, 250)
        $_Ttype = GUICtrlCreateLabel("TType " & $perField[13], 10, 270)
        $_Pcode = GUICtrlCreateLabel("PC " & $perField[14], 10, 290)
        $_Bcode = GUICtrlCreateLabel("BC " & $perField[15], 10, 310)
        $_Bname = GUICtrlCreateLabel("BN " & $perField[16], 10, 330)
        $_Acct = GUICtrlCreateLabel("AN  " & $perField[17], 10, 350)
        $_Lcur = GUICtrlCreateLabel("Lc ", 10, 370) 
        $_Cmb = GUICtrlCreateCombo("C1", 200, 350,100) ; create first item
        $_Cur = GUICtrlSetData($_Cmb, "C2", $perField[18]) ; add other item snd set a new default
        $_Amt = GUICtrlCreateLabel("Lnd " & $perField[19], 10, 390,800)
        $_Msg1 = GUICtrlCreateLabel("Message1 " & $perField[20], 10, 410)
        $_Msg2 = GUICtrlCreateLabel("Message2 " & $perField[21], 10, 430)
        $Prev = GUICtrlCreateButton("Previous", 10, 450, 100)
        $Next = GUICtrlCreateButton("Next", 110, 450, 100)
        GUISetState()
        
        while 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    GUIDelete($EditF)
                    ExitLoop
                Case $Next
                    $i = $i + 1
                    $perField = stringsplit($perTxn[$i], chr(34) & "," & chr(34),1)
                    $perField[1] = stringreplace($perField[1],chr(34),"")
                    $perField[1] = stringreplace($perField[1],@Lf,"")
                    $a = StringStripWS ($perTxn[$i], 1)
                    if $i > UBound($perTxn)-1 then
                    GUICtrlSetState($Next, $GUI_DISABLE)
                    elseif stringlen($a) <= 0 then
                        GUICtrlSetState($Next, $GUI_DISABLE)
                    else
                    GUICtrlSetState($Prev, $GUI_ENABLE)
                    $perField[21] = stringreplace($perField[21],chr(34),"")
                        GUICtrlSetData($_Ref, "RNum " & $perField[1])
                        GUICtrlSetData($_Tdate,"Date " & $perField[2])
                        GUICtrlSetData($_Sname ,"Sender Name: " & $perField[3])
                        GUICtrlSetData($_Sadd1,"Sender Address 1: " & $perField[4])
                        GUICtrlSetData($_Sadd2,"Sender Adderss 2: " & $perField[5])
                        GUICtrlSetData($_Sphone,"SP " & $perField[6])
                        GUICtrlSetData($_Rname,"Receiver Name: " & $perField[7])
                        GUICtrlSetData($_Radd1,"Receiver Address 1: " & $perField[8])
                        GUICtrlSetData($_Radd2 ,"Receiver Address 2: " & $perField[9])
                        GUICtrlSetData($_Rphone ,"RP/Mo " & $perField[10])
                        GUICtrlSetData($_Rgender, "Rg " & $perField[11])
                        GUICtrlSetData($_Rbday ,"RDay " & $perField[12])
                        GUICtrlSetData($_Ttype,"TType " & $perField[13])
                        GUICtrlSetData($_Pcode ,"PC " & $perField[14])
                        GUICtrlSetData($_Bcode,"BC " & $perField[15])
                        GUICtrlSetData($_Bname,"BN " & $perField[16])
                        GUICtrlSetData($_Acct,"AN " & $perField[17])
                        GUICtrlSetData($_Lcur,"Lc ")    
                        GUICtrlSetData($_Cur, "C1 | C2", $perField[18]) 
                        GUICtrlSetData($_Amt,"Lnd " & $perField[19])
                        GUICtrlSetData($_Msg1 ,"Message1 " & $perField[20])
                        GUICtrlSetData($_Msg2 ,"Message2 " & $perField[21])
                    endif
                case $Prev
                    $i = $i - 1
                    $perField = stringsplit($perTxn[$i], chr(34) & "," & chr(34),1)
                    $perField[1] = stringreplace($perField[1],chr(34),"")
                    $perField[1] = stringreplace($perField[1],@Lf,"")
                    $a = StringStripWS ($perTxn[$i], 1)
                    if $i <= 0 then
                    GUICtrlSetState($Prev, $GUI_DISABLE)
                    elseif stringlen($a) <= 0 then
                        GUICtrlSetState($Prev, $GUI_DISABLE)
                    else
                        GUICtrlSetState($Next, $GUI_ENABLE)
                        $perField[21] = stringreplace($perField[21],chr(34),"")
                        GUICtrlSetData($_Ref, "RNum " & $perField[1])
                        GUICtrlSetData($_Tdate,"Date " & $perField[2])
                        GUICtrlSetData($_Sname ,"Sender Name: " & $perField[3])
                        GUICtrlSetData($_Sadd1,"Sender Address 1: " & $perField[4])
                        GUICtrlSetData($_Sadd2,"Sender Adderss 2: " & $perField[5])
                        GUICtrlSetData($_Sphone,"SP " & $perField[6])
                        GUICtrlSetData($_Rname,"Receiver Name: " & $perField[7])
                        GUICtrlSetData($_Radd1,"Receiver Address 1: " & $perField[8])
                        GUICtrlSetData($_Radd2 ,"Receiver Address 2: " & $perField[9])
                        GUICtrlSetData($_Rphone ,"RP/Mo " & $perField[10])
                        GUICtrlSetData($_Rgender, "Rg " & $perField[11])
                        GUICtrlSetData($_Rbday ,"RDay " & $perField[12])
                        GUICtrlSetData($_Ttype,"TType " & $perField[13])
                        GUICtrlSetData($_Pcode ,"PC " & $perField[14])
                        GUICtrlSetData($_Bcode,"BC " & $perField[15])
                        GUICtrlSetData($_Bname,"BN " & $perField[16])
                        GUICtrlSetData($_Acct,"AN " & $perField[17])
                        GUICtrlSetData($_Lcur,"Lc ")    
                        GUICtrlSetData($_Cur, "C1 | C2", $perField[18]) 
                        GUICtrlSetData($_Amt,"Lnd " & $perField[19])
                        GUICtrlSetData($_Msg1 ,"Message1 " & $perField[20])
                        GUICtrlSetData($_Msg2 ,"Message2 " & $perField[21])
                    endif
            EndSwitch
        WEnd    
    endif
endFunc

i made this in a separate .au3 file and it is working but when i put the function in a button where my real program is, it only displays the first label so i redo and started uessing coordinates and those coordinates i posted 1st showed them all.

and this would be my main GUI where $EditF would be placed in a button

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)
Global $Saverate = 0 ,$var = "", $MainF,$Label1
Main()
Func Main()
    local $Upload, $Rate, $var, $Report, $Generate, $MainF
    $MainF = GUICreate("Main GUI", 220 ,100);Creates The GUI
    Opt("GUICoordMode", 2)
    $Upload = GUICtrlCreateButton("Upload / Edit", 10, 30, 100)
    $Rate = GUICtrlCreateButton("Rate", 0, -1)
    $Report = GUICtrlCreateButton("Report", -200, 2)
    $Generate = GUICtrlCreateButton("Generate", 0, -1)
    Dim $AccelKeys[4][4]=[["^u", $Upload], ["^r", $Rate], ["^p", $Report], ["^g", $Generate]]
    GUISetAccelerators($AccelKeys)
    GUISetState() 
        ; Disable the first GUI
    GUISetState(@SW_DISABLE, $MainF)
    Ratein()
    ; Re-enable the first GUI
    GUISetState(@SW_ENABLE, $MainF)
    ; Run the GUI until the dialog is closed
    $Label1 = GUICtrlCreateLabel("Current Rate is " & $Saverate, -150, 2)
    GUISetState() 
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Upload
                 ; Disable the first GUI
                GUISetState(@SW_DISABLE, $MainF)
                Upit()
                ; Re-enable the first GUI
                GUISetState(@SW_ENABLE, $MainF)
            Case $Rate
                ; Disable the first GUI
                GUISetState(@SW_DISABLE, $MainF)
                Ratein()
                ; Re-enable the first GUI
                GUISetState(@SW_ENABLE, $MainF)
            Case $Report
                 ; Disable the first GUI
                GUISetState(@SW_DISABLE, $MainF)
                ;Rep()
                ; Re-enable the first GUI
                GUISetState(@SW_ENABLE, $MainF)
        EndSwitch
    WEnd
EndFunc
Edited by Ace08

Work smarter not harder.My First Posted Script: DataBase

Link to comment
Share on other sites

  • Moderators

Ace08,

when i click the next or prev buttons the combobox will be completely disabled

This does not happen when I run a cut-down version of the script - the combo can be reselected easily. ;)

Could you let me have a copy of one of the files you are reading in so that I can run the script with all the GUICtrlSetData lines working. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

;) but why would it happen on me

here i have modified this file to hide any sensitive data but the file would look like this.

Thanks Melba23 for your time i realy appreciate it :)AR10H0901.txt

PS: those spaces are already there, we are recieving them with that kind of formatting and we are not alowed to tamper in them exept change C1 to C2 or the other way around.

Edited by Ace08

Work smarter not harder.My First Posted Script: DataBase

Link to comment
Share on other sites

  • Moderators

Ace08,

Thank you for that. Sorry if this is taking some time, but I am keeping one eye on the events at the mine in Chile - what a wonderful day! ;)

I have now got all the labels to display and update correctly - and all is working just about as I expected. You were using Opt("GUICoordMode", 2) but mixing your control coordinates between modes 1 and 2. :shocked:

A couple of questions:

- You use this line:

GUICtrlSetData($_Cur, "C1 | C2", $perField[18])

$_Cur is not a ControlID - it is actually the return value from when you set the data to the combo initially. The combo ControlID is held in $_Cmb. Are you trying to set the default value of the combo to the value of $perField[18]? :)

- What is selecting C1 or C2 in the combo supposed to do? You never read the combo, so I do not understand why it is there. Is it something to do with the "Lc" label? Do you want to change the value in the label? Do you want eventually to rewrite these changes to the file on disk? ;)

Nearly there. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

but I am keeping one eye on the events at the mine in Chile - what a wonderful day!

i see thanks Melba23 for the help even though you're kinda busy :)

I have now got all the labels to display and update correctly - and all is working just about as I expected. You were using Opt("GUICoordMode", 2) but mixing your control coordinates between modes 1 and 2.

aw, so this is where my problem is? i've tried Opt("GUICoordMode", 1) and saw the combobox active(but it totaly ruined the design ;) )

$_Cur is not a ControlID - it is actually the return value from when you set the data to the combo initially. The combo ControlID is held in $_Cmb. Are you trying to set the default value of the combo to the value of $perField[18]?

Yes, i would like to set it to the value of $perField[18] since not all those line are C1 nor C2

- What is selecting C1 or C2 in the combo supposed to do? You never read the combo, so I do not understand why it is there. Is it something to do with the "Lc" label? Do you want to change the value in the label? Do you want eventually to rewrite these changes to the file on disk?

i still havn't added that one yet since im stuck with a disabled combobox but that is what i would like to happen, but i am still having issues with that, the script would display the labels with the values of $perField

but the only thing that needs to be changed is C1 or C2 then save it on a new file.

Edited by Ace08

Work smarter not harder.My First Posted Script: DataBase

Link to comment
Share on other sites

  • Moderators

Ace08,

Here is what I have got so far. For me it works well and the "Lc" label is changed to match the selected value in the combo. The value is also changed in the relevant element of the $perTxn array:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)
Global $Saverate = 0, $var = "", $MainF, $Label1
Main()
Func Main()
    Local $Upload, $Rate, $var, $Report, $Generate, $MainF
    $MainF = GUICreate("Main GUI", 220, 100);Creates The GUI
    ;Opt("GUICoordMode", 2)  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $Upload = GUICtrlCreateButton("Upload / Edit", 10, 30, 100)
    $Rate = GUICtrlCreateButton("Rate", 110, 30, 100)
    $Report = GUICtrlCreateButton("Report", 10, 60, 100)
    $Generate = GUICtrlCreateButton("Generate", 110, 60, 100)
    Dim $AccelKeys[4][4] = [["^u", $Upload],["^r", $Rate],["^p", $Report],["^g", $Generate]]
    GUISetAccelerators($AccelKeys)
    GUISetState()
    ; Disable the first GUI
    GUISetState(@SW_DISABLE, $MainF)
    ;Ratein()
    ; Re-enable the first GUI
    GUISetState(@SW_ENABLE, $MainF)
    ; Run the GUI until the dialog is closed
    $Label1 = GUICtrlCreateLabel("Current Rate is " & $Saverate, -150, 2)
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Upload
                ; Disable the first GUI
                GUISetState(@SW_DISABLE, $MainF)
                Upit()
                ; Re-enable the first GUI
                GUISetState(@SW_ENABLE, $MainF)
            Case $Rate
                ; Disable the first GUI
                GUISetState(@SW_DISABLE, $MainF)
                ;Ratein()
                ; Re-enable the first GUI
                GUISetState(@SW_ENABLE, $MainF)
            Case $Report
                ; Disable the first GUI
                GUISetState(@SW_DISABLE, $MainF)
                ;Rep()
                ; Re-enable the first GUI
                GUISetState(@SW_ENABLE, $MainF)
        EndSwitch
    WEnd
EndFunc   ;==>Main

Func Upit() ;in progress
    Local $file, $FileCont, $perTxn, $i, $EditF, $perField, $Prev, $Next, $_Ref, $_Tdate, $_Sname, $_Sadd1, $_Sadd2, $_Sphone, $_Rname, $_Radd1, $_Radd2
    Local $_Rphone, $_Rgender, $_Rbday, $_Ttype, $_Pcode, $_Bcode, $_Bname, $_Acct, $_Lcur, $_Cur, $_Amt, $_Msg1, $_Msg2, $a, $_Cmb, $sCurr_Lc, $sNew_Lc
    Local $i = 1
    $var = FileOpenDialog("Open File.", "M:\Program\Au3 Scripts", "File(*.*)", 2)
    If @error Then
        WinActivate("My Gui", "")
    Else
        $file = FileOpen($var, 0)
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf
        $FileCont = FileRead($file)
        $perTxn = StringSplit($FileCont, @CR)

        $perField = StringSplit($perTxn[$i], Chr(34) & "," & Chr(34), 1)

        $perField[1] = StringReplace($perField[1], Chr(34), "")
        $perField[1] = StringReplace($perField[1], @CR, "")
        $perField[21] = StringReplace($perField[21], Chr(34), "")

        $EditF = GUICreate("Edit Transactions", 500, 500);Creates The GUI
        $_Ref = GUICtrlCreateLabel("RNum " & $perField[1], 10, 30, 1000)
        $_Tdate = GUICtrlCreateLabel("Date " & $perField[2], 10, 50)
        $_Sname = GUICtrlCreateLabel("Sender Name: " & $perField[3], 10, 70)
        $_Sadd1 = GUICtrlCreateLabel("Sender Address 1: " & $perField[4], 10, 90)
        $_Sadd2 = GUICtrlCreateLabel("Sender Adderss 2: " & $perField[5], 10, 110)
        $_Sphone = GUICtrlCreateLabel("SP " & $perField[6], 10, 130)
        $_Rname = GUICtrlCreateLabel("Receiver Name: " & $perField[7], 10, 150)
        $_Radd1 = GUICtrlCreateLabel("Receiver Address 1: " & $perField[8], 10, 170)
        $_Radd2 = GUICtrlCreateLabel("Receiver Address 2: " & $perField[9], 10, 190)
        $_Rphone = GUICtrlCreateLabel("RP/Mo " & $perField[10], 10, 210)
        $_Rgender = GUICtrlCreateLabel("Rg " & $perField[11], 10, 230)
        $_Rbday = GUICtrlCreateLabel("RDay " & $perField[12], 10, 250)
        $_Ttype = GUICtrlCreateLabel("TType " & $perField[13], 10, 270)
        $_Pcode = GUICtrlCreateLabel("PC " & $perField[14], 10, 290)
        $_Bcode = GUICtrlCreateLabel("BC " & $perField[15], 10, 310)
        $_Bname = GUICtrlCreateLabel("BN " & $perField[16], 10, 330)
        $_Acct = GUICtrlCreateLabel("AN  " & $perField[17], 10, 350)
        $_Lcur = GUICtrlCreateLabel("Lc " & $perField[18], 10, 370)
        $_Amt = GUICtrlCreateLabel("Lnd " & $perField[19], 10, 390, 800)
        $_Msg1 = GUICtrlCreateLabel("Message1 " & $perField[20], 10, 410)
        $_Msg2 = GUICtrlCreateLabel("Message2 " & $perField[21], 10, 430)

        $_Cmb = GUICtrlCreateCombo("C1", 200, 470, 100) ; create first item
        GUICtrlSetData($_Cmb, "C2|" & $perField[18], $perField[18]) ; add other item snd set a new default

        $Prev = GUICtrlCreateButton("Previous", 10, 470, 100)
        $Next = GUICtrlCreateButton("Next", 390, 470, 100)
        GUISetState()

        While 1
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    GUIDelete($EditF)
                    ExitLoop
                Case $_Cmb
                    $sCurr_Lc = $perField[18] ; Current value
                    $sNew_Lc = GUICtrlRead($_Cmb) ; Selected value
                    GUICtrlSetData($_Lcur, "Lc " & $sNew_Lc) ; Change label
                    $perTxn[$i] = StringReplace($perTxn[$i], '"' & $sCurr_Lc & '"', '"' & $sNew_Lc & '"') ; Change value in array

                Case $Next
                    $i = $i + 1
                    $perField = StringSplit($perTxn[$i], Chr(34) & "," & Chr(34), 1)
                    $perField[1] = StringReplace($perField[1], Chr(34), "")
                    $perField[1] = StringReplace($perField[1], @LF, "")
                    $a = StringStripWS($perTxn[$i], 1)
                    If $i > UBound($perTxn) - 1 Then
                        GUICtrlSetState($Next, $GUI_DISABLE)
                    ElseIf StringLen($a) <= 0 Then
                        GUICtrlSetState($Next, $GUI_DISABLE)
                    Else
                        GUICtrlSetState($Prev, $GUI_ENABLE)
                        $perField[21] = StringReplace($perField[21], Chr(34), "")
                        GUICtrlSetData($_Ref, "RNum " & $perField[1])
                        GUICtrlSetData($_Tdate, "Date " & $perField[2])
                        GUICtrlSetData($_Sname, "Sender Name: " & $perField[3])
                        GUICtrlSetData($_Sadd1, "Sender Address 1: " & $perField[4])
                        GUICtrlSetData($_Sadd2, "Sender Adderss 2: " & $perField[5])
                        GUICtrlSetData($_Sphone, "SP " & $perField[6])
                        GUICtrlSetData($_Rname, "Receiver Name: " & $perField[7])
                        GUICtrlSetData($_Radd1, "Receiver Address 1: " & $perField[8])
                        GUICtrlSetData($_Radd2, "Receiver Address 2: " & $perField[9])
                        GUICtrlSetData($_Rphone, "RP/Mo " & $perField[10])
                        GUICtrlSetData($_Rgender, "Rg " & $perField[11])
                        GUICtrlSetData($_Rbday, "RDay " & $perField[12])
                        GUICtrlSetData($_Ttype, "TType " & $perField[13])
                        GUICtrlSetData($_Pcode, "PC " & $perField[14])
                        GUICtrlSetData($_Bcode, "BC " & $perField[15])
                        GUICtrlSetData($_Bname, "BN " & $perField[16])
                        GUICtrlSetData($_Acct, "AN " & $perField[17])
                        GUICtrlSetData($_Lcur, "Lc " & $perField[18])
                        GUICtrlSetData($_Amt, "Lnd " & $perField[19])
                        GUICtrlSetData($_Msg1, "Message1 " & $perField[20])
                        GUICtrlSetData($_Msg2, "Message2 " & $perField[21])

                        GUICtrlSetData($_Cmb, "|C1|C2|" & $perField[18], $perField[18])

                    EndIf
                Case $Prev
                    $i = $i - 1
                    $perField = StringSplit($perTxn[$i], Chr(34) & "," & Chr(34), 1)
                    $perField[1] = StringReplace($perField[1], Chr(34), "")
                    $perField[1] = StringReplace($perField[1], @LF, "")
                    $a = StringStripWS($perTxn[$i], 1)
                    If $i <= 0 Then
                        GUICtrlSetState($Prev, $GUI_DISABLE)
                    ElseIf StringLen($a) <= 0 Then
                        GUICtrlSetState($Prev, $GUI_DISABLE)
                    Else
                        GUICtrlSetState($Next, $GUI_ENABLE)
                        $perField[21] = StringReplace($perField[21], Chr(34), "")
                        GUICtrlSetData($_Ref, "RNum " & $perField[1])
                        GUICtrlSetData($_Tdate, "Date " & $perField[2])
                        GUICtrlSetData($_Sname, "Sender Name: " & $perField[3])
                        GUICtrlSetData($_Sadd1, "Sender Address 1: " & $perField[4])
                        GUICtrlSetData($_Sadd2, "Sender Adderss 2: " & $perField[5])
                        GUICtrlSetData($_Sphone, "SP " & $perField[6])
                        GUICtrlSetData($_Rname, "Receiver Name: " & $perField[7])
                        GUICtrlSetData($_Radd1, "Receiver Address 1: " & $perField[8])
                        GUICtrlSetData($_Radd2, "Receiver Address 2: " & $perField[9])
                        GUICtrlSetData($_Rphone, "RP/Mo " & $perField[10])
                        GUICtrlSetData($_Rgender, "Rg " & $perField[11])
                        GUICtrlSetData($_Rbday, "RDay " & $perField[12])
                        GUICtrlSetData($_Ttype, "TType " & $perField[13])
                        GUICtrlSetData($_Pcode, "PC " & $perField[14])
                        GUICtrlSetData($_Bcode, "BC " & $perField[15])
                        GUICtrlSetData($_Bname, "BN " & $perField[16])
                        GUICtrlSetData($_Acct, "AN " & $perField[17])
                        GUICtrlSetData($_Lcur, "Lc " & $perField[18])
                        GUICtrlSetData($_Amt, "Lnd " & $perField[19])
                        GUICtrlSetData($_Msg1, "Message1 " & $perField[20])
                        GUICtrlSetData($_Msg2, "Message2 " & $perField[21])

                        GUICtrlSetData($_Cmb, "|C1|C2|" & $perField[18], $perField[18])

                    EndIf
            EndSwitch
        WEnd
    EndIf
EndFunc   ;==>Upit

You will have to recreate the complete file contents by combining the elements of the $perTxn array before using FileWrite to overwrite the original if you want to save these changes to disk. :)

But that is for later. Does this script work for you now? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks a lot Melba23 its working ;) , also while working with this one i tried to look for an alternative, just use a plain label like the other labels $_Lcur = GUICtrlCreateLabel("Lc : " & $perField[18], -1, 0)then i added a button that when clicked will then change the value of $perField[18] to its opposite C1 or C2(this one is working too for me but maybe i'll stick with the combobox :)). now i can move on with the rest of the script Thanks again Melba23 for the help ;)

Work smarter not harder.My First Posted Script: DataBase

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...