控件不算多的情况下直接搜索数组,控件多的情况下生成字典,
字典1==》左侧INPUT的ID==>右侧INPUT的ID
字典2==》右侧INPUT的ID==>左侧INPUT的ID
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <array.au3>
Opt("GUIOnEventMode", 1)
;~ Global $aInput_NUM1[10], $aInput_NUM2[10], $aLabel_Count1[10], $aInput_NUM3[10], $aInput_NUM4[10], $aLabel_Count2[10]
;~ Global $COUNT[10]
Global $aInput_NUM1[10][3], $aLabel_Count1[10]
#Region ### START Koda GUI section ### Form=
$WinForm = GUICreate("QQ超市售货能力计算器", 716, 352, 274, 215)
GUISetOnEvent(-3,"_exit")
$Group1 = GUICtrlCreateGroup("Group1", 8, 8, 169, 345)
For $i = 0 To 9
$aInput_NUM1[$i][0] = GUICtrlCreateInput("1", 16, 24 + $i * 24, 41, 21)
$aInput_NUM1[$i][1] = GUICtrlCreateInput("0", 64, 24 + $i * 24, 41, 21)
$aInput_NUM1[$i][2] = GUICtrlCreateLabel("0", 112, 24 + $i * 24, 36, 17)
GUICtrlCreateUpdown($aInput_NUM1[$i][0])
GUICtrlSetLimit(-1, 30, 1)
GUICtrlCreateUpdown($aInput_NUM1[$i][1])
GUICtrlSetLimit(-1, 30, 0)
Next
GUICtrlCreateGroup("", -99, -99, 1, 1)
;~ $Group2 = GUICtrlCreateGroup("Group2", 168, 8, 169, 345)
;~ For $i = 0 To 9
;~ $aInput_NUM3[$i] = GUICtrlCreateInput("1", 168, 24 + $i * 24, 41, 21)
;~ GUICtrlCreateUpdown($aInput_NUM3[$i])
;~ GUICtrlSetLimit(-1, 30, 1)
;~ Next
;~ For $i = 0 To 9
;~ $aInput_NUM4[$i] = GUICtrlCreateInput("0", 216, 24 + $i * 24, 41, 21)
;~ GUICtrlCreateUpdown($aInput_NUM4[$i])
;~ GUICtrlSetLimit(-1, 30, 0)
;~ Next
;~ For $i = 0 To 9
;~ $aLabel_Count2[$i] = GUICtrlCreateLabel("0", 264, 24 + $i * 24, 36, 17)
;~ Next
;~ GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
#EndRegion ### END Koda GUI section ###
While 1
Sleep(10)
WEnd
Func _exit()
Exit
EndFunc
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg
Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
$hWndFrom = $ilParam
$iIDFrom = _WinAPI_LoWord($iwParam)
$iCode = _WinAPI_HiWord($iwParam)
If $iCode = $EN_CHANGE Then
$index=_ArraySearch($aInput_NUM1,$iIDFrom,0,0,0,0,1,0)
If $index>-1 Then
GUICtrlSetData($aInput_NUM1[$index][2],GUICtrlRead($aInput_NUM1[$index][0])*GUICtrlRead($aInput_NUM1[$index][1]))
Else
$index=_ArraySearch($aInput_NUM1,$iIDFrom,0,0,0,0,1,1)
If Not @error Then GUICtrlSetData($aInput_NUM1[$index][2],GUICtrlRead($aInput_NUM1[$index][0])*GUICtrlRead($aInput_NUM1[$index][1]))
EndIf
EndIf
EndFunc ;==>WM_COMMAND
|