showshow 发表于 2012-5-23 13:10:21

[已解决]radio或checkbox如何成对建立?

本帖最后由 showshow 于 2012-5-25 08:17 编辑

可能问题没描述清楚,

想在GUI上创建多组radio按钮,组与组之间的选取不干扰

就如radio1,radio2成一组形成单选(选中radio1就取消选中radio2)
    radio3,radio4成一组形成单选(选中radio3就取消选中radio4)
    .....
      .....
以次类推,最重要的是组与组之间的选取不干扰,不知可否实现?

或者checkbox也可以~

=======感谢楼下3位大虾==========

user3000 发表于 2012-5-23 14:50:36

回复 1# showshow


    半天没人回应楼主, 那么我应一声:
请查阅 GuiCtrlCreatGroup 函数

楼下继续来人接力?

netegg 发表于 2012-5-23 14:58:16

#include <GUIConstantsEx.au3>

Example()

Func Example()
        GUICreate("My GUI group") ; will create a dialog box that when displayed is centered

        Local $x = 10, $y = 10, $w = 50, $h = 16
        For $i = 1 To 6
                GUICtrlCreateRadio(2 * $i, $i*$x*5, $y + 2, $w, $h)
                GUICtrlCreateRadio(2 * $i + 1, $i*$x*5, $y + 22, $w, $h)
                GUICtrlCreateGroup('', -99, -99, 1, 1)
        Next
        GUISetState() ; will display an empty dialog box

        ; Run the GUI until the dialog is closed
        While 1
                Local $msg = GUIGetMsg()

                If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        WEnd
EndFunc   ;==>Example

502762378 发表于 2012-5-23 20:07:24


#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 232, 186, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 24, 16, 89, 25)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 24, 48, 89, 25)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 24, 88, 89, 25)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 24, 128, 89, 25)
GUISetOnEvent(-3, "gui")
GUICtrlSetOnEvent($Checkbox1, "gui")
GUICtrlSetOnEvent($Checkbox2, "gui")
GUICtrlSetOnEvent($Checkbox3, "gui")
GUICtrlSetOnEvent($Checkbox4, "gui")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1       
        Sleep(100)
WEnd

Func gui()
    Switch @GUI_CtrlId
      Case -3
            Exit
      Case $Checkbox1 To $Checkbox2
            DllCall("user32.dll","Int","CheckRadioButton","hwnd",$Form1,"Int",$Checkbox1,"Int",$Checkbox2,"Int",@GUI_CtrlId)
      Case $Checkbox3 To $Checkbox4
         DllCall("user32.dll","Int","CheckRadioButton","hwnd",$Form1,"Int",$Checkbox3,"Int",$Checkbox4,"Int",@GUI_CtrlId)
    EndSwitch
EndFunc


plutosherry 发表于 2013-12-4 15:15:24

好东西,正好用了

menfan1 发表于 2013-12-4 16:22:43

这个方法不错哈。。
页: [1]
查看完整版本: [已解决]radio或checkbox如何成对建立?