im using this code i found to help me with getting a custom icon to show up in the caption bar. im getting some build errors when i try to build it so was hoping someone could tell me how to fix them.
;-icon.asm-------------------------------------------------------------------
; x86 - Dos & Win32 - Assembly Language Programming ;
; ;
; Written by: John A Lyons ;
; Email : sysop@megablast.8k.com ;
; Page : http://www.asmsource.8k.com/ ;
; Compiler : Masm32 v6.13 Microsoft Macro Assembler ;
; Date : 28-Dec-2000 ;
; Purpose : Uses an icon to replece the boring windows default. Very ;
; simple program, but important use of resource file ;
; ;
;----------------------------------------------------------------------------
; Compile with nmake
;
.386 ; 32-Bit when .386 appears before .MODEL
.MODEL FLAT , STDCALL
include windows.inc ;<--- i setup all the includes to
include user32.inc ;<--- the right directories
include kernel32.inc
include gdi32.inc
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib
EXTRN wsprintfA:PROC ;<------ this line is a problem
.const
IDI_ICON1 equ 5
.data
ClassName db "SimpleWinClass",0
AppName db "Icon",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hwnd HWND ?
hdc HDC ?
temp db 100 dup(0) ;<---- this line is a problem
.code
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:SDWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
; LOCAL hInst:HINSTANCE
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
mov eax,hInstance
mov wc.hInstance,eax
; push hInstance
; pop wc.hInstance
invoke LoadIcon, hInstance, IDI_ICON1
mov wc.hIcon,eax
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
; mov wc.hIcon,eax
mov wc.hIconSm,0
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT, ;postion
300,100, ;size
NULL,NULL,\
hInst,NULL
mov hwnd,eax
INVOKE ShowWindow, hwnd,SW_SHOWNORMAL
INVOKE UpdateWindow, hwnd
.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
LOCAL ps:PAINTSTRUCT
mov eax,uMsg
.IF eax==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF eax==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
invoke EndPaint,hWnd, ADDR ps
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
showtemp proc near
lea esi,temp
xor ecx,ecx
loll1:
inc ecx
inc esi
cmp ,byte ptr 0
jne loll1
invoke TextOut,hdc,0,ebx,ADDR temp,ecx
ret
sh
Problems:
1) wsprintf is defined in windows.inc, you can't re-define it to something else.
2) you defined "temp db 100 dup(0)" in the .data? section. Move it to .data
-----------------------
"Bart, with $10,000, we'd be millionaires!
We could buy all kinds of useful things like ... love!"
thanks ernie for getting me going. the example code i was using was pretty crappy. I ended up with the following code if anyone is interested in changing there icon. the code works great.
.386
.model flat,stdcall
option casemap:none
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
.const
IDI_ICON1 equ 5
.data
ClassName db "SimpleWinClass",0
AppName db "Icon",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hwnd HWND ?
.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
invoke LoadIcon, hInstance, IDI_ICON1
mov wc.hIcon,eax
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
CW_USEDEFAULT,300,200,NULL,NULL,\
hInst,NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.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
LOCAL ps:PAINTSTRUCT
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF eax==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
invoke EndPaint,hWnd, ADDR ps
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
end start
***********************************************************
***********************************************************
resource file looks like this:
#define IDI_ICON1 5
IDI_ICON1 ICON DISCARDABLE MOVEABLE LOADONCALL "skull.ico"
***********************************************************
This message was edited by smurf, on 3/24/2001 8:00:17 PM