一组单选框选中即执行命令,如何简单点写?
如果单选框少还好办,多了一个个写case太不靠谱了,有没有简便点的写法?#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 432, 145, 192, 114)
$Group1 = GUICtrlCreateGroup("Group1", 24, 16, 369, 49)
$Radio1 = GUICtrlCreateRadio("Radio1", 40, 32, 81, 25)
$Radio2 = GUICtrlCreateRadio("Radio2", 129, 32, 81, 25)
$Radio3 = GUICtrlCreateRadio("Radio3", 217, 32, 81, 25)
$Radio4 = GUICtrlCreateRadio("Radio4", 306, 32, 81, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input1 = GUICtrlCreateInput("Input1", 56, 80, 97, 21)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Radio1
GUICtrlSetData($Input1, "a")
Case $Radio2
GUICtrlSetData($Input1, "b")
Case $Radio3
GUICtrlSetData($Input1, "c")
Case $Radio4
GUICtrlSetData($Input1, "d")
EndSwitch
WEnd
用数组存储id afan 发表于 2023-9-9 21:45
用数组存储id
来条鱼啊...
================= #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 432, 145, 192, 114)
$Group1 = GUICtrlCreateGroup("Group1", 24, 16, 369, 49)
$Radio1 = GUICtrlCreateRadio("Radio1", 40, 32, 81, 25)
$Radio2 = GUICtrlCreateRadio("Radio2", 129, 32, 81, 25)
$Radio3 = GUICtrlCreateRadio("Radio3", 217, 32, 81, 25)
$Radio4 = GUICtrlCreateRadio("Radio4", 306, 32, 81, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input1 = GUICtrlCreateInput("Input1", 56, 80, 97, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Radio1 To $Radio4
Example($Input1,$nMsg)
EndSwitch
WEnd
Func Example($Input,$Msg)
GUICtrlSetData($Input, Chr(61+$Msg))
EndFunc ;==>Example
我也凑个热闹,用@gyp2000的代码。
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 432, 145, 192, 114)
$Group1 = GUICtrlCreateGroup("Group1", 24, 16, 369, 49)
$Radio1 = GUICtrlCreateRadio("Radio1", 40, 32, 81, 25)
$Radio2 = GUICtrlCreateRadio("Radio2", 129, 32, 81, 25)
$Radio3 = GUICtrlCreateRadio("Radio3", 217, 32, 81, 25)
$Radio4 = GUICtrlCreateRadio("Radio4", 306, 32, 81, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input1 = GUICtrlCreateInput("Input1", 56, 80, 97, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
If StringInStr(GUICtrlRead($nMsg,1),'Radio') > 0 Then Example($Input1,$nMsg)
WEnd
Func Example($Input,$Msg)
GUICtrlSetData($Input, GUICtrlRead($nMsg,1))
EndFunc ;==>Example
绿色风 发表于 2023-9-10 10:37
我也凑个热闹,用@gyp2000的代码。
这个对比文字好像不具普适性,我拼凑了一段代码,好像有点问题,那个返回的消息ID没规律???
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
Dim $Radio,$Radio2
$Form1 = GUICreate("Form1", 432, 245, 192, 114)
$Group1 = GUICtrlCreateGroup("Group1", 24, 16, 369, 49)
$Radio = GUICtrlCreateRadio("Radio1", 40, 32, 81, 25)
$Radio = GUICtrlCreateRadio("Radio2", 129, 32, 81, 25)
$Radio = GUICtrlCreateRadio("Radio3", 217, 32, 81, 25)
$Radio = GUICtrlCreateRadio("Radio4", 306, 32, 81, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Group1", 24, 116, 369, 49)
$Radio2 = GUICtrlCreateRadio("Radio21", 40, 132, 81, 25)
$Radio2 = GUICtrlCreateRadio("Radio22", 129, 132, 81, 25)
$Radio2 = GUICtrlCreateRadio("Radio23", 217, 132, 81, 25)
$Radio2 = GUICtrlCreateRadio("Radio24", 306, 132, 81, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input1 = GUICtrlCreateInput("Input1", 56, 80, 97, 21)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg(0)
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Radio To $Radio
$Rdo=$nMsg
GUICtrlSetData($Input1, $Rdo)
Case $Radio2 To $Radio2
$Rdo1=$nMsg
GUICtrlSetData($Input1, $Rdo1)
EndSwitch
WEnd GUICreate('Form1', 632, 250)
GUICtrlCreateGroup('Group1', 24, 16, 550, 49)
Local $aRadio1 = [, ['a1'], ['b1'], ['c1'], ['d1'], ['e1'], ['f1']]
For $i = 1 To 6
$aRadio1[$i] = GUICtrlCreateRadio('Radio1-' & $i, 40 + ($i - 1) * 90, 32, 81, 25)
Next
Local $Input1 = GUICtrlCreateInput('Input1', 56, 80, 97, 21)
GUICtrlCreateGroup('Group2', 24, 115, 550, 49)
Local $aRadio2 = [, ['a2'], ['b2'], ['c2'], ['d2'], ['e2'], ['f2']]
For $i = 1 To 6
$aRadio2[$i] = GUICtrlCreateRadio('Radio2-' & $i, 40 + ($i - 1) * 90, 130, 81, 25)
Next
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $aRadio1 To $aRadio1[$aRadio1]
GUICtrlSetData($Input1, $aRadio1[$nMsg - $aRadio1 + 1])
Case $aRadio2 To $aRadio2[$aRadio2]
GUICtrlSetData($Input1, $aRadio2[$nMsg - $aRadio2 + 1])
EndSwitch
WEnd afan 发表于 2023-9-10 11:52
这条鱼不错,有很多启发...{:1_206:} afan 发表于 2023-9-10 11:52
消息ID,根据创建的先后顺序 来产生的。 Switch $nMsg
Case x to x
EndSwitch
这种形式 创建控件需要连续创建,中间有其他控件的话就会出问题
Global $controlMap[]
GUICreate('Form1', 632, 250)
GUICtrlCreateGroup('Group1', 24, 16, 550, 49)
Local $aRadio1 = [, ['a1'], ['b1'], ['c1'], ['d1'], ['e1'], ['f1']]
For $i = 1 To 6
$aRadio1[$i] = GUICtrlCreateRadio('Radio1-' & $i, 40 + ($i - 1) * 90, 32, 81, 25)
$controlMap[$aRadio1[$i]] = $aRadio1[$i]
Next
Local $Input1 = GUICtrlCreateInput('Input1', 56, 80, 97, 21)
GUICtrlCreateGroup('Group2', 24, 115, 550, 49)
Local $aRadio2 = [, ['a2'], ['b2'], ['c2'], ['d2'], ['e2'], ['f2']]
For $i = 1 To 6
$aRadio2[$i] = GUICtrlCreateRadio('Radio2-' & $i, 40 + ($i - 1) * 90, 130, 81, 25)
$controlMap[$aRadio2[$i]] = $aRadio2[$i]
Next
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case Else
If $nMsg > 0 and MapExists($controlMap, $nMsg) Then GUICtrlSetData($Input1, $controlMap[$nMsg])
EndSwitch
WEnd
3131210 发表于 2023-9-10 19:19
Switch $nMsg
Case x to x
EndSwitch
你们为什么都用1 to 6,不用0? 根据各位的提示捣鼓的成品,目前发现是Group不能直接一次设置为显示/隐藏,另外Combox高度设置好像无效?
变量定义的时候有点麻烦,实际上可以用$Rdo这种,不过会过意来的时候已经成屎山了,懒得改了...
#region AutoIt3Wrapper 预编译参数(常用参数)
#AutoIt3Wrapper_Icon=F:\AU3脚本\图标\hidao.ico;图标,支持EXE,DLL,ICO
#AutoIt3Wrapper_OutFile=R_Calc.exe ;输出文件名
#AutoIt3Wrapper_OutFile_Type=exe ;文件类型
#AutoIt3Wrapper_Compression=9;压缩等级
#AutoIt3Wrapper_UseUPX=y;使用压缩
#AutoIt3Wrapper_Res_Comment=R_Calc ;注释
#AutoIt3Wrapper_Res_Description=电阻计算器;详细信息
#AutoIt3Wrapper_Res_Fileversion=0.1.2023.910
#AutoIt3Wrapper_Res_FileVersion_AutoIncrement=;p ;自动更新版本
#AutoIt3Wrapper_Res_LegalCopyright=邪恶海盗;版权
#endregion AutoIt3Wrapper 预编译参数(常用参数)
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
#region ### START Koda GUI section ### Form=f:\au3脚本\色环电阻.kxf
Dim $Radio1, $Radio2, $Radio3, $Radio4, $Radio5, $Radio6, $i1 = 0, $i2 = 0, $i3 = 0, $i4 = 0, $i5 = 0, $i6 = 0
Dim $Rdo1_3 = ['黑=0', '棕=1', '红=2', '橙=3', '黄=4', '绿=5', '蓝=6', '紫=7', '灰=8', '白=9']
Dim $Rdo1_3L = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
Dim $Color1_3 =
Dim $Rdo4 = ['黑=0', '棕=1', '红=2', '橙=3', '黄=4', '绿=5', '蓝=6', '紫=7', '金=-1', '银=-2']
Dim $Rdo4L = ['0', '1', '2', '3', '4', '5', '6', '7', '-1', '-2']
Dim $Color4 =
Dim $Rdo5 = ['棕=±1', '红=±2', '绿=±0.5', '蓝=±0.25', '紫=±0.1', '灰=±0.05', '金=±5', '银=±10']
Dim $Rdo5L = ['±1', '±2', '±0.5', '±0.25', '±0.1', '±0.05', '±5', '±10']
Dim $Color5 =
Dim $Rdo6 = ['棕=100ppm', '红=50ppm', '橙=15ppm', '黄=25ppm', '蓝=10ppm', '紫=5ppm']
Dim $Rdo6L = ['100ppm/℃', '50ppm/℃', '15ppm/℃', '25ppm/℃', '10ppm/℃', '5ppm/℃']
Dim $Color6 =
$Form1_1 = GUICreate("电阻计算器 v0.1 20230910", 535, 365)
$oeminfo = GUICtrlCreateLabel('邪恶海盗 www.hidao.org', 375, 1, 160, 18, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 10)
GUICtrlSetColor(-1, 0x0000FF)
$Tab1 = GUICtrlCreateTab(0, 0, 535, 365)
$TabSheet1 = GUICtrlCreateTabItem("色环转阻值")
$Radio30 = GUICtrlCreateRadio("3环电阻", 10, 30, 70, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
$Radio40 = GUICtrlCreateRadio("4环电阻", 10, 55, 70, 25)
$Radio50 = GUICtrlCreateRadio("5环电阻", 85, 30, 70, 25)
$Radio60 = GUICtrlCreateRadio("6环电阻", 85, 55, 70, 25)
GUICtrlCreateLabel(" ", 165, 54, 10, 2, $SS_ETCHEDHORZ)
GUICtrlCreateLabel(" ", 170, 35, 125, 40, $SS_GRAYFRAME)
GUICtrlCreateLabel(" ", 293, 54, 10, 2, $SS_ETCHEDHORZ)
$Label01 = GUICtrlCreateLabel(" ", 185, 34, 10, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Color1_3)
$Label02 = GUICtrlCreateLabel(" ", 200, 34, 10, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Color1_3)
$Label03 = GUICtrlCreateLabel(" ", 215, 34, 10, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Color1_3)
$Label04 = GUICtrlCreateLabel(" ", 230, 34, 10, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Color4)
$Label05 = GUICtrlCreateLabel(" ", 255, 34, 10, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Color5)
$Label06 = GUICtrlCreateLabel(" ", 270, 34, 10, 42, $SS_SUNKEN)
GUICtrlSetBkColor(-1, $Color6)
GUICtrlSetState($Label03, $GUI_HIDE)
GUICtrlSetState($Label05, $GUI_HIDE)
GUICtrlSetState($Label06, $GUI_HIDE)
$Lab1 = GUICtrlCreateLabel("计算过程及结果", 305, 25, 220, 25, $SS_SUNKEN + $SS_CENTERIMAGE)
;GUICtrlSetFont(-1,10)
$Lab2 = GUICtrlCreateLabel("计算过程及结果", 305, 50, 220, 25, $SS_SUNKEN + $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 10)
$Group1 = GUICtrlCreateGroup("第1位", 10, 85, 70, 270)
GUICtrlSetFont(-1, 9)
For $Rn1 = 0 To 9
$Radio1[$Rn1] = GUICtrlCreateRadio($Rdo1_3[$Rn1], 15, 100 + 25 * $Rn1, 60, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Color1_3[$Rn1])
Next
GUICtrlSetColor($Radio1, 0x000000)
GUICtrlSetColor($Radio1, 0x000000)
GUICtrlSetState($Radio1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("第2位", 85, 85, 70, 270)
GUICtrlSetFont(-1, 9)
For $Rn2 = 0 To 9
$Radio2[$Rn2] = GUICtrlCreateRadio($Rdo1_3[$Rn2], 90, 100 + 25 * $Rn2, 60, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Color1_3[$Rn2])
Next
GUICtrlSetColor($Radio2, 0x000000)
GUICtrlSetColor($Radio2, 0x000000)
GUICtrlSetState($Radio2, $GUI_CHECKED)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("第3位", 160, 85, 70, 270)
GUICtrlSetFont(-1, 9)
For $Rn3 = 0 To 9
$Radio3[$Rn3] = GUICtrlCreateRadio($Rdo1_3[$Rn3], 165, 100 + 25 * $Rn3, 60, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Color1_3[$Rn3])
Next
GUICtrlSetColor($Radio3, 0x000000)
GUICtrlSetColor($Radio3, 0x000000)
GUICtrlSetState($Radio3, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("倍率(10^n)", 235, 85, 80, 270)
GUICtrlSetFont(-1, 9)
For $Rn4 = 0 To 9
$Radio4[$Rn4] = GUICtrlCreateRadio($Rdo4[$Rn4], 240, 100 + 25 * $Rn4, 70, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Color4[$Rn4])
Next
GUICtrlSetColor($Radio4, 0x000000)
GUICtrlSetState($Radio4, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group5 = GUICtrlCreateGroup("误差(%)", 320, 85, 100, 270)
GUICtrlSetFont(-1, 9)
For $Rn5 = 0 To 7
$Radio5[$Rn5] = GUICtrlCreateRadio($Rdo5[$Rn5], 325, 100 + 25 * $Rn5, 90, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Color5[$Rn5])
Next
GUICtrlSetState($Radio5, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group6 = GUICtrlCreateGroup("温度系数(/℃)", 425, 85, 100, 270)
GUICtrlSetFont(-1, 9)
For $Rn6 = 0 To 5
$Radio6[$Rn6] = GUICtrlCreateRadio($Rdo6[$Rn6], 430, 100 + 25 * $Rn6, 90, 25)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $Color6[$Rn6])
Next
GUICtrlSetColor($Radio6, 0x000000)
GUICtrlSetState($Radio6, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState($Group3, $GUI_HIDE)
For $Radio_30 In $Radio3
GUICtrlSetState($Radio_30, $GUI_HIDE)
Next
GUICtrlSetState($Group5, $GUI_HIDE)
For $Radio_50 In $Radio5
GUICtrlSetState($Radio_50, $GUI_HIDE)
Next
GUICtrlSetState($Group6, $GUI_HIDE)
For $Radio_60 In $Radio6
GUICtrlSetState($Radio_60, $GUI_HIDE)
Next
$TabSheet4 = GUICtrlCreateTabItem("串并联阻值计算")
;GUICtrlSetState(-1, $GUI_SHOW)
$Group7 = GUICtrlCreateGroup("串联阻值计算", 10, 35, 505, 95)
$InputR11 = GUICtrlCreateInput("", 24, 55, 50, 25)
$Combo11 = GUICtrlCreateCombo("", 74, 55, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$InputR12 = GUICtrlCreateInput("", 144, 55, 50, 25)
$Combo12 = GUICtrlCreateCombo("", 194, 55, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$InputR13 = GUICtrlCreateInput("?", 294, 55, 100, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
$ButtonR1 = GUICtrlCreateButton("计算", 424, 54, 65, 25)
$InputR21 = GUICtrlCreateInput("", 22, 95, 50, 25)
$Combo21 = GUICtrlCreateCombo("", 72, 95, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$InputR22 = GUICtrlCreateInput("?", 144, 95, 100, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
$InputR23 = GUICtrlCreateInput("", 294, 95, 50, 25)
$Combo23 = GUICtrlCreateCombo("", 344, 95, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$ButtonR2 = GUICtrlCreateButton("计算", 425, 94, 65, 25)
GUICtrlCreateLabel("=", 254, 55, 25, 25, $SS_CENTER + $SS_CENTERIMAGE)
GUICtrlCreateLabel("=", 254, 97, 25, 25, $SS_CENTER + $SS_CENTERIMAGE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group8 = GUICtrlCreateGroup("并联阻值计算", 10, 140, 505, 95)
$InputR31 = GUICtrlCreateInput("", 24, 160, 50, 25)
$Combo31 = GUICtrlCreateCombo("", 74, 161, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$InputR32 = GUICtrlCreateInput("", 144, 161, 50, 25)
$Combo32 = GUICtrlCreateCombo("", 194, 161, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
GUICtrlCreateLabel("=", 254, 163, 25, 25, $SS_CENTER + $SS_CENTERIMAGE)
$InputR33 = GUICtrlCreateInput("?", 294, 161, 100, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
$ButtonR3 = GUICtrlCreateButton("计算", 424, 160, 65, 25)
$InputR41 = GUICtrlCreateInput("", 24, 200, 50, 25)
$Combo41 = GUICtrlCreateCombo(" ", 74, 200, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$InputR42 = GUICtrlCreateInput("?", 144, 200, 100, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel("=", 254, 202, 25, 25, $SS_CENTER + $SS_CENTERIMAGE)
$InputR43 = GUICtrlCreateInput("", 294, 200, 50, 25)
$Combo43 = GUICtrlCreateCombo("", 344, 200, 50, 25)
GUICtrlSetData(-1, "Ω|KΩ|MΩ", 'Ω')
$ButtonR4 = GUICtrlCreateButton("计算", 424, 199, 65, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $oeminfo
ShellExecute('www.hidao.org')
Case $Radio30
GUICtrlSetState($Label03, $GUI_HIDE)
GUICtrlSetState($Label04, $GUI_SHOW)
GUICtrlSetState($Label05, $GUI_HIDE)
GUICtrlSetState($Label06, $GUI_HIDE)
GUICtrlSetState($Group3, $GUI_HIDE)
For $Radio_30 In $Radio3
GUICtrlSetState($Radio_30, $GUI_HIDE)
Next
GUICtrlSetState($Group4, $GUI_SHOW)
For $Radio_40 In $Radio4
GUICtrlSetState($Radio_40, $GUI_SHOW)
Next
GUICtrlSetState($Group5, $GUI_HIDE)
For $Radio_50 In $Radio5
GUICtrlSetState($Radio_50, $GUI_HIDE)
Next
GUICtrlSetState($Group6, $GUI_HIDE)
For $Radio_60 In $Radio6
GUICtrlSetState($Radio_60, $GUI_HIDE)
Next
_Calc()
Case $Radio40
GUICtrlSetState($Label03, $GUI_HIDE)
GUICtrlSetState($Label04, $GUI_SHOW)
GUICtrlSetState($Label05, $GUI_SHOW)
GUICtrlSetState($Label06, $GUI_HIDE)
GUICtrlSetState($Group3, $GUI_HIDE)
For $Radio_30 In $Radio3
GUICtrlSetState($Radio_30, $GUI_HIDE)
Next
GUICtrlSetState($Group4, $GUI_SHOW)
For $Radio_40 In $Radio4
GUICtrlSetState($Radio_40, $GUI_SHOW)
Next
GUICtrlSetState($Group5, $GUI_SHOW)
For $Radio_50 In $Radio5
GUICtrlSetState($Radio_50, $GUI_SHOW)
Next
GUICtrlSetState($Group6, $GUI_HIDE)
For $Radio_60 In $Radio6
GUICtrlSetState($Radio_60, $GUI_HIDE)
Next
_Calc()
Case $Radio50
GUICtrlSetState($Label03, $GUI_SHOW)
GUICtrlSetState($Label04, $GUI_SHOW)
GUICtrlSetState($Label05, $GUI_SHOW)
GUICtrlSetState($Label06, $GUI_HIDE)
GUICtrlSetState($Group3, $GUI_SHOW)
For $Radio_30 In $Radio3
GUICtrlSetState($Radio_30, $GUI_SHOW)
Next
GUICtrlSetState($Group4, $GUI_SHOW)
For $Radio_40 In $Radio4
GUICtrlSetState($Radio_40, $GUI_SHOW)
Next
GUICtrlSetState($Group5, $GUI_SHOW)
For $Radio_50 In $Radio5
GUICtrlSetState($Radio_50, $GUI_SHOW)
Next
GUICtrlSetState($Group6, $GUI_HIDE)
For $Radio_60 In $Radio6
GUICtrlSetState($Radio_60, $GUI_HIDE)
Next
_Calc()
Case $Radio60
GUICtrlSetState($Label03, $GUI_SHOW)
GUICtrlSetState($Label04, $GUI_SHOW)
GUICtrlSetState($Label05, $GUI_SHOW)
GUICtrlSetState($Label06, $GUI_SHOW)
GUICtrlSetState($Group3, $GUI_SHOW)
For $Radio_30 In $Radio3
GUICtrlSetState($Radio_30, $GUI_SHOW)
Next
GUICtrlSetState($Group4, $GUI_SHOW)
For $Radio_40 In $Radio4
GUICtrlSetState($Radio_40, $GUI_SHOW)
Next
GUICtrlSetState($Group5, $GUI_SHOW)
For $Radio_50 In $Radio5
GUICtrlSetState($Radio_50, $GUI_SHOW)
Next
GUICtrlSetState($Group6, $GUI_SHOW)
For $Radio_60 In $Radio6
GUICtrlSetState($Radio_60, $GUI_SHOW)
Next
_Calc()
Case $Radio1 To $Radio1
$i1 = $nMsg - $Radio1
;GUICtrlSetData($Label01,$Rdo1_3L[$i1])
GUICtrlSetBkColor($Label01, $Color1_3[$i1])
GUICtrlSetBkColor($Label02, $Color1_3[$i2])
GUICtrlSetBkColor($Label03, $Color1_3[$i3])
GUICtrlSetBkColor($Label04, $Color4[$i4])
GUICtrlSetBkColor($Label05, $Color5[$i5])
GUICtrlSetBkColor($Label06, $Color6[$i6])
;MsgBox(0, '', $i1)
_calc()
Case $Radio2 To $Radio2
$i2 = $nMsg - $Radio2
GUICtrlSetBkColor($Label01, $Color1_3[$i1])
GUICtrlSetBkColor($Label02, $Color1_3[$i2])
GUICtrlSetBkColor($Label03, $Color1_3[$i3])
GUICtrlSetBkColor($Label04, $Color4[$i4])
GUICtrlSetBkColor($Label05, $Color5[$i5])
GUICtrlSetBkColor($Label06, $Color6[$i6])
;MsgBox(0, '', $i2)
_calc()
Case $Radio3 To $Radio3
$i3 = $nMsg - $Radio3
GUICtrlSetBkColor($Label01, $Color1_3[$i1])
GUICtrlSetBkColor($Label02, $Color1_3[$i2])
GUICtrlSetBkColor($Label03, $Color1_3[$i3])
GUICtrlSetBkColor($Label04, $Color4[$i4])
GUICtrlSetBkColor($Label05, $Color5[$i5])
GUICtrlSetBkColor($Label06, $Color6[$i6])
;MsgBox(0, '', $i3)
_calc()
Case $Radio4 To $Radio4
$i4 = $nMsg - $Radio4
GUICtrlSetBkColor($Label01, $Color1_3[$i1])
GUICtrlSetBkColor($Label02, $Color1_3[$i2])
GUICtrlSetBkColor($Label03, $Color1_3[$i3])
GUICtrlSetBkColor($Label04, $Color4[$i4])
GUICtrlSetBkColor($Label05, $Color5[$i5])
GUICtrlSetBkColor($Label06, $Color6[$i6])
;MsgBox(0, '', $i4)
_calc()
Case $Radio5 To $Radio5
$i5 = $nMsg - $Radio5
GUICtrlSetBkColor($Label01, $Color1_3[$i1])
GUICtrlSetBkColor($Label02, $Color1_3[$i2])
GUICtrlSetBkColor($Label03, $Color1_3[$i3])
GUICtrlSetBkColor($Label04, $Color4[$i4])
GUICtrlSetBkColor($Label05, $Color5[$i5])
GUICtrlSetBkColor($Label06, $Color6[$i6])
;MsgBox(0, '', $i5)
_calc()
Case $Radio6 To $Radio6
$i6 = $nMsg - $Radio6
GUICtrlSetBkColor($Label01, $Color1_3[$i1])
GUICtrlSetBkColor($Label02, $Color1_3[$i2])
GUICtrlSetBkColor($Label03, $Color1_3[$i3])
GUICtrlSetBkColor($Label04, $Color4[$i4])
GUICtrlSetBkColor($Label05, $Color5[$i5])
GUICtrlSetBkColor($Label06, $Color6[$i6])
;MsgBox(0, '', $i6)
_calc()
Case $ButtonR1
; $ComboR3=GUICtrlRead($Combo13)
Switch GUICtrlRead($Combo11)
Case 'Ω'
$R11 = GUICtrlRead($InputR11)
Case "KΩ"
$R11 = GUICtrlRead($InputR11) * 1000
Case "MΩ"
$R11 = GUICtrlRead($InputR11) * 1000000
EndSwitch
Switch GUICtrlRead($Combo12)
Case 'Ω'
$R12 = GUICtrlRead($InputR12)
Case 'KΩ'
$R12 = GUICtrlRead($InputR12) * 1000
Case 'MΩ'
$R12 = GUICtrlRead($InputR12) * 1000000
EndSwitch
Switch $R11 + $R12
Case $R11 + $R12 < 999
;$R13=$R11+$R12
GUICtrlSetData($InputR13, Round($R11 + $R12, 1) & ' Ω')
Case 1000 To 999999
GUICtrlSetData($InputR13, Round(($R11 + $R12) / 1000, 1) & " KΩ")
Case Else
GUICtrlSetData($InputR13, Round(($R11 + $R12) / 1000000, 1) & " MΩ")
EndSwitch
;GUICtrlSetData($InputR13,GUICtrlRead($InputR11)+GUICtrlRead($InputR12))
Case $ButtonR2
Switch GUICtrlRead($Combo21)
Case 'Ω'
$R21 = GUICtrlRead($InputR21)
Case "KΩ"
$R21 = GUICtrlRead($InputR21) * 1000
Case "MΩ"
$R21 = GUICtrlRead($InputR21) * 1000000
EndSwitch
Switch GUICtrlRead($Combo23)
Case 'Ω'
$R23 = GUICtrlRead($InputR23)
Case 'KΩ'
$R23 = GUICtrlRead($InputR23) * 1000
Case 'MΩ'
$R23 = GUICtrlRead($InputR23) * 1000000
EndSwitch
Switch $R23 - $R21
Case $R23 - $R21 < 999
;$R13=$R11+$R12
GUICtrlSetData($InputR22, Round($R23 - $R21, 1) & ' Ω')
Case 1000 To 999999
GUICtrlSetData($InputR22, Round(($R23 - $R21) / 1000, 1) & " KΩ")
Case Else
GUICtrlSetData($InputR22, Round(($R23 - $R21) / 1000000, 1) & " MΩ")
EndSwitch
Case $ButtonR3
Switch GUICtrlRead($Combo31)
Case 'Ω'
$R31 = GUICtrlRead($InputR31)
Case "KΩ"
$R31 = GUICtrlRead($InputR31) * 1000
Case "MΩ"
$R31 = GUICtrlRead($InputR31) * 1000000
EndSwitch
Switch GUICtrlRead($Combo32)
Case 'Ω'
$R32 = GUICtrlRead($InputR32)
Case 'KΩ'
$R32 = GUICtrlRead($InputR32) * 1000
Case 'MΩ'
$R32 = GUICtrlRead($InputR32) * 1000000
EndSwitch
Switch ($R31 * $R32) / ($R31 + $R32)
Case ($R31 * $R32) / ($R31 + $R32) < 999
;$R13=$R11+$R12
GUICtrlSetData($InputR33, Round(($R31 * $R32) / ($R31 + $R32), 1) & ' Ω')
Case 1000 To 999999
GUICtrlSetData($InputR33, Round((($R31 * $R32) / ($R31 + $R32)) / 1000, 1) & " KΩ")
Case Else
GUICtrlSetData($InputR33, Round((($R31 * $R32) / ($R31 + $R32)) / 1000000, 1) & " MΩ")
EndSwitch
Case $ButtonR4
Switch GUICtrlRead($Combo41)
Case 'Ω'
$R41 = GUICtrlRead($InputR41)
Case "KΩ"
$R41 = GUICtrlRead($InputR41) * 1000
Case "MΩ"
$R41 = GUICtrlRead($InputR41) * 1000000
EndSwitch
Switch GUICtrlRead($Combo43)
Case 'Ω'
$R43 = GUICtrlRead($InputR43)
Case 'KΩ'
$R43 = GUICtrlRead($InputR43) * 1000
Case 'MΩ'
$R43 = GUICtrlRead($InputR43) * 1000000
EndSwitch
Switch ($R41 * $R43) / ($R41 - $R43)
Case ($R41 * $R43) / ($R41 - $R43) < 999
;$R13=$R11+$R12
GUICtrlSetData($InputR42, Round(($R41 * $R43) / ($R41 - $R43), 1) & ' Ω')
Case 1000 To 999999
GUICtrlSetData($InputR42, Round(($R41 * $R43) / ($R41 - $R43) / 1000, 1) & " KΩ")
Case Else
GUICtrlSetData($InputR42, Round(($R41 * $R43) / ($R41 - $R43) / 1000000, 1) & " MΩ")
EndSwitch
EndSwitch
WEnd
Func _Calc()
If GUICtrlRead($Radio30) = $GUI_CHECKED Then
$Var1 = ' ' & $Rdo1_3L[$i1] & ' ' & $Rdo1_3L[$i2] & ' ×10^' & $Rdo4L[$i4] & " = "
$Var2 = ($Rdo1_3L[$i1] & $Rdo1_3L[$i2]) * 10 ^ $Rdo4L[$i4]
$Var3 = '(误差:' & '±20' & '%)'
;GUICtrlSetData($Label1, ' ' & $i1 & ' ' & $i2 & ' ×10^' & $i4 & " = " & ($i1 & $i2) * 10 ^ $i4 & " Ω" & ' (误差:' & '20%' & ')')
EndIf
If GUICtrlRead($Radio40) = $GUI_CHECKED Then
$Var1 = ' ' & $Rdo1_3L[$i1] & ' ' & $Rdo1_3L[$i2] & ' ×10^' & $Rdo4L[$i4] & " = "
$Var2 = ($Rdo1_3L[$i1] & $Rdo1_3L[$i2]) * 10 ^ $Rdo4L[$i4]
$Var3 = '(误差:' & $Rdo5L[$i5] & '%)'
;GUICtrlSetData($Label1, ' ' & $i1 & ' ' & $i2 & ' ×10^' & $i4 & " = " & ($i1 & $i2) * 10 ^ $i4 & " Ω" & ' (误差:' & $i5 & ')')
EndIf
If GUICtrlRead($Radio50) = $GUI_CHECKED Then
$Var1 = ' ' & $Rdo1_3L[$i1] & ' ' & $Rdo1_3L[$i2] & ' ' & $Rdo1_3L[$i3] & ' ×10^' & $Rdo4L[$i4] & " = "
$Var2 = ($Rdo1_3L[$i1] & $Rdo1_3L[$i2] & $Rdo1_3L[$i3]) * 10 ^ $Rdo4L[$i4]
$Var3 = '(误差:' & $Rdo5L[$i5] & '%)'
;GUICtrlSetData($Label1, ' ' & $i1 & ' ' & $i2 & ' ' & $i3 & ' ×10^' & $i4 & " = " & ($i1 & $i2 & $i3) * 10 ^ $i4 & " Ω" & ' (误差:' & $i5 & ')')
EndIf
If GUICtrlRead($Radio60) = $GUI_CHECKED Then
$Var1 = ' ' & $Rdo1_3L[$i1] & ' ' & $Rdo1_3L[$i2] & ' ' & $Rdo1_3L[$i3] & ' ×10^' & $Rdo4L[$i4] & " = "
$Var2 = ($Rdo1_3L[$i1] & $Rdo1_3L[$i2] & $Rdo1_3L[$i3]) * 10 ^ $Rdo4L[$i4]
$Var3 = '(误差:' & $Rdo5L[$i5] & '% 温度系数:' & $Rdo6L[$i6] & ')'
;GUICtrlSetData($Label1, ' ' & $i1 & ' ' & $i2 & ' ' & $i3 & ' ×10^' & $i4 & " = " & ($i1 & $i2 & $i3) * 10 ^ $i4 & " Ω" & ' (误差:±' & $i5 & ',温度:)' & $i6)
EndIf
Switch $Var2
Case $Var2 < 999
$Var2t = $Var2
Case 1000 To 999999
$Var2t = $Var2 / 1000 & "K"
Case Else
$Var2t = $Var2 / 1000000 & "M"
EndSwitch
GUICtrlSetData($Lab1, $Var1 & $Var2t & 'Ω')
GUICtrlSetData($Lab2, $Var3)
EndFunc ;==>_Calc
Combo下拉列表不知道怎么把每项颜色搞成不一样的,不然用Combo比Radio方便... 邪恶海盗 发表于 2023-9-11 14:49
根据各位的提示捣鼓的成品,目前发现是Group不能直接一次设置为显示/隐藏,另外Combox高度设置好像无效?
变 ...
还挺实用~ 这些颜色还真得每次去查。
就是有时候两端距离差不多,第1环得靠经验去判断,还有些颜色难以辨识,特别是烧坏的 afan 发表于 2023-9-11 15:47
还挺实用~ 这些颜色还真得每次去查。
就是有时候两端距离差不多,第1环得靠经验去判断,还有些颜色难以 ...
好像这屎山代码还有很大的优化空间...{:1_617:}
页:
[1]
2