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

$ filename "NestedModal.exe"
'uses rtl32
'uses rtl64

'%review

uses dialogs


function NestedDialogProc( sys hDlg, uint uMsg, sys wParam, lParam) as sys callback
  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( sys hDlg, uint uMsg, sys wParam, lParam ) as sys callback

  select case uMsg

    case WM_COMMAND

      select case loword(wParam)
        case 100          
          Dialog( 0, 0, 120, 90, "Modal Nested Dialog",
                       WS_OVERLAPPED or WS_SYSMENU or DS_CENTER )
          DefPushButton( "Close", IDCANCEL, -1, 60, 40, 12  )
          CreateModalDialog( hDlg, @NestedDialogProc, 0 )

        case IDCANCEL
          EndDialog( hDlg, null )

      end select

    case WM_CLOSE
      EndDialog( hDlg, null )

  end select

  return 0
end function

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

Dialog( 0, 0, 150, 100, "Main Dialog",
             WS_OVERLAPPED or WS_SYSMENU or DS_CENTER )

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

CreateModalDialog( 0, @MainDialogProc, 0 )

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