home *** CD-ROM | disk | FTP | other *** search
- '######################## Dialog Builder Template #########################
-
- #INCLUDE "radiotst.inc"
-
- '##########################################################################
-
- FUNCTION WinMain(ByVal Instance as LONG, _
- ByVal hPrevInstance as LONG, _
- lpszCmdLine as ASCIIZ PTR, _
- ByVal nCmdShow as LONG) AS LONG
-
- hInstance = Instance
-
- DialogBox hInstance,ByVal 100,0,CodePtr(DlgProc1)
-
- FUNCTION = 0
-
- END FUNCTION
-
- '##########################################################################
-
- FUNCTION DlgProc1(ByVal hDlg as LONG, _
- ByVal Msg as LONG, _
- ByVal wParam as LONG, _
- ByVal lParam as LONG) EXPORT as LONG
-
- LOCAL Caption as ASCIIZ * 20 ' make larger if needed
-
- Select Case Msg
-
- Case %WM_INITDIALOG
-
- hWnd = hDlg ' hWnd is global handle
-
- SendMessage hDlg,%WM_SETICON,1, _
- LoadIcon(hInstance,ByVal 1)
-
- Caption="Radio Button Test"
- SendMessage hDlg,%WM_SETTEXT,0,VarPtr(Caption)
-
- ' ----------------------------
- ' Get handles for dialog items
- ' ----------------------------
- h1GroupBox1 = GetDlgItem(hDlg,101)
- h1RadioButton1 = GetDlgItem(hDlg,102)
- h1RadioButton2 = GetDlgItem(hDlg,103)
- h1RadioButton3 = GetDlgItem(hDlg,104)
- h1RadioButton4 = GetDlgItem(hDlg,105)
- h1Button1 = GetDlgItem(hDlg,106)
- h1Button2 = GetDlgItem(hDlg,107)
-
- SetCheck h1RadioButton1,1
-
- Case %WM_COMMAND
- Select Case wParam
- Case 102 ' "Radio 1"
- SetWindowText hWnd,"Selected Radio 1"
-
- Case 103 ' "Radio 2"
- SetWindowText hWnd,"Selected Radio 2"
-
- Case 104 ' "Radio 3"
- SetWindowText hWnd,"Selected Radio 3"
-
- Case 105 ' "Radio 4"
- SetWindowText hWnd,"Selected Radio 4"
-
- Case 106 ' "Reset All"
- SetCheck h1RadioButton1,1
- SetCheck h1RadioButton2,0
- SetCheck h1RadioButton3,0
- SetCheck h1RadioButton4,0
- SetWindowText hWnd,"Radio Button Test"
-
- Case 107 ' "Get Selection"
- If GetCheck(h1RadioButton1) = 1 Then
- TxtMsg$ = "Radio 1 is selected"
- ElseIf GetCheck(h1RadioButton2) = 1 Then
- TxtMsg$ = "Radio 2 is selected"
- ElseIf GetCheck(h1RadioButton3) = 1 Then
- TxtMsg$ = "Radio 3 is selected"
- ElseIf GetCheck(h1RadioButton4) = 1 Then
- TxtMsg$ = "Radio 4 is selected"
- End If
-
- MessageBox hWnd,ByCopy TxtMsg$, _
- "Check Result",%MB_ICONINFORMATION
-
- End Select
-
- Case %WM_CLOSE
- EndDialog hDlg, 0
-
- END Select
-
- END FUNCTION
-
- '##########################################################################
-
- Sub SetCheck(hCtl as LONG,CheckState as LONG)
-
- Select Case CheckState
- Case 0
- CheckState = %BST_UNCHECKED
- Case 1
- CheckState = %BST_CHECKED
- Case 2
- CheckState = %BST_INDETERMINATE
- End Select
-
- SendMessage hCtl,%BM_SETCHECK,CheckState,0
-
- END SUB
-
- '##########################################################################
-
- FUNCTION GetCheck(hCtl as LONG) as LONG
-
- ' ------------------------------
- ' returns 1 if checked, 0 if not
- ' ------------------------------
- FUNCTION = SendMessage(hCtl,%BM_GETCHECK,0,0)
-
- END FUNCTION
-
- '##########################################################################
-
-