When i try to attach this code to a push button, it does not work. Am I invoking the code wrong? What code should i put to call the code under the pushbutton?
The PushButton Code:
.ELSEIF eax==NCB_ShowBmp
Invoke ShowMain
mov hwndDlg,eax
.ENDIF
The window to show bmp file in:
ShowBmpMain proto :DWORD,:DWORD,:DWORD,:DWORD
.data
bmp db "MyBmp.bmp",0
.data?
hbmp HBITMAP ?
.code
ShowBmpMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,lpszArgs:LPSTR,nWinMode:DWORD
LOCAL hwnd:HWND
invoke CreateWindowEx, WS_EX_OVERLAPPEDWINDOW, ADDR ClassName,ADDR AppName,\
WS_VISIBLE or WS_POPUP,CW_USEDEFAULT,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,HWND_DESKTOP,NULL,\
hInst,NULL
mov hwnd,eax
invoke LoadImage, hInst, addr bmp, IMAGE_BITMAP, NULL, NULL, LR_LOADFROMFILE
mov hbmp,eax
invoke CreatePatternBrush, eax
invoke ShowWindow, hwnd, SW_SHOWMAXIMIZED
invoke UpdateWindow, hwnd
invoke ShowProc
ret
ShowBmpMain EndP
ShowBmpProc Proc hWnd:HWND, message:UINT, wParam:WPARAM, lParam:LPARAM
.IF message==WM_DESTROY
invoke DeleteObject, hbmp
invoke PostQuitMessage,NULL
.ELSEIF message==WM_KEYDOWN || message==WM_LBUTTONDOWN || message==WM_RBUTTONDOWN || message==WM_MBUTTONDOWN
invoke DeleteObject, hbmp
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWnd,message,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
ShowBmpProc EndP
I know it's pretty simple, and i'm sure i left something minor out. But isn't that always the case :)
Thanks,
Nokturnal
ahem... I see several problems.
You are invoking a procedure called ShowMain
.ELSEIF eax==NCB_ShowBmp
Invoke ShowMain
mov hwndDlg,eax
.ENDIF
But you define the procedure as ShowBmpMain (maybe a typo?)
Also ShowBmpMain requires 4 arguments and you haven't supplied any !
ShowBmpMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,lpszArgs:LPSTR,nWinMode;DWORD
You did the same thing later in ShowBmpMain when you invoke ShowProc. Should be ShowBmpProc (also requires 4 arguments).
ShowBmpProc Proc hWnd:HWND, message:UINT, wParam:WPARAM, lParam:LPARAM
Then you create a PatternBrush, but don't do anything with it.
You will need to "SelectObject" then maybe "FillRect" to see any visible results.
I would also suggest looking up Dialogs in the API/SDK.