#include <GUIConstants.au3>
Opt('MustDeclareVars', 1)
Global $GUI = GUICreate("Раскрывающийся список")
Global $hH = GuiCtrlCreateCombo('', 38, 37, 70, 24)
GUICtrlSetData(-1, '1|2|3')
Global $hK = GuiCtrlCreateCombo('', 38, 68, 70, 24)
GUICtrlSetData(-1, '1|2|3')
Global $hCalc = GUICtrlCreateButton('Рассчитать', 5, 104, 75, 28)
If Not $hCalc Or _
Not GUICtrlSetFont($hCalc, 9) Then Exit 1
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND')
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $hH
ConsoleWrite(GUICtrlRead($hH) & @CRLF)
GUICtrlSendMsg($hK, $CB_SETCURSEL, GUICtrlSendMsg($hH, $CB_GETCURSEL, 0, 0), 0)
Case $hK
ConsoleWrite(GUICtrlRead($hK) & @CRLF)
GUICtrlSendMsg($hH, $CB_SETCURSEL, GUICtrlSendMsg($hK, $CB_GETCURSEL, 0, 0), 0)
Case $hCalc
_Calc()
EndSwitch
WEnd
Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
If BitShift($wParam, 16) = $CBN_EDITCHANGE Then
If $lParam = GUICtrlGetHandle($hH) Then
Local $sH = GUICtrlRead($hH)
; Надо вставить значение $sH в элемент $hK
;ConsoleWrite($sH & @CRLF)
ControlSetText($GUI, "", $hK, $sH)
EndIf
If $lParam = GUICtrlGetHandle($hK) Then
Local $sK = GUICtrlRead($hK)
; Надо вставить значение $sK в элемент $hH
;ConsoleWrite($sK & @CRLF)
ControlSetText($GUI, "", $hH, $sK)
EndIf
EndIf
Return $GUI_RUNDEFMSG
EndFunc
Func _Calc()
Local $sH = GUICtrlRead($hH)
ConsoleWrite('H: ' & $sH & @CRLF)
Local $sK = GUICtrlRead($hK)
ConsoleWrite('K: ' & $sK & @CRLF)
EndFunc