yokoliu 发表于 2009-9-16 23:53:07

控件句柄如何转换为控件id?

本帖最后由 yokoliu 于 2009-9-17 09:17 编辑

#include <GuiComboBoxEx.au3>
#include <GuiConstantsEx.au3>



$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


Local $hGUI, $hImage, $input, $hCombo,$sText

; Create GUI
$hGUI = GUICreate("ComboBoxEx Add Dir", 400, 300, -1, -1, -1)
$hCombo = _GUICtrlComboBoxEx_Create ($hGUI, "", 2, 2, 394, 100)
$binput = GUICtrlCreateButton("Input control", 2, 30, 120)
GUISetState()


_GUICtrlComboBoxEx_BeginUpdate ($hCombo)
_GUICtrlComboBoxEx_AddDir ($hCombo, @ScriptDir & "\*.mdb")
_GUICtrlComboBoxEx_EndUpdate ($hCombo)

GUICtrlSetState($hCombo,$GUI_DISABLE)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case   $binput
MsgBox(0,0,_GUICtrlComboBoxEx_GetCurSel($hCombo))
_GUICtrlComboBoxEx_GetItemText($hCombo,_GUICtrlComboBoxEx_GetCurSel($hCombo),$sText)
MsgBox(4160, "Information", "Edit Text: " & $sText)
EndSwitch
WEnd

上面的GUICtrlSetState($hCombo,$GUI_DISABLE)不起作用
如果用GUICtrlCreateCombo,就可以,但是_GUICtrlComboBoxEx_AddDir ($hCombo, @ScriptDir & "\*.mdb")这句就不行了,_GUICtrlComboBoxEx_AddDir (GUICtrlGetHandle($hCombo), @ScriptDir & "\数据库\*.mdb"),也不行,
高手请支招

yokoliu 发表于 2009-9-16 23:54:59

GUICtrlCreateCombo 返回的id可以用GUICtrlGetHandle得到句柄,反过来呢?

bing614 发表于 2009-9-17 00:54:55

ControlDisable ($hGUI, "",$hCombo)

pusofalse 发表于 2009-9-17 00:57:16

_WinAPI_GetDlgCtrlID($hWnd)

yokoliu 发表于 2009-9-17 09:16:55

楼上两位,太感谢了!!

xiehuahere 发表于 2012-11-8 14:33:15

控件句柄转控件ID。。。学习了!

171239435 发表于 2019-3-15 17:38:12

pusofalse 发表于 2009-9-17 00:57
_WinAPI_GetDlgCtrlID($hWnd)

感谢。{:face (130):}
页: [1]
查看完整版本: 控件句柄如何转换为控件id?