如何让输入框的获取Combo控件内容。
本帖最后由 udbghdto 于 2011-7-21 16:58 编辑想做到$Input1 输入框默认值是:D:\123,$Combo1 是显示硬盘所有分区,如果是下拉选择框选择了E:。$Input1就是显示E:\123, 如果是下拉选择框选择了F:。$Input1就是显示F:\123,如此效果。。
2.3#都可以。。谢谢了。。
可是我写的不能实现。不是哪里出错了。#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$Input1 = GUICtrlCreateInput("", 56, 88, 337, 21,$ES_readonly)
$Combo1 = GUICtrlCreateCombo("", 448, 88, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $CBS_dropdownlist))
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
$var = DriveGetDrive("FIXED")
If $var = 2 Then
GUICtrlSetData($Combo1, "D:", "D:")
EndIf
If $var = 3 Then
GUICtrlSetData($Combo1, "D:|E:", "D:")
EndIf
If $var = 4 Then
GUICtrlSetData($Combo1, "D:|E:|F:", "D:")
EndIf
If $var = 5 Then
GUICtrlSetData($Combo1, "D:|E:|F:|G:", "D:")
EndIf
If $var > 5 Then
GUICtrlSetData($Combo1, "D:|E:|F:|G:|H:", "D:")
EndIf
If GUICtrlRead($Combo1) = "D:" Then
GUICtrlSetData($Input1,"D:\123")
EndIf
If GUICtrlRead($Combo1) = "E:" Then
GUICtrlSetData($Input1,"E:\123")
EndIf
If GUICtrlRead($Combo1) = "F:" Then
GUICtrlSetData($Input1,"F:\123")
EndIf
If GUICtrlRead($Combo1) = "G:" Then
GUICtrlSetData($Input1,"G:\123")
EndIf
If GUICtrlRead($Combo1) = "H:" Then
GUICtrlSetData($Input1,"H:\123")
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$Input1 = GUICtrlCreateInput("", 56, 88, 337, 21,$ES_readonly)
$Combo1 = GUICtrlCreateCombo("", 448, 88, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $CBS_dropdownlist))
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
$var = DriveGetDrive("FIXED")
If $var = 2 Then
GUICtrlSetData($Combo1, "D:", "D:")
EndIf
If $var = 3 Then
GUICtrlSetData($Combo1, "D:|E:", "D:")
EndIf
If $var = 4 Then
GUICtrlSetData($Combo1, "D:|E:|F:", "D:")
EndIf
If $var = 5 Then
GUICtrlSetData($Combo1, "D:|E:|F:|G:", "D:")
EndIf
If $var > 5 Then
GUICtrlSetData($Combo1, "D:|E:|F:|G:|H:", "D:")
EndIf
While 1
If GUICtrlRead($Combo1) = "D:" Then
GUICtrlSetData($Input1,"D:\123")
EndIf
If GUICtrlRead($Combo1) = "E:" Then
GUICtrlSetData($Input1,"E:\123")
EndIf
If GUICtrlRead($Combo1) = "F:" Then
GUICtrlSetData($Input1,"F:\123")
EndIf
If GUICtrlRead($Combo1) = "G:" Then
GUICtrlSetData($Input1,"G:\123")
EndIf
If GUICtrlRead($Combo1) = "H:" Then
GUICtrlSetData($Input1,"H:\123")
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd 本帖最后由 南一 于 2011-8-30 13:16 编辑
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $var = DriveGetDrive("FIXED")
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
$Input1 = GUICtrlCreateInput("", 56, 88, 337, 21, $ES_readonly)
$Combo1 = GUICtrlCreateCombo($var, 448, 88, 145, 25, $CBS_dropdownlist)
For $i = 2 To $var
GUICtrlSetData($Combo1, $var[$i])
Next
GUICtrlSetData($Input1, $var & "\123")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
$Drive = GUICtrlRead($Combo1)
GUICtrlSetData($Input1, $Drive & "\123")
EndSwitch
WEnd
回复 3# 南一
哇!南老师好久不见咯! 回复 2# menfan1
为什么我原来的代码不行呢,是哪里出错了。。下次好注意。。 我的代码是哪里错了。南哥 谢谢分享... 首先这种检测磁盘数量,然后输出的方法是不科学的,你要求里面写着是在combo里显示所有磁盘分区,但以你的代码是存在缺陷的。
然后是你对combo的操作,你是跟在窗体窗体代码后面的,也就是说这个代码只会跟随窗体执行一次,以后的操作就是失效的。所以你分区可以显示,但后期对combo进行操作,是无效的,后面的操作代码需写在while wend里面。
你的代码我已经进行了修改,可以精简些,目的达到即可。 赋初始值和循环判断的问题哈
页:
[1]