找回密码
 加入
搜索
查看: 4882|回复: 14

[GUI管理] 恼人的GUICtrlSetData,哪里错了?

 火.. [复制链接]
发表于 2011-8-10 05:43:47 | 显示全部楼层 |阅读模式
本帖最后由 诺言 于 2011-8-10 16:22 编辑
Dim $Var
$Drive=DriveGetDrive("ALL")
For $i = 1 To $Drive[0]
$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[1]))
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[0]
$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[1]))
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
发表于 2011-8-10 06:35:06 | 显示全部楼层
先要描述错在那里吧,我运行了下你贴的代码,没有错误提示,能运行!
发表于 2011-8-10 07:26:36 | 显示全部楼层
GUICtrlSetData($Combo1,$Var,StringUpper($Drive[1]))
发表于 2011-8-10 08:16:09 | 显示全部楼层
楼主用错代码
 楼主| 发表于 2011-8-10 14:31:04 | 显示全部楼层
先要描述错在那里吧,我运行了下你贴的代码,没有错误提示,能运行!
happytc 发表于 2011-8-10 06:35


编译看看
 楼主| 发表于 2011-8-10 14:32:12 | 显示全部楼层
GUICtrlSetData($Combo1,$Var,StringUpper($Drive[1]))
ceoguang 发表于 2011-8-10 07:26


这样也试过的,编译后还是不正常
 楼主| 发表于 2011-8-10 14:32:30 | 显示全部楼层
编译看看
诺言 发表于 2011-8-10 14:31


能说明哪里错了吗?
 楼主| 发表于 2011-8-10 14:32:52 | 显示全部楼层
楼主用错代码
mo_shaojie 发表于 2011-8-10 08:16


能说明哪里错了吗?
发表于 2011-8-10 14:46:51 | 显示全部楼层
编译后没问题呀,楼主不能编译?
 楼主| 发表于 2011-8-10 15:06:02 | 显示全部楼层
编译后没问题呀,楼主不能编译?
wa18239 发表于 2011-8-10 14:46


编译后 GUICtrlCreateCombo 能正常显示吗?
发表于 2011-8-10 16:00:04 | 显示全部楼层
正常,跳出一个确定框,显示所有的盘符,点确定后跳出新的下拉菜单,里面的内容为所有盘符
发表于 2011-8-10 16:14:56 | 显示全部楼层
回复 8# 诺言
#include <GUIConstantsEx.au3>
Dim $Var
$Drive=DriveGetDrive("ALL")
For $i = 1 To $Drive[0]
$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[1]))
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
试下以上那个看看.
发表于 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

这样也可以,效果一样
发表于 2011-8-10 21:30:29 | 显示全部楼层
截张图上来看看
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-10 22:24 , Processed in 0.089379 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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