诺言 发表于 2011-8-10 05:43:47

恼人的GUICtrlSetData,哪里错了?

本帖最后由 诺言 于 2011-8-10 16:22 编辑

Dim $Var
$Drive=DriveGetDrive("ALL")
For $i = 1 To $Drive
$Var=$Var&StringUpper($Drive[$i])&"|"
Next
MsgBox(0,0,$Var)
#include <GUIConstantsEx.au3>
$Form1 = GUICreate("", 100, 100, -1, -1)
$Combo1 = GUICtrlCreateCombo("", 10, 10, 40, 20, 0x0003)
;~ GUICtrlSetData(-1,"1|2|3","1")
GUICtrlSetData($Combo1,StringReplace($Var,"|","",-1),StringUpper($Drive))
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd已经自己解决,原因:GUICtrlCreateCombo不能定义高度Dim $Var
$Drive=DriveGetDrive("ALL")
For $i = 1 To $Drive
$Var=$Var&StringUpper($Drive[$i])&"|"
Next
MsgBox(0,0,$Var)
#include <GUIConstantsEx.au3>
$Form1 = GUICreate("", 100, 100, -1, -1)
$Combo1 = GUICtrlCreateCombo("", 10, 10, 40, -1, 0x0003)
;~ GUICtrlSetData(-1,"1|2|3","1")
GUICtrlSetData($Combo1,StringReplace($Var,"|","",-1),StringUpper($Drive))
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

happytc 发表于 2011-8-10 06:35:06

先要描述错在那里吧,我运行了下你贴的代码,没有错误提示,能运行!

ceoguang 发表于 2011-8-10 07:26:36

GUICtrlSetData($Combo1,$Var,StringUpper($Drive))

mo_shaojie 发表于 2011-8-10 08:16:09

楼主用错代码

诺言 发表于 2011-8-10 14:31:04

先要描述错在那里吧,我运行了下你贴的代码,没有错误提示,能运行!
happytc 发表于 2011-8-10 06:35 http://www.autoitx.com/images/common/back.gif

编译看看

诺言 发表于 2011-8-10 14:32:12

GUICtrlSetData($Combo1,$Var,StringUpper($Drive))
ceoguang 发表于 2011-8-10 07:26 http://www.autoitx.com/images/common/back.gif

这样也试过的,编译后还是不正常

诺言 发表于 2011-8-10 14:32:30

编译看看
诺言 发表于 2011-8-10 14:31 http://www.autoitx.com/images/common/back.gif

能说明哪里错了吗?

诺言 发表于 2011-8-10 14:32:52

楼主用错代码
mo_shaojie 发表于 2011-8-10 08:16 http://www.autoitx.com/images/common/back.gif

能说明哪里错了吗?

wa18239 发表于 2011-8-10 14:46:51

编译后没问题呀,楼主不能编译?

诺言 发表于 2011-8-10 15:06:02

编译后没问题呀,楼主不能编译?
wa18239 发表于 2011-8-10 14:46 http://www.autoitx.com/images/common/back.gif

编译后 GUICtrlCreateCombo 能正常显示吗?

骗子 发表于 2011-8-10 16:00:04

正常,跳出一个确定框,显示所有的盘符,点确定后跳出新的下拉菜单,里面的内容为所有盘符

mo_shaojie 发表于 2011-8-10 16:14:56

回复 8# 诺言 #include <GUIConstantsEx.au3>
Dim $Var
$Drive=DriveGetDrive("ALL")
For $i = 1 To $Drive
$Var=$Var&StringUpper($Drive[$i])&"|"
Next
$Form1 = GUICreate("", 100, 100, -1, -1)
$Combo1 = GUICtrlCreateCombo("", 10, 10, 40, 20, 0x0003)
GUICtrlSetData($Combo1,StringReplace($Var,"|","",-1),StringUpper($Drive))
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd试下以上那个看看.

netegg 发表于 2011-8-10 16:17:30

运行正常,不过楼主为什么这么用StringReplace($Var,"|","",-1), stringtrimright($var, 1)不行吗

诺言 发表于 2011-8-10 16:27:27

运行正常,不过楼主为什么这么用StringReplace($Var,"|","",-1), stringtrimright($var, 1)不行吗
netegg 发表于 2011-8-10 16:17 http://www.autoitx.com/images/common/back.gif
这样也可以,效果一样

netegg 发表于 2011-8-10 21:30:29

截张图上来看看
页: [1]
查看完整版本: 恼人的GUICtrlSetData,哪里错了?