home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Hutch / DOWNLOAD / Dbldr.exe / RADIOTST / RADIOTST.BAS < prev    next >
Encoding:
BASIC Source File  |  1999-08-11  |  3.6 KB  |  128 lines

  1. '######################## Dialog Builder Template #########################
  2.  
  3.     #INCLUDE "radiotst.inc"
  4.  
  5. '##########################################################################
  6.  
  7. FUNCTION WinMain(ByVal Instance      as LONG, _
  8.                  ByVal hPrevInstance as LONG, _
  9.                  lpszCmdLine         as ASCIIZ PTR, _
  10.                  ByVal nCmdShow      as LONG) AS LONG
  11.  
  12.     hInstance = Instance
  13.  
  14.     DialogBox hInstance,ByVal 100,0,CodePtr(DlgProc1)
  15.  
  16.     FUNCTION = 0
  17.  
  18. END FUNCTION
  19.  
  20. '##########################################################################
  21.  
  22. FUNCTION DlgProc1(ByVal hDlg   as LONG, _
  23.                   ByVal Msg    as LONG, _
  24.                   ByVal wParam as LONG, _
  25.                   ByVal lParam as LONG) EXPORT as LONG
  26.  
  27.   LOCAL Caption as ASCIIZ * 20  ' make larger if needed
  28.  
  29.   Select Case Msg
  30.  
  31.       Case %WM_INITDIALOG
  32.  
  33.         hWnd = hDlg     ' hWnd is global handle
  34.  
  35.         SendMessage hDlg,%WM_SETICON,1, _
  36.                     LoadIcon(hInstance,ByVal 1)
  37.  
  38.         Caption="Radio Button Test"
  39.           SendMessage hDlg,%WM_SETTEXT,0,VarPtr(Caption)
  40.  
  41.         ' ----------------------------
  42.         ' Get handles for dialog items
  43.         ' ----------------------------
  44.           h1GroupBox1    = GetDlgItem(hDlg,101)
  45.           h1RadioButton1 = GetDlgItem(hDlg,102)
  46.           h1RadioButton2 = GetDlgItem(hDlg,103)
  47.           h1RadioButton3 = GetDlgItem(hDlg,104)
  48.           h1RadioButton4 = GetDlgItem(hDlg,105)
  49.           h1Button1      = GetDlgItem(hDlg,106)
  50.           h1Button2      = GetDlgItem(hDlg,107)
  51.  
  52.           SetCheck h1RadioButton1,1
  53.  
  54.       Case %WM_COMMAND
  55.         Select Case wParam
  56.           Case 102    ' "Radio 1"
  57.             SetWindowText hWnd,"Selected Radio 1"
  58.  
  59.           Case 103    ' "Radio 2"
  60.             SetWindowText hWnd,"Selected Radio 2"
  61.  
  62.           Case 104    ' "Radio 3"
  63.             SetWindowText hWnd,"Selected Radio 3"
  64.  
  65.           Case 105    ' "Radio 4"
  66.             SetWindowText hWnd,"Selected Radio 4"
  67.  
  68.           Case 106    ' "Reset All"
  69.             SetCheck h1RadioButton1,1
  70.             SetCheck h1RadioButton2,0
  71.             SetCheck h1RadioButton3,0
  72.             SetCheck h1RadioButton4,0
  73.             SetWindowText hWnd,"Radio Button Test"
  74.  
  75.           Case 107    ' "Get Selection"
  76.             If GetCheck(h1RadioButton1) = 1 Then
  77.               TxtMsg$ = "Radio 1 is selected"
  78.             ElseIf GetCheck(h1RadioButton2) = 1 Then
  79.               TxtMsg$ = "Radio 2 is selected"
  80.             ElseIf GetCheck(h1RadioButton3) = 1 Then
  81.               TxtMsg$ = "Radio 3 is selected"
  82.             ElseIf GetCheck(h1RadioButton4) = 1 Then
  83.               TxtMsg$ = "Radio 4 is selected"
  84.             End If
  85.  
  86.           MessageBox hWnd,ByCopy TxtMsg$, _
  87.                      "Check Result",%MB_ICONINFORMATION
  88.  
  89.         End Select
  90.  
  91.       Case %WM_CLOSE
  92.          EndDialog hDlg, 0
  93.  
  94.   END Select
  95.  
  96. END FUNCTION
  97.  
  98. '##########################################################################
  99.  
  100. Sub SetCheck(hCtl as LONG,CheckState as LONG)
  101.  
  102.     Select Case CheckState
  103.       Case 0
  104.         CheckState = %BST_UNCHECKED
  105.       Case 1
  106.         CheckState = %BST_CHECKED
  107.       Case 2
  108.         CheckState = %BST_INDETERMINATE
  109.     End Select
  110.  
  111.     SendMessage hCtl,%BM_SETCHECK,CheckState,0
  112.  
  113. END SUB
  114.  
  115. '##########################################################################
  116.  
  117. FUNCTION GetCheck(hCtl as LONG) as LONG
  118.  
  119.   ' ------------------------------
  120.   ' returns 1 if checked, 0 if not
  121.   ' ------------------------------
  122.     FUNCTION = SendMessage(hCtl,%BM_GETCHECK,0,0)
  123.  
  124. END FUNCTION
  125.  
  126. '##########################################################################
  127.  
  128.