
'====================================================================
'' Control grouping demo, modal dialog as main.
'====================================================================

#include "dialogs.bas"

'====================================================================

Function DialogProc( Byval hDlg As  HWND, _
                     Byval uMsg As UINT, _
                     Byval wParam As WPARAM, _
                     Byval lParam As LPARAM ) As Integer

  Select Case uMsg

    Case WM_COMMAND

      Dim As Integer ctrl, res
      Dim As String state

      If hiword(wParam) = BN_CLICKED Then

        If loword(wParam) = 105 Then

          state = ""
          For ctrl = 101 To 104
            res = IsDlgButtonChecked( hDlg, ctrl )
            If res = BST_CHECKED Then
              state = state & "1"
            Else
              state = state & "0"
            End If
          Next
          MessageBox( hDlg, state, "State", 0 )

        Elseif loword(wParam) = IDCANCEL Then

          EndDialog( hDlg, null )

        End If

      End If

    Case WM_CLOSE

        EndDialog( hDlg, null )

  End Select

  Return 0

End Function

'====================================================================

Dim As LPDLGTEMPLATE lpdt

Dialog( 8, 0, 0, 150, 100, "Group Demo", lpdt, _
        WS_OVERLAPPED Or WS_SYSMENU Or DS_CENTER )

GroupBox( 100, 10, 5, 80, 35, "GroupBox1" )

'' By default all of the controls in a dialog form a single group.
'' The WS_GROUP style specifies the first control in a group, with
'' the group extending up to, but not including, the next control
'' in the tab order that has the WS_GROUP style. Unlike the VB
'' Frame control, a GroupBox control provides visual grouping
'' only.
''
AutoRadioButton( 101, 15, 15, 70, 10, "AutoRadioButton&1", _
                 WS_TABSTOP Or WS_GROUP )

AutoRadioButton( 102, 15, 25, 70, 10, "AutoRadioButton&2" )

GroupBox( 110, 10, 45, 80, 35, "GroupBox2" )

AutoRadioButton( 103, 15, 55, 70, 10, "AutoRadioButton&3", _
                 WS_TABSTOP Or WS_GROUP )

AutoRadioButton( 104, 15, 65, 70, 10, "AutoRadioButton&4" )

DefPushButton( 105, 100, 10, 38, 12, "&Get State", _
               WS_TABSTOP Or WS_GROUP )

PushButton( IDCANCEL, 100, 28, 38, 12, "Cancel", WS_TABSTOP )

CreateModalDialog( 0, @DialogProc, 0, lpdt )

'====================================================================
 