
; template for program using standard Win32 headers

format PE GUI 4.0
stack $1000
entry start

;include '%fasminc%\win32a.inc'
include 'macros.inc'

include '%finc%\win32\win32a.inc'
include 'strings.inc'

section '.data' data readable writeable

  _title db 'xedit',0
  _class db 'SKINGSTON',0

  mainhwnd dd ?
  hinstance dd ?
  message string "hello"

  msg MSG
  wc WNDCLASS

err db "not equal to 5",0
bye db "bye",0

section '.code' code readable executable

proc freshProblemFix,.this,.that
begin
     return
endp

; Start of program
  start:
       ; call    MainProc
        ret

        invoke  GetModuleHandle,0
        mov     [hinstance],eax
        invoke  LoadIcon,0,IDI_APPLICATION
        mov     [wc.hIcon],eax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [wc.hCursor],eax
        mov     [wc.style],0
        mov     [wc.lpfnWndProc],aWndProc
        mov     [wc.cbClsExtra],0
        mov     [wc.cbWndExtra],0
        mov     eax,[hinstance]
        mov     [wc.hInstance],eax
        mov     [wc.hbrBackground],COLOR_BTNFACE+1
        mov     [wc.lpszMenuName],0
        mov     [wc.lpszClassName],_class
        invoke  RegisterClass,wc

        invoke  CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,160,160,700,500,NULL,NULL,[hinstance],NULL
        mov     [mainhwnd],eax

        ;stdcall string.display,[message.pointer]
        objcall string.display,message


  msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        or      eax,eax
        jz      end_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop

  end_loop:
        invoke  ExitProcess,[msg.wParam]

; Main Window Proc
proc aWndProc, .hwnd, .wmsg, .wparam, .lparam
begin
        push    ebx esi edi
        cmp     [.wmsg],WM_DESTROY

        je      .wmdestroy
  defwndproc:
        invoke  DefWindowProc,[.hwnd],[.wmsg],[.wparam],[.lparam]
        jmp     .finish
  .wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax
  .finish:
        pop     edi esi ebx
        return
endp

; Include Import Table
section '.idata' import data readable writeable
include 'imports.inc'
