Jump to content

Funny result on Combo Box


MattX
 Share

Recommended Posts

Got a combo box working with a user.ini file - funny thing is now is the msgbox line I have put in to check that the relevant user is being selected is comming up with an answer of' 4' and not the selected user. Anyone got an idea why ?

#include <GuiConstants.au3>

GUICreate("Select User", 250, 66)

$combo = GUICtrlCreateCombo("", 16, 8, 225, 21)
GUICtrlSetData($combo, "")
$selectbutton = GUICtrlCreateButton("Select", 100, 40, 60, 20)
GUISetState()
$userlist = IniReadSection("c:\usersini.ini", "Users")
If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $userlist[0][0]
        $tmp = $userlist[$i][1] & "|"
        GUICtrlSetData($combo, $tmp)
            Next
EndIf
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $selectbutton
            MsgBox(0, "You chose", $selectbutton)
        ;DriveMapDel("n:")
        ;DriveMapAdd("n:", "\\server" & $selectbutton, 0, "domain" & $selectbutton, "password")
    EndSelect
WEnd
Exit
Link to comment
Share on other sites

Got a combo box working with a user.ini file - funny thing is now is the msgbox line I have put in to check that the relevant user is being selected is comming up with an answer of' 4' and not the selected user. Anyone got an idea why ?

#include <GuiConstants.au3>

GUICreate("Select User", 250, 66)

$combo = GUICtrlCreateCombo("", 16, 8, 225, 21)
GUICtrlSetData($combo, "")
$selectbutton = GUICtrlCreateButton("Select", 100, 40, 60, 20)
GUISetState()
$userlist = IniReadSection("c:\usersini.ini", "Users")
If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $userlist[0][0]
        $tmp = $userlist[$i][1] & "|"
        GUICtrlSetData($combo, $tmp)
            Next
EndIf
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $selectbutton
            MsgBox(0, "You chose", $selectbutton)
      ;DriveMapDel("n:")
      ;DriveMapAdd("n:", "\\server" & $selectbutton, 0, "domain" & $selectbutton, "password")
    EndSelect
WEnd
Exit

Because your showing the controld id

MsgBox(0, "You chose", GuiCtrlRead($selectbutton))

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Because your showing the controld id

MsgBox(0, "You chose", GuiCtrlRead($selectbutton))

Even weirder now - the result is always 'select' !! Picking this up from the:

$selectbutton = GUICtrlCreateButton("Select", 100, 40, 60, 20) line.

Link to comment
Share on other sites

Even weirder now - the result is always 'select' !! Picking this up from the:

$selectbutton = GUICtrlCreateButton("Select", 100, 40, 60, 20) line.

Changed it to MsgBox(0, "You chose", GuiCtrlRead($combo))

and I get the correct result - next task is to somehow use that variable for the drive mapping....

Link to comment
Share on other sites

Changed it to MsgBox(0, "You chose", GuiCtrlRead($combo))

and I get the correct result - next task is to somehow use that variable for the drive mapping....

$user=GuiCtrlRead($combo)
MsgBox(0, "You chose", $user)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

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