         title   xxxx - Dialog as Main Window

         .586
         .model flat, stdcall
         option casemap :none   ; Case sensitive

            include  \AsmEditDir\include\windows.inc
            include  \HutchDir\include\user32.inc
            include  \HutchDir\include\kernel32.inc
            include  \HutchDir\include\gdi32.inc

include  \AsmEditDir\include\DSPMACRO.asm

         includelib  \HutchDir\lib\user32.lib
         includelib  \HutchDir\lib\kernel32.lib
         includelib  \HutchDir\lib\gdi32.lib

WndProc        PROTO :DWORD, :DWORD, :DWORD, :DWORD

.const
IDM_EXIT       equ 2

.data
hInst          dd  0

DlgName        db  'TESTDLG',0
szError        db  'You must enter data first!',0
szBuff         db  50 dup(?) 
MenuName       db  'MainMenu',0

.code

;________________________________________________________________________________
start:
      INVOKE     GetModuleHandle, NULL
         mov     hInst, eax
      
;---------- [Call the dialog box stored in resource file] ----------
      INVOKE     DialogBoxParam, hInst, addr DlgName, 0, addr WndProc, 0
      INVOKE     ExitProcess, eax

;________________________________________________________________________________
WndProc proc   hWnd:DWORD, uMsg, wParam, lParam
LOCAL    hIcon:DWORD

      .if uMsg == WM_INITDIALOG
         INVOKE     LoadIcon, hInst, 200
            mov     hIcon, eax

         INVOKE     SendMessage, hWnd, WM_SETICON, 1, hIcon
            xor     eax, eax
            ret

      .elseif uMsg == WM_COMMAND
         .if wParam == 102
            INVOKE     GetDlgItemText, hWnd, 100, addr szBuff, sizeof szBuff
            INVOKE     lstrlen, addr szBuff
            .if !eax
               INVOKE     MessageBox, NULL, addr szError, addr DlgName, MB_OK
            .endif
            INVOKE     SetDlgItemText, hWnd, 101, addr szBuff

         .elseif wParam == IDOK

         .elseif wParam == IDM_EXIT || wParam == IDCANCEL
               jmp     GetOut
         .endif

      .elseif uMsg == WM_CLOSE

GetOut:
         INVOKE     EndDialog, hWnd, 0
            xor     eax, eax
            ret
      .endif

         xor     eax, eax
         ret

WndProc endp

end start
