
'====================================================================
'' Button grid 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

  Static state(100 To 200) As Integer

  Select Case uMsg

    Case WM_COMMAND

      If hiword(wParam) = BN_CLICKED Then

        If state(loword(wParam)) Then
          SetDlgItemText( hDlg, loword(wParam), "" )
          state(loword(wParam)) = 0
        Else
          SetDlgItemText( hDlg, loword(wParam), "X" )
          state(loword(wParam)) = 1
        End If

      End If

    Case WM_CLOSE

      EndDialog( hDlg, null )

  End Select

  Return 0

End Function

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

Dim As LPDLGTEMPLATE lpdt

Dim As Short id, r, c

Dialog( 100, 0, 0, 122, 130, "Button Grid Demo", lpdt, _
        WS_OVERLAPPED Or WS_SYSMENU Or DS_CENTER )

id = 100
For c = 10 To 100 Step 10
  For r = 10 To 100 Step 10
    PushButton( id, r, c, 9, 9, "", WS_TABSTOP )
    id += 1
  Next
next

CreateModalDialog( 0, @DialogProc, 0, lpdt )

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