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
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
Comment