         title   xxxx - Normal Window with (.rc) N/E

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

            include  \AsmEditDir\include\windows.inc
            include  \HutchDir\include\user32.inc
            include  \HutchDir\include\GDI32.inc
            include  \HutchDir\include\kernel32.inc
            include  \HutchDir\include\comdlg32.inc
            include  \HutchDir\include\COMCTL32.inc

   include  \AsmEditDir\include\DSPMACRO.asm

         includelib  \HutchDir\lib\user32.lib
         includelib  \HutchDir\lib\GDI32.lib
         includelib  \HutchDir\lib\kernel32.lib
         includelib  \HutchDir\lib\comdlg32.lib
         includelib  \HutchDir\lib\COMCTL32.lib

WinMain        PROTO  :DWORD, :DWORD, :DWORD, :DWORD
EndIt          PROTO  :DWORD, :DWORD, :DWORD, :DWORD

.const
EditID         equ 1
IDM_EXIT       equ 2
IDM_QUIT       equ 3

.data
ClassName      db  'xxxx',0
AppName        db  'xxxx - Normal Window with (.rc) N/E 07',0
ButtClass      db  'BUTTON',0
MenuName       db  'MainMenu',0
dlgname        db  'EndIt',0
szMsg          db  'Get The Exit Dialog',0

.data?
hInst          dd  ?
CommandLine    dd  ?
hREdDll        dd  ?
MainExit       dd  ?
hWnd           dd  ? 
hButt          dd  ?

.code

;________________________________________________________________________________
start:
      INVOKE     GetModuleHandle, NULL
         mov     hInst, eax
      INVOKE     GetCommandLine
         mov     CommandLine, eax

        call     InitCommonControls          ; Initialize the common ctrl lib

      INVOKE     WinMain, hInst ,NULL, CommandLine, SW_SHOWDEFAULT
         mov     MainExit, eax

NoGo:
      INVOKE     ExitProcess, MainExit

;________________________________________________________________________________
WinMain proc  uses ebx  hinst:DWORD, hPrevInst, CmdLine, CmdShow
LOCAL    wc:WNDCLASSEX
LOCAL    msg:MSG

         mov     wc.cbSize, sizeof WNDCLASSEX
         mov     wc.style, CS_HREDRAW or CS_VREDRAW
         mov     wc.lpfnWndProc, offset WndProc
         mov     wc.cbClsExtra, NULL
         mov     wc.cbWndExtra, NULL
        push     hInst
         pop     wc.hInstance
         mov     wc.hbrBackground, COLOR_BTNFACE+1 ;COLOR_WINDOW+1
         mov     wc.lpszMenuName, offset MenuName
         mov     wc.lpszClassName, offset ClassName
      INVOKE     LoadIcon, NULL, IDI_APPLICATION
         mov     wc.hIcon, eax
         mov     wc.hIconSm, eax
      INVOKE     LoadCursor, NULL, IDC_ARROW
         mov     wc.hCursor, eax
      INVOKE     RegisterClassEx, addr wc

;---------- [Center the window] ----------
      INVOKE     GetSystemMetrics, SM_CXSCREEN
         sub     eax, 350
         shr     eax, 1
        push     eax
      INVOKE     GetSystemMetrics, SM_CYSCREEN
         sub     eax, 250
         shr     eax, 1
         pop     ebx

      INVOKE     CreateWindowEx, 0, addr ClassName,\
                 addr AppName, WS_OVERLAPPEDWINDOW,\
                 ebx, eax, 350, 250, NULL, NULL, hInst, NULL
         mov     hWnd, eax

      INVOKE     ShowWindow, hWnd, SW_SHOWNORMAL
      INVOKE     UpdateWindow, hWnd
      .while TRUE
         INVOKE     GetMessage, addr msg, NULL, 0, 0
            .BREAK .IF (!eax)
            INVOKE     TranslateMessage, addr msg
            INVOKE     DispatchMessage, addr msg
      .endw
         mov     eax, msg.wParam
         ret
WinMain endp

;________________________________________________________________________________
WndProc proc  uses edx  hwnd:DWORD, wMsg, wParam, lParam

      .if wMsg == WM_CREATE
         INVOKE     CreateWindowEx, NULL, addr ButtClass, addr szMsg,
                    WS_CHILD or WS_VISIBLE or BS_PUSHBUTTON,
                    106, 75, 135, 30, hwnd, 84, hInst, 0
            mov     hButt, eax

      .elseif wMsg == WM_DESTROY
        INVOKE     PostQuitMessage, NULL

      .elseif wMsg == WM_COMMAND
            mov     eax, wParam
           cwde                         ; Only low word contains command

         .if eax == IDM_QUIT
            INVOKE     DialogBoxParam, hInst, addr dlgname, 0, addr EndIt, 0

         .elseif eax == 84
            INVOKE     DialogBoxParam, hInst, addr dlgname, 0, addr EndIt, 0

         .elseif eax == IDM_EXIT
            INVOKE     DestroyWindow, hwnd
         .endif

      .else

DefWin:
         INVOKE     DefWindowProc, hwnd, wMsg, wParam, lParam
            ret
      .endif

         xor    eax, eax
         ret
WndProc endp

;________________________________________________________________________________
EndIt proc  hdlg:DWORD, uMsg, wParam, lParam

      .if uMsg == WM_COMMAND
         .if wParam == IDCANCEL
               jmp     GetOut

         .elseif wParam == 401
            INVOKE     SendMessage, hWnd, WM_COMMAND, IDM_EXIT, 0
         .endif

      .elseif uMsg == WM_CLOSE

GetOut:
         INVOKE     EndDialog, hdlg, wParam ; End the dialog with wparam as return
            mov     eax, TRUE               ; Return
            jmp     EndItRet                ; with TRUE

      .endif

Ret0:
         xor     eax, eax

EndItRet:
         ret
EndIt endp

end start
;INVOKE     MessageBox, NULL, addr szText, addr AppName, MB_OK
