Hello MASM32,
according to the documentation, it's possible to set a button with text and icon:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb775951(v=vs.85).aspx
but this code is not working for me... any idea?
include masm32rt.inc
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
.data
SzWindowClass db "WindowClass",0
SzButtonClass db "button",0
SzText db "text text",0
hMainWindow HWND 0
hButton HWND 0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
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 hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET SzWindowClass
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
INVOKE CreateWindowEx,NULL,ADDR SzWindowClass,ADDR SzWindowClass,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
hInst,NULL
mov hMainWindow,eax
invoke CreateWindowEx, 0, addr SzButtonClass, addr SzText, WS_CHILD or WS_VISIBLE or BS_TEXT, \
40, 40, 200, 200, hMainWindow, NULL, hInst, NULL
mov hButton, eax
invoke LoadIcon, hInst, 101
invoke SendMessage,hButton, BM_SETIMAGE, IMAGE_ICON, eax
invoke ShowWindow, hMainWindow,SW_SHOWNORMAL
invoke UpdateWindow, hMainWindow
.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 hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
end start
Add a manifest to your resource file, this will reference common controls v6.
Sinsi, Did that work for you? I tried it but still not working... :-P
I renamed WinApp4.rc to rsrc.rc and used "Build All" from the qeditor menu.
nope, does'nt work... can you share the exe file?
Here you go.
Works fine. :t
Works well under Win 7-64. :t
Gunther