Thanks Semen, your solution is perfect.
Scott
------------------
Announcement
Collapse
No announcement yet.
DDT -- Option button group
Collapse
X
-
Scott--
Try this (it's your code after small correction)
Code:#Compile Exe #Register None #Dim All #Include "WIN32API.INC" CallBack Function MAIN_CB() As Long Local i As Long, Res As Long, Txt As String, TxtC As String Select Case CbMsg Case %WM_COMMAND Select Case CbCtl Case 201 For i = 101 To 106 Control Get Check CbHndl, i To Res Select Case i Case 101: Txt$ = "Group 1 Radio 1 Check is :" & Str$(Res) Case 102: Txt$ = "Group 1 Radio 2 Check is :" & Str$(Res) Case 103: Txt$ = "Group 1 Radio 3 Check is :" & Str$(Res) Case 104: Txt$ = "Group 2 Radio 1 Check is :" & Str$(Res) Case 105: Txt$ = "Group 2 Radio 2 Check is :" & Str$(Res) Case 106: Txt$ = "Group 2 Radio 3 Check is :" & Str$(Res) End Select TxtC$ = TxtC$ + Txt$ + $CRLF Next MsgBox TxtC$ End Select End Select End Function Function PbMain() As Long Local hDlg As Long Dialog New 0,"Option Group Test",,,442,205, %WS_SYSMENU To hDlg Control Add Frame,hDlg, -1,"Group Box 1",31,74,261,28 Control Add TextBox,hDlg, -1,"Text1",53,83,40,14 Control Add Option,hDlg,101, "Do Opt 1 ", 100, 85, 49, 10, %WS_GROUP Or %WS_TABSTOP Control Add Option,hDlg,102, "Do Opt 2", 155, 85, 63, 10 Control Add Option,hDlg,103, "Do Nothing", 227, 85, 52, 10 Control Add Frame,hDlg, -1,"Group Box 2",32,114,261,28, %WS_TABSTOP,, Control Add TextBox,hDlg, -1,"Text2",54,123,40,14, Control Add Option,hDlg, 104, "Do Opt 1", 101, 125, 49, 10, %WS_GROUP Or %WS_TABSTOP Control Add Option,hDlg,105, "Do Opt 2", 156, 125, 63, 10 Control Add Option,hDlg,106, "Do Nothing", 228, 125, 52, 10 Control Add Button,hDlg, 201,"T&est",240,165,99,17 Control Set Check hDlg, 103, 1 Control Set Check hDlg, 106, 1 Dialog Show Modal hDlg ,Call MAIN_CB End Function
Leave a comment:
-
DDT -- Option button group
Hi,
I am trying TO figure out a way TO test option button states IF THEY HAVEN'T BEEN CLICKED.
The CONTROL GET CHECK Statement only returns a value if the button was clicked. I am hoping to
emulate the option.Value property IN VB. I set the the initial values TO DO Nothing when the DIALOG first
displays AND would like TO test their STATE when a "DO THE FUNCTION COMMAND BUTTON" (missing FROM this example) is pushed.
Is there a way to do this?
Is there a more proper way TO handle option button events?
Thanks
Scott
Code:#COMPILE EXE #REGISTER NONE #INCLUDE "WIN32API.INC" #INCLUDE "COMMCTRL.INC" #INCLUDE "COMDLG32.INC" 'globals ============================================== GLOBAL gInstance AS LONG GLOBAL ghDlg AS LONG ' callbacks =========================================== CALLBACK FUNCTION GETOPTIONS_CB() LOCAL cID AS LONG LOCAL ctlMSG AS LONG LOCAL Res AS LONG LOCAL Txt$ cID = CBCTL ctlMSG = CBCTLMSG CONTROL SEND CBHNDL, cID, %BM_CLICK , 0, 0 TO Res 'Force the button click 'CONTROL SEND CBHNDL, cID, %BM_GETCHECK , 0, 0 TO Res 'This does not show state unless %BM_CLICK first CONTROL GET CHECK CBHNDL, cID TO Res 'nor does this call... IF cID AND Res THEN SELECT CASE cID CASE 105: Txt$ = "Group 1 Radio 1 Check is :" & STR$(Res) CASE 106: Txt$ = "Group 1 Radio 2 Check is :" & STR$(Res) CASE 107: Txt$ = "Group 1 Radio 3 Check is :" & STR$(Res) CASE 110: Txt$ = "Group 2 Radio 1 Check is :" & STR$(Res) CASE 111: Txt$ = "Group 2 Radio 2 Check is :" & STR$(Res) CASE 112: Txt$ = "Group 2 Radio 3 Check is :" & STR$(Res) CASE ELSE: Txt$ = "No Button Selected" END SELECT END IF CONTROL SET TEXT ghDlg, 100, Txt$ END FUNCTION CALLBACK FUNCTION cmdExit_CB() DIALOG END CBHNDL, 0 END FUNCTION CALLBACK FUNCTION MAIN_CB() AS LONG END FUNCTION FUNCTION PBMAIN() AS LONG LOCAL hDlg AS LONG LOCAL Result AS LONG LOCAL hIcon AS LONG InitCommonControls 'Create Dialog DIALOG NEW 0,"Option Group Test",,,442,205, %WS_MINIMIZEBOX OR %WS_POPUP OR %WS_CAPTION OR %WS_SYSMENU, TO hDlg CONTROL ADD LABEL,hDlg, 100,"LABEL1",30,10,260,13,%SS_SUNKEN,, 'Create Group 1 ==== CONTROL ADD FRAME,hDlg, 103,"Group Box 1",31,74,261,28, %WS_TABSTOP,, CONTROL ADD TEXTBOX,hDlg,104,"Text1",53,83,40,14,, CONTROL ADD OPTION,hDlg,105, "Do Opt 1 ", 100, 85, 49, 10 , %WS_GROUP OR %WS_TABSTOP OR %BS_NOTIFY , CALL GETOPTIONS_CB CONTROL ADD OPTION,hDlg,106, "Do Opt 2", 155, 85, 63, 10 ,%WS_TABSTOP OR %BS_NOTIFY , CALL GETOPTIONS_CB CONTROL ADD OPTION,hDlg,107, "Do Nothing", 227, 85, 52, 10 ,%WS_TABSTOP OR %BS_NOTIFY, CALL GETOPTIONS_CB 'Create Group 2 ==== CONTROL ADD FRAME,hDlg, 108,"Group Box 2",32,114,261,28, %WS_TABSTOP,, CONTROL ADD TEXTBOX,hDlg,109,"Text2",54,123,40,14, CONTROL ADD OPTION,hDlg,110, "Do Opt 1", 101, 125, 49, 10 , %WS_GROUP OR %WS_TABSTOP, CALL GETOPTIONS_CB CONTROL ADD OPTION,hDlg,111, "Do Opt 2", 156, 125, 63, 10 ,, CALL GETOPTIONS_CB CONTROL ADD OPTION,hDlg,112, "Do Nothing", 228, 125, 52, 10 ,, CALL GETOPTIONS_CB 'Add Command Button CONTROL ADD BUTTON,hDlg,113,"E&xit",320,165,99,17,,,CALL cmdExit_CB '=======Set all OPTION BUTTON defaults to NO_OP CONTROL SET CHECK hDlg, 107, 1& CONTROL SET CHECK hDlg, 112, 1& ghDlg = hDlg DIALOG SHOW MODAL hDlg ,CALL MAIN_CB TO result END FUNCTION
Tags: None
Leave a comment: