Не корректно работает создание и удаление элемента GUI при нажатии на $nCheckbox1
Код:
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <UpdownConstants.au3>
Global $iInput1
Global $iInput2
$hGUI = GUICreate('Кабельные вводы', 980, 250, -1, -1, -1, $WS_CLIPCHILDREN)
$nInput1 = GUICtrlCreateInput('23', 10, 10, 50, 20)
GUICtrlCreateUpdown(-1, $UDS_ALIGNLEFT) ; слева
GUICtrlSetLimit(-1, 99, 1)
$nInput2 = GUICtrlCreateInput('33', 75, 10, 50, 20)
GUICtrlCreateUpdown(-1, $UDS_ALIGNRIGHT) ; справа
GUICtrlSetLimit(-1, 99, 1)
$nCheckbox1 = GUICtrlCreateCheckbox('', 130, 10, 20, 20)
$nOutput1 = GUICtrlCreateEdit('', 160, 10, 400, 100)
$nOutput2 = GUICtrlCreateEdit('', 570, 10, 400, 100)
$nOutput3 = GUICtrlCreateEdit('', 160, 130, 400, 100)
$nOutput4 = GUICtrlCreateEdit('', 570, 130, 400, 100)
GUISetState()
Dim $TCM = [["ТСМ 20/0+5-12", 5, 12], _
["ТСМ 30/0+13-23", 13, 23], _
["ТСМ 40/0+23-33", 23, 33], _
["ТСМ 60/0+34-51", 34, 51], _
["ТСМ 90/0+52-78", 52, 78], _
["ТСМ 120/0+79-99", 79, 99]]
Dim $RM = [["RM 20 (∅4-14,5)", 4, 14.5], _
["RM 30 (∅10-25)", 10, 25], _
["RM 40 (∅21,5-34,5)", 21.5, 34.5], _
["RM 60 (∅28-54)", 28, 54], _
["RM 90 (∅48-71)", 48, 71], _
["RM 120 (∅67,5-99)", 67.5, 99]]
Dim $RMe = [["RM 20w40 (∅3,5-16,5)", 3.5, 16.5], _
["RM 40 10-32 (∅9,5-32,5)", 9.5, 32.5], _
["RM 60 24-54 (∅24-54)", 24, 54]]
While 1
$dn = GUICtrlRead($nInput1)
$dk = GUICtrlRead($nInput2)
Select
Case $dn <> $iInput1
CabTCM()
CabTCM_1()
CabRM()
CabRM_1()
$iInput1 = $dn
Case $dk <> $iInput2
CabTCM()
CabTCM_1()
CabRM()
CabRM_1()
$iInput2 = $dk
Case $nCheckbox1
If BitAND(GUICtrlRead($nCheckbox1),$GUI_CHECKED) Then
ConsoleWrite('Нажато' & @CRLF)
$nInput3 = GUICtrlCreateInput('', 10, 40, 50, 20)
GUICtrlCreateUpdown(-1, $UDS_ALIGNLEFT) ; слева
GUICtrlSetLimit(-1, 99, 1)
$nInput4 = GUICtrlCreateInput('', 75, 40, 50, 20)
GUICtrlCreateUpdown(-1, $UDS_ALIGNRIGHT) ; справа
GUICtrlSetLimit(-1, 99, 1)
$nCheckbox2 = GUICtrlCreateCheckbox('', 130, 40, 20, 20)
Else
ConsoleWrite('Не нажато' & @CRLF)
;GUICtrlDelete ( $nInput3 )
EndIf
EndSelect
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func CabTCM()
If Int($dn) > Int($dk) Or $dn < $TCM[0][1] Or $dk > $TCM[UBound($TCM) - 1][2] Then Return GUICtrlSetData($nOutput1, "Некорректный диапазон")
GUICtrlSetData($nOutput1, '∅' & $dn & '–' & $dk & ':' & @TAB)
For $i = 0 To UBound($TCM) - 1
If $dn <= $TCM[$i][2] Then
;$n = $i
For $i = $i To UBound($TCM) - 1
If $dk > $TCM[$i][2] Then
ConsoleWrite($TCM[$i][0] & ', ')
GUICtrlSetData($nOutput1, $TCM[$i][0] & ', ', 1)
Else
;$k = $i
ConsoleWrite($TCM[$i][0] & @CRLF)
GUICtrlSetData($nOutput1, $TCM[$i][0], 1)
ExitLoop 2
EndIf
Next
EndIf
Next
EndFunc
Func CabRM()
If Number($dn) > Number($dk) Or $dn < $RMe[0][1] Or $dk > $RM[UBound($RM) - 1][2] Then Return GUICtrlSetData($nOutput2, "Некорректный диапазон")
GUICtrlSetData($nOutput2, '∅' & $dn & '–' & $dk & ':' & @TAB)
For $i = 0 To UBound($RM) - 1
If $dn >= $RM[$i][1] And $dk <= $RM[$i][2] Then Return GUICtrlSetData($nOutput2, $RM[$i][0], 1)
Next
For $i = 0 To UBound($RMe) - 1
If $dn >= $RMe[$i][1] And $dk <= $RMe[$i][2] Then Return GUICtrlSetData($nOutput2, $RMe[$i][0], 1)
Next
;GUICtrlSetData($nOutput2, "Не найдено")
Local $j = -1, $RMt = $RM
For $i = 0 To UBound($RM) - 1
If $dn >= $RMt[$i][1] And $dn <= $RMt[$i][2] Then $j = $i
Next
If $j = -1 Then
$RMt[0][0] = $RMe[0][0]
$RMt[0][1] = $RMe[0][1]
$RMt[0][2] = $RMe[0][2]
$j = 0
EndIf
For $i = $j To UBound($RMt) - 1
GUICtrlSetData($nOutput2, $RMt[$i][0] & ", ", 1)
If $dk >= $RMt[$i][1] And $dk <= $RMt[$i][2] Then Return
Next
EndFunc
Func CabTCM_1()
If Number($dn) > Number($dk) Or $dn < $TCM[0][1] Or $dk > $TCM[UBound($TCM) - 1][2] Then Return GUICtrlSetData($nOutput3, "Некорректный диапазон")
GUICtrlSetData($nOutput3, '∅' & $dn & '–' & $dk & ':' & @TAB)
For $i = 0 To UBound($TCM) - 1
If $dk <= $TCM[$i][2] Then
For $i = $i To 0 Step -1
If $dn >= $TCM[$i][1] Then
GUICtrlSetData($nOutput3, $TCM[$i][0], 1)
ExitLoop 2
Else
GUICtrlSetData($nOutput3, $TCM[$i][0] & ', ', 1)
EndIf
Next
Else
EndIf
Next
EndFunc
Func CabRM_1()
If Number($dn) > Number($dk) Or $dn < $RMe[0][1] Or $dk > $RM[UBound($RM) - 1][2] Then Return GUICtrlSetData($nOutput4, "Некорректный диапазон")
GUICtrlSetData($nOutput4, '∅' & $dn & '–' & $dk & ':' & @TAB)
For $i = 0 To UBound($RM) - 1
If $dn >= $RM[$i][1] And $dk <= $RM[$i][2] Then Return GUICtrlSetData($nOutput4, $RM[$i][0], 1)
Next
For $i = 0 To UBound($RMe) - 1
If $dn >= $RMe[$i][1] And $dk <= $RMe[$i][2] Then Return GUICtrlSetData($nOutput4, $RMe[$i][0], 1)
Next
For $i = 0 To UBound($RM) - 1
If $dk <= $RM[$i][2] Then
For $i = $i To 0 Step -1
If $dn >= $RM[$i][1] Then
GUICtrlSetData($nOutput4, $RM[$i][0], 1)
ExitLoop 2
Else
GUICtrlSetData($nOutput4, $RM[$i][0] & ', ', 1)
EndIf
Next
Else
EndIf
Next
EndFunc