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

[AU3基础] 如何通过$WM_COMMAND把combox 选择后的值赋值给某变量

[复制链接]
发表于 2010-6-9 18:03:23 | 显示全部楼层 |阅读模式
本帖最后由 wjscxs 于 2010-6-11 17:53 编辑
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#Region ### START Koda GUI section ### Form=
$Form = GUICreate("", 441, 278, @DesktopWidth-460, -5)
$nian = _GUICtrlComboBox_Create($Form,"", 63, 7, 48, 25)
_GUICtrlComboBox_BeginUpdate($nian)
for $i =0 to 148
        _GUICtrlComboBox_AddString($nian,$i+1901)
Next
_GUICtrlComboBox_SetEditText($nian,@YEAR)
_GUICtrlComboBox_EndUpdate($nian)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND,"combo_edit")
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
func combo_edit($hWnd, $iMsg, $iwParam, $ilParam)
        #forceref $hWnd, $iMsg
        Local  $hWndFrom,$iCode
        $hWndFrom = $ilParam
        ;$iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
        $iCode = BitShift($iwParam, 16) ; Hi Word
        Switch $hWndFrom
                Case $nian
                        Switch $iCode
                                Case $CBN_SELCHANGE
                                        MsgBox(1,"",_GUICtrlComboBox_GetEditText($nian))
                        EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND
看到没,那个msgbox(MsgBox(1,"",_GUICtrlComboBox_GetEditText($nian)))有没办法让它显示combo选择后的值,(不是选择前的值)
 楼主| 发表于 2010-6-11 20:06:12 | 显示全部楼层
bump,,,,,,,
发表于 2010-6-11 20:17:21 | 显示全部楼层
Local $sText, $iCurSel

Switch $iCode
Case $CBN_SELENDOK
        $iCurSel = _GUICtrlComboBox_GetCurSel($nian)
        _GUICtrlComboBox_GetLBText($nian, $iCurSel, $sText)
        MsgBox(1,"", $sText)
EndSwitch
 楼主| 发表于 2010-6-12 07:39:28 | 显示全部楼层
谢谢......
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-24 13:10 , Processed in 0.101164 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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