; Paint.asm Iczelion's example FASMW version

format PE GUI 4.0
entry start


include '%include%\win32a.inc'

;--------------------------------------------------------------------------------------------
section '.data' data readable writeable

_title db 'Our First Window',0
_class db 'SimpleWinClass',0
_OurText db 'Win32 assembly is great and easy!',0
mainhwnd dd ?
hinstance dd ?
msg MSG
wc WNDCLASS
_hdc dd 0
_rect RECT
_ps PAINTSTRUCT

;---------------------------------------------------------------------------------------------
section '.code' code readable executable

start:

invoke GetModuleHandle,0
mov ,eax
invoke LoadIcon,0,IDI_APPLICATION
mov ,eax
invoke LoadCursor,0,IDC_ARROW
mov ,eax
mov ,0
mov ,WindowProc
mov ,0
mov ,0
mov eax,
mov ,eax
mov ,COLOR_WINDOW+1
mov ,0
mov ,_class
invoke RegisterClass,wc

invoke CreateWindowEx,0,_class,_title,WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT , CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, , NULL
mov ,eax
invoke ShowWindow, , SW_SHOWNORMAL
invoke UpdateWindow,

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,
;--------------------------------------------------------------------------------------------
proc WindowProc, hwnd,wmsg,wparam,lparam
enter
push ebx esi edi
cmp ,WM_DESTROY
je wmdestroy
cmp ,WM_PAINT
je wmpaint
defwndproc:
invoke DefWindowProc,,,,
jmp finish
wmpaint:
invoke BeginPaint, , _ps
mov [_hdc], eax
invoke GetClientRect, , _rect
invoke DrawText, [_hdc], _OurText, -1, _rect, DT_SINGLELINE+DT_CENTER+DT_VCENTER
invoke EndPaint, , _ps
jmp finish
wmdestroy:
invoke PostQuitMessage,0
xor eax,eax
finish:
pop edi esi ebx
return
;--------------------------------------------------------------------------------------------
section '.idata' import data readable writeable

library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'

import kernel,\
GetModuleHandle,'GetModuleHandleA',\
ExitProcess,'ExitProcess'

import user,\
RegisterClass,'RegisterClassA',\
CreateWindowEx,'CreateWindowExA',\
DefWindowProc,'DefWindowProcA',\
GetMessage,'GetMessageA',\
TranslateMessage,'TranslateMessage',\
DispatchMessage,'DispatchMessageA',\
LoadCursor,'LoadCursorA',\
LoadIcon,'LoadIconA',\
PostQuitMessage,'PostQuitMessage',\
ShowWindow,'ShowWindow',\
UpdateWindow, 'UpdateWindow',\
BeginPaint, 'BeginPaint',\
GetClientRect, 'GetClientRect',\
DrawText, 'DrawTextA',\
EndPaint, 'EndPaint',\
GetWindowLong, 'GetWindowLongA'
;=======================================================


Cheers,

The I
Posted on 2003-08-15 01:06:09 by imagineer