找回密码
 加入
搜索
查看: 2042|回复: 3

[已解决]_GUICtrlComboBoxEx_Create读取错误

[复制链接]
发表于 2009-6-27 19:05:43 | 显示全部楼层 |阅读模式
本帖最后由 jycel 于 2009-6-28 11:08 编辑

如图:按照普通的GUICtrlRead($hCombo)的值全都为0大家帮我看看问题在那儿
解决方法在二楼,说明三楼
#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GuiConstantsEx.au3>

Opt('MustDeclareVars', 1)
Dim $File ,$var1
        $File = @ScriptDir&"\Menu.ini"
        $var1 = IniReadSection($File, "在线影视")
$Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
        Local $hGUI, $hImage, $hCombo,$nMsg,$Button1,$rj
        
        ; Create GUI
        $hGUI = GUICreate("ComboBoxEx End Update", 400, 300)
        $hCombo = _GUICtrlComboBoxEx_Create ($hGUI, "", 2, 2, 394, 100)
        $Button1 = GUICtrlCreateButton("测试读取", 50, 100, 65, 25)
        GUISetState()

        $hImage = _GUIImageList_Create (16, 16, 5, 3)
                _GUIImageList_AddIcon ($hImage, "1.ico")
                _GUIImageList_AddIcon ($hImage, "2.ico")
                _GUIImageList_AddIcon ($hImage, "3.ico")
                _GUIImageList_AddIcon ($hImage, "4.ico")
                _GUIImageList_AddIcon ($hImage, "5.ico")
                _GUIImageList_AddIcon ($hImage, "6.ico")
                _GUIImageList_AddIcon ($hImage, "7.ico")
                _GUIImageList_AddIcon ($hImage, "8.ico")
                _GUIImageList_AddIcon ($hImage, "9.ico")
                _GUIImageList_AddIcon ($hImage, "10.ico")                                
                _GUIImageList_AddIcon ($hImage, "11.ico")
                _GUIImageList_AddIcon ($hImage, "12.ico")
                _GUIImageList_AddIcon ($hImage, "13.ico")
                _GUIImageList_AddIcon ($hImage, "14.ico")
                _GUIImageList_AddIcon ($hImage, "15.ico")                
        ;_GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($hCombo, 0xFF0000, 16, 16))
        ;_GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($hCombo, 0x00FF00, 16, 16))
        ;_GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($hCombo, 0x0000FF, 16, 16))
        _GUICtrlComboBoxEx_SetImageList ($hCombo, $hImage)

        _GUICtrlComboBoxEx_InitStorage ($hCombo, 150, 300)
        
        _GUICtrlComboBoxEx_BeginUpdate ($hCombo)
        For $x = 0 To $var1[0][0]
                _GUICtrlComboBoxEx_AddString ($hCombo, $var1[$x][0], $x, $x,-1,-1);_GUICtrlComboBoxEx_AddString ($hCombo, StringFormat("%03d : Random string", Random(1, 200, 1)), $x, $x)
        Next
        _GUICtrlComboBoxEx_EndUpdate ($hCombo)

        ;Do

        ;Until GUIGetMsg() = $GUI_EVENT_CLOSE
        While 1
        $nMsg = GUIGetMsg()
                        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $rj=GUICtrlRead($hCombo)
                        MsgBox(0,"提示","你选择的是:"&$rj)
                EndSwitch
        WEnd
EndFunc   ;==>_Main

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-6-28 04:14:20 | 显示全部楼层
本帖最后由 lynfr8 于 2009-6-28 04:15 编辑

修改这一段即可:
        
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_GUICtrlComboBoxEx_GetItemText ($hCombo, _GUICtrlComboBoxEx_GetCurSel ($hCombo), $sText)
MsgBox(4160, "提示", "你选择的是: " & $sText)
                EndSwitch
        WEnd

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-6-28 04:23:21 | 显示全部楼层
autoit的内置GUI函数,GUICtrlRead, GUICtrlGetState等,它们的参数都是控件ID,而非控件句柄。
而UDF所创建的控件,都是返回其句柄,所以并不能使用内置函数来获取到任何信息,除非用API将句柄转换为ID,或直接用UDF来获取。
 楼主| 发表于 2009-6-28 11:07:14 | 显示全部楼层
搞定了!谢谢指点哈!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-2 15:54 , Processed in 0.078690 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表