Jump to content

Combo Box error


Recommended Posts

This line

Dim $comboText = _GUICtrlComboBox_GetEditText($RC_mainUserListBox)

this is just one line in much larger program. the problem I'm having is not syntax but compatibility.

works fine in windows xp, but if you try to run it on a win2k machine it returns a character the looks like

a solid block ... something like the letter l right next to the lettere l without a space in between. The data actually

in the edit portion of that control was the letter "a". On the winxp machine it grabs that information correctly from the box.

On the win2k machine it simply returns a double l looking block (kinda looks like a null character).

can anyone offer a solution / alternative to this kind of gui... I really want something that autocompletes... and actually

works on a win2k machine .. and a winxp machine. Thank you for any help on this matter

Edited by Aiakonai

hmm... I wonder which key is the any key :O

Link to comment
Share on other sites

In case anyone actually wanted to see the code for the entire program ... here it is.

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Rchat.exe
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****

#include <GUIConstants.au3>
#include "debug.au3"
#include <String.au3>
#include <GUIListBox.au3>
#include <File.au3>
#Include <GuiComboBox.au3>

;-pw for resetting the password
;-network starting from the network
;-local starting on the local computer

;$message = GUIGetMsg()
;Switch $message
;   Case $GUI_EVENT_CLOSE
;       leave()
;   Case $send
;       SendMessage()
;EndSwitch

;
debug_show(1)
UDPStartup()
Dim $myip = @IPAddress1
Func _SubnetMask($strIP = @IPAddress1)
    Local $strEnumKey, $nEnum
    Local $strKey = "HKLM\SYSTEM\CurrentControlSet\" & _
            "Services\Tcpip\Parameters\Interfaces\"
    While 1
        $nEnum += 1
        $strEnumKey = RegEnumKey($strKey, $nEnum)
        If @error <> 0 Then ExitLoop
        If RegRead($strKey & $strEnumKey, "DhcpIPAddress") = $strIP Then
            Return RegRead($strKey & $strEnumKey, "DhcpSubnetMask")
        EndIf
    WEnd
    Return SetError(1, 0, 0)
EndFunc

;set options
Opt("GUIOnEventMode", 1)
;variables needed throughout program
Dim $currentVersion = "1.0.0.8"
Dim $mask = _SubnetMask()
Dim $splitMask = StringSplit($mask,".")
Dim $myip = @IPAddress1
Dim $splitMyIP = StringSplit($myip,".")
Dim $temp
Dim $broadcastIP = ""
Dim $uPath = ""
Dim $userDirectory = "K:\data\rdcd\notify\users\"

For $i = 1 To 4 Step 1
    $temp =BitNOT($splitMask[$i])
    $broadcastIP = $broadcastIP&BitAND(BitOR($temp,$splitMyIP[$i]),255)&"."
Next
$broadcastIP= StringTrimRight($broadcastIP,1)
debug_show(1)

;sends a message to all via udp
Func broadcast($msg)
    Dim $Usock = UDPOpen($broadcastIP,65532)
    UDPSend($Usock,$msg)
    UDPCloseSocket($Usock)
EndFunc

Func showParam()
    Dim $x = $CmdLine[0]
    For $i = 1 To $x step 1
        debug("cmd line param","number "&$i&" "&$CmdLine[$i])
    Next
EndFunc



Func RC_startClient()   
    RC_createProfile()
    RC_createMainWindow()
   ;RC_listenMode()
EndFunc

Func RC_checkReg()
    Dim $regpath = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List"
    If @OSVersion =  "WIN_XP" Or @OSVersion = "WIN_VISTA" Then
        If StringInStr(RegRead($regpath, @AutoItExe),"Enabled") = 0 Then
            dim $pathPW = @AutoItExe
            $pathPW = StringTrimRight($pathPW,4)
            dim $fh = FileOpen($pathPW,0)
            dim $encPW = FileReadLine($fh)
            RunAsSet("Administrator", @ComputerName ,_StringEncrypt(0,$encPW,@AutoItExe)) 
        ;****
            RegWrite($regpath, @AutoItExe, "REG_SZ", @AutoItExe & ":*:Enabled:Rchat.exe")
        ;****
            RunAsSet()
            fileclose($fh)
        EndIf
    EndIf   
EndFunc

Func RC_createProfile()
;place a file with your uid.ok
;open that file and put your ip in that
    
    _FileCreate($userDirectory&'\'&@UserName&".ok")
    Sleep(10)
    Dim $fh = FileOpen($userDirectory&'\'&@UserName&".ok",2)
    FileWriteLine($fh,@IPAddress1)
    fileclose($fh)
EndFunc

Func RC_leave()
;TCPShutdown()
;alertOthers()
    Exit
EndFunc
;modified from help file for autocomplete on combo box
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo
    If Not IsHWnd($RC_mainUserListBox) Then $hWndCombo = GUICtrlGetHandle($RC_mainUserListBox)
    $hWndFrom = $ilParam
    $iIDFrom = BitAND($iwParam, 0xFFFF); Low Word
    $iCode = BitShift($iwParam, 16); Hi Word
    Switch $hWndFrom
        Case $RC_mainUserListBox, $hWndCombo
            Switch $iCode                   
                Case $CBN_EDITCHANGE; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box                 
                    RC_Edit_Changed()
                Case $CBN_KILLFOCUS; Sent when a combo box loses the keyboard focus                 
                    HotKeySet("{Enter}")                    
                    debug("at endfocus","true")
                Case $CBN_SETFOCUS; Sent when a combo box receives the keyboard focus
                    HotKeySet("{Enter}","RC_addPerson")
                    debug("at setfocus","true")
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func RC_clearConnected()
    debug("clearing connected", "should be cleared now")
    _GUICtrlEdit_SetText($RC_mainConnectedList,"")
EndFunc

Func RC_Edit_Changed()
    _GUICtrlComboBox_AutoComplete ($RC_mainUserListBox)
EndFunc

Func RC_addperson()
    Dim $comboText = _GUICtrlComboBox_GetEditText($RC_mainUserListBox)
;add the actual code to connect to a user here
    _GUICtrlEdit_AppendText($RC_mainConnectedList,$comboText&@CRLF)
    _GUICtrlComboBox_SetEditText($RC_mainUserListBox,"")
EndFunc

Func RC_createMainWindow()
    global $RC_mainWindow = GUICreate("RChat Client V1.0",300,400)
    global $RC_mainUserListBox = GUICtrlCreateCombo("",10,70,270,340)   
    global $RC_mainHeaderUserList = GUICtrlCreateLabel("Click on a name then Click connect to communicate with that user",10,10,200,30)
    global $RC_mainConnectedList = GUICtrlCreateEdit("",10,250,270,100)
    global $RC_mainClearConnected = GUICtrlCreateButton("Clear Connected List",160,460,110,20)
    GUICtrlSetOnEvent(-1,"RC_clearConnected")
    GUICtrlSetFont($RC_mainHeaderUserList,10)
    GUISetState()
    GUISetOnEvent($GUI_EVENT_CLOSE,"RC_leave")  
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")   
    _GUICtrlComboBox_BeginUpdate($RC_mainUserListBox)
    Dim $userList = RC_getUserList()
    RC_addUsers($userList)
    _GUICtrlComboBox_EndUpdate($RC_mainUserListBox) 
    GUICtrlSetState($RC_mainUserListBox,$GUI_FOCUS)
    HotKeySet("{Enter}","RC_addPerson")     
EndFunc

Func RC_createChatWindow()
    Global $RC_chatWin = GUICreate("Chat Session",320,360,50,50,$WS_TILEDWINDOW)    
    GUISetOnEvent($GUI_EVENT_CLOSE,"RC_leave")
    Global $RC_chatMsgBoard = GUICtrlCreateEdit("",10,10,300,200)
    GUICtrlSetResizing(-1,$GUI_DOCKLEFT)
    Global $RC_chatSendBox = GUICtrlCreateEdit("",10,220,300,100)   
    Global $RC_chatSendButton = GUICtrlCreateButton("Send",260,320,50,20)   
    GUICtrlSetOnEvent(-1,"RC_sendMSG")
    GUICtrlSetColor($RC_chatMsgBoard,0x0000ff)
    GUISetState()
    
EndFunc

Func RC_destroyChatWindow()
    If $RC_chatWin <> "x" Then
        GUIDelete($RC_chatWin)
        $RC_chatWin = "x"
    Else
        msgbox(0,"error","No chat window detected")
    EndIf
EndFunc

Func RC_getUserList()
    Dim $search = FileFindFirstFile("K:\data\rdcd\notify\users\*.*");returns a search handle    
    Dim $userList[150]
    Dim $i = 0
    Dim $atEnd = False
    Do          
        Dim $temp = FileFindNextFile($search)
        If @error = 1 Then $atEnd = True
        If StringInStr($temp,".ok") <> 0 Then
            $temp = StringTrimRight($temp,3)
            If @error <> 1 Then
                $userlist[$i] = $temp
            EndIf           
        EndIf
        $i = $i + 1
    Until $atEnd = True
    return $userList    
EndFunc

Func RC_addUsers($userList)
    Dim $i = 0
    Do
        _GUICtrlComboBox_AddString($RC_mainUserListBox,$userList[$i])
        $i = $i + 1
    Until $userList[$i] = ""
EndFunc

;debug("tempdir",@TempDir)
;debug("path name for exe",@AutoItExe)
;this needs to be run again when the exe is placed on the server

;based on what is in the command line 1 of 3 things will happen
;-pw sets the password for fixing the firewall if necessary (this should only need to be done once)
;-network is what will run to check versioning and update if necessary .. then it will start the
;-local with a 2nd parameter that is the file location of the user directory
If $CmdLine[0] <> 0 Then
;this is the network copy
    If $CmdLine[1] = "-pw" Then
        dim $pw = inputbox("Administration","Please enter the administrator's password","","*")
    ;debug("pw val",$pw)
        dim $pathPW = @AutoItExe
        $pathPW = StringTrimRight($pathPW,4)
        _filecreate($pathPW)
        dim $fh = fileopen($pathPW,1)
        FileWriteLine($fh,_StringEncrypt(1,$pw,@AutoItExe,2))   
        fileclose($fh)
        sleep(100)
    ElseIf $CmdLine[1] = "-network" Then            
    ;set firewall
        RC_checkReg()
    ;copy files if they dont already exist (version checking needs to be done)
    ;***
        If FileExists(@TempDir&"\Rchat.txt") = 0 Then
            FileCopy("L:\apps\Rchat\Rchat.exe",@TempDir,1)          
        Else
            Dim $fh = FileOpen(@TempDir&"\Rchat.txt",0)
            Dim $x = FileReadLine($fh)          
            If $x <> $currentVersion Then
                debug("line read", "version is incorrect")
                FileCopy("L:\apps\Rchat\Rchat.exe",@TempDir,1)              
            Else
                debug("line read", "version is correct")
            EndIf
            MsgBox(1,"oky","doky")
        EndIf
    ;start local
        Dim $locName =  @TempDir&"\Rchat.exe -local K:\data\rdcd\notify\users\"     
        Run($locName)
    ;exit
        Exit
    ElseIf $CmdLine[1] = "-local" Then      
        _FileCreate(@TempDir&"\Rchat.txt")
        Dim $fh = FileOpen(@TempDir&"\Rchat.txt",1)
        FileWriteLine($fh,$currentVersion)
    ;do normal startup
        $uPath = $CmdLine[2]
        debug("upath",$uPath)
        RC_startClient()
        debug("in local copy", "local copy started")
    EndIf
Else
;this should not be reached
EndIf
debug_fatal(1,"end")
;broadcast("exit")
UDPShutdown()

hmm... I wonder which key is the any key :O

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