
'====================================================================
'' Nested modal dialog demo, modal dialog as main.
'====================================================================

#include "dialogs.bas"

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

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

    Case WM_COMMAND

      If loword(wParam) = IDCANCEL Then
        EndDialog( hDlg, null )
      End If

    Case WM_CLOSE

      EndDialog( hDlg, null )

  End Select

  Return 0

End Function

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

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

  Select Case uMsg

    Case WM_COMMAND

      Select Case loword(wParam)

        Case 100

          Dim As LPDLGTEMPLATE lpdt
          Dialog( 1, 0, 0, 120, 90, "Nested Dialog", lpdt, _
                  WS_OVERLAPPED Or WS_SYSMENU Or DS_CENTER )
          DefPushButton( IDCANCEL, -1, 60, 40, 12, "Close" )
          CreateModalDialog( hDlg, @NestedDialogProc, 0, lpdt )

        Case IDCANCEL

          EndDialog( hDlg, null )

      End Select

    Case WM_CLOSE

      EndDialog( hDlg, null )

  End Select

  Return 0

End Function

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

Dim As LPDLGTEMPLATE lpdt

Dialog( 2, 0, 0, 150, 100, "Main Dialog", lpdt, _
        WS_OVERLAPPED Or WS_SYSMENU Or DS_CENTER )

DefPushButton( 100, 30, 70, 40, 12, "Go" )
PushButton( IDCANCEL, 80, 70, 40, 12, "Close" )

CreateModalDialog( 0, @MainDialogProc, 0, lpdt )

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