However, if I want to make a call to the CreateBM procedure, fasm complains of an invalid value where indicated.
format PE GUI 4.0
entry start
include '%fasminc%\win32axp.inc'
section '.code' code readable executable
start:
invoke GetModuleHandle,0
mov [wc.hInstance],eax
invoke RegisterClass,wc
invoke CreateWindowEx,WS_EX_CLIENTEDGE,myClass,myTitle,WS_CLIPCHILDREN+WS_VISIBLE+WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, [wc.hInstance],NULL
mov [hWndMain], eax
invoke ShowWindow, [hWndMain], SW_SHOWDEFAULT
invoke UpdateWindow, [hWndMain]
@@:
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]
proc wndProc hwnd,wmsg,wparam,lparam
push ebx esi edi
cmp [wmsg], WM_CREATE
je .wmCREATE
cmp [wmsg], WM_DESTROY
je .wmDESTROY
jmp .wmDEFAULT
.wmDEFAULT:
invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
jmp .wmBYE
.wmCREATE:
invoke LoadBitmap, [wc.hInstance], IDB_IMG
mov [ImgHnd], eax
; when the stdcall below is uncommented, it won't compile
; stdcall CreateBM, [imgHnd]
xor eax, eax
jmp .wmBYE
.wmDESTROY:
invoke PostQuitMessage,0
xor eax,eax
jmp .wmBYE
.wmBYE:
pop edi esi ebx
ret
endp
proc CreateBM, hbc
locals
bm BITMAP
hdcMem dd ?
hdcMem2 dd ?
hbmMask dd ?
endl
;when trying to compile with the above call uncommented, fasm says
;the line below has an invalid value
invoke GetObject, [hbc], sizeof.BITMAP, bm
ret
endp
section '.data' data readable writeable
ImgHnd dd ?
hWndMain dd ?
msg MSG
wc WNDCLASS 0, wndProc, 0, 0, NULL, NULL, NULL, COLOR_WINDOW+1, NULL, myClass
myClass db 'test', 0
myTitle db 'test', 0
IDB_IMG = 3000
section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',\
user32, 'USER32.DLL',\
gdi32, 'GDI32.DLL',\
comdlg32,'COMDLG32.DLL',\
advapi32,'ADVAPI32.DLL',\
comctl32,'COMCTL32.DLL'
include '%fasminc%\apia\Kernel32.inc'
include '%fasminc%\apia\User32.inc'
include '%fasminc%\apia\Gdi32.inc'
include '%fasminc%\apia\Comdlg32.inc'
include '%fasminc%\apia\Advapi32.inc'
include '%fasminc%\apia\Comctl32.inc'
section '.rsrc' resource data readable
directory \
RT_BITMAP, bitmaps
resource bitmaps, \
IDB_IMG, LANG_ENGLISH+SUBLANG_DEFAULT, ball
bitmap ball, 'img.bmp'