Sign in to follow this  
Followers 0
MattX

Funny result on Combo Box

5 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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.

 

Share this post


Link to post
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.

Share this post


Link to post
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....

Share this post


Link to post
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)


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0