I do it like this????all files are in the same folder??
resouce file ??
#define IDI_ICON 102
?_?_ ?_?_
IDI_ICON ICON "test.ico"
?_?_ ?_?_
asm file??
?_?_ ?_?_
.const
IDI_ICON equ 102
?_?_ ?_?_
invoke LoadIcon,NULL,IDI_ICON
mov wc.hIcon,eax
mov wc.hIconSm,eax
?_?_ ?_?_
but it doesn't work, where is wrong.?
Posted on 2002-10-04 07:21:10 by devspace
You need to give the handle for the instance containing the icon resource (hInstance) obtained with GetModuleHandle function.

asm file??
?_?_ ?_?_
.const
IDI_ICON equ 102
?_?_ ?_?_
invoke GetModuleHandle,0
mov wc.hInstance,eax

invoke LoadIcon,eax,IDI_ICON
mov wc.hIcon,eax
mov wc.hIconSm,eax
?_?_ ?_?_
Posted on 2002-10-04 07:31:02 by pelaillo
But it isn't work still:
The resource file is:
#include "\masm32\include\resource.h"
#define IDI_ICON 102 ;???
#define IDM_CREATE 1
#define IDM_OPEN 2
#define IDM_SAVE 3
#define IDM_SAVEAS 4
#define IDM_EXIT 5
#define IDM_BACKCOLOR 6
#define IDM_FONTSIZE 7
#define IDM_FONTCOLOR 8
#define IDM_HELP 9
#define IDM_ABOUT 10
FirstMenu menu
{ popup "???",help
{menuitem "??",IDM_CREATE,GRAYED
menuitem "????",IDM_OPEN
menuitem "????",IDM_SAVE
menuitem "??????_?_",IDM_SAVEAS
menuitem separator
menuitem "???",IDM_EXIT}
popup "???_"
{menuitem "????",IDM_BACKCOLOR
menuitem "???",IDM_FONTCOLOR
menuitem "????",IDM_FONTSIZE}
popup "????"
{menuitem "????",IDM_HELP
menuitem separator
menuitem "????",IDM_ABOUT}}
IDI_ICON ICON "myicon.ico"



The asm file like this:
.386
.model flat,stdcall
option casemap:none
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\gdi32.lib

.const
IDI_ICON equ 102
.data
MenuName db "FirstMenu",0 ;
ClassName db "MyClass",0 ;
AppName db "NotePad",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
local hwnd:HWND
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 hInst
pop wc.hInstance
invoke LoadIcon,hInst,IDI_ICON
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,offset MenuName
mov wc.lpszClassName,offset ClassName
invoke RegisterClassEx,addr wc
invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr ClassName,addr AppName,WS_OVERLAPPEDWINDOW,200,200,\
400,200,NULL,NULL,hInst,NULL
mov hwnd,eax
invoke ShowWindow,hwnd,SW_SHOWDEFAULT
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
.if uMsg==WM_CREATE

.elseif uMsg==WM_COMMAND

.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
(I come from china ,and english is poor ,will make you a friend,
my email is:devspace@etang.com)
Posted on 2002-10-05 05:20:22 by devspace

But it isn't work still:
The resource file is:
#include "\masm32\include\resource.h"
#define IDI_ICON 102 ;???
#define IDM_CREATE 1
#define IDM_OPEN 2
#define IDM_SAVE 3
#define IDM_SAVEAS 4
#define IDM_EXIT 5
#define IDM_BACKCOLOR 6
#define IDM_FONTSIZE 7
#define IDM_FONTCOLOR 8
#define IDM_HELP 9
#define IDM_ABOUT 10
FirstMenu menu
{ popup "???",help
{menuitem "??",IDM_CREATE,GRAYED
menuitem "????",IDM_OPEN
menuitem "????",IDM_SAVE
menuitem "??????_?_",IDM_SAVEAS
menuitem separator
menuitem "???",IDM_EXIT}
popup "???_"
{menuitem "????",IDM_BACKCOLOR
menuitem "???",IDM_FONTCOLOR
menuitem "????",IDM_FONTSIZE}
popup "????"
{menuitem "????",IDM_HELP
menuitem separator
menuitem "????",IDM_ABOUT}}
IDI_ICON ICON "myicon.ico"



The asm file like this:
.386
.model flat,stdcall
option casemap:none
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\gdi32.lib

.const
IDI_ICON equ 102
.data
MenuName db "FirstMenu",0 ;
ClassName db "MyClass",0 ;
AppName db "NotePad",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
local hwnd:HWND
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 hInst
pop wc.hInstance
invoke LoadIcon,hInst,IDI_ICON
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,offset MenuName
mov wc.lpszClassName,offset ClassName
invoke RegisterClassEx,addr wc
invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr ClassName,addr AppName,WS_OVERLAPPEDWINDOW,200,200,\
400,200,NULL,NULL,hInst,NULL
mov hwnd,eax
invoke ShowWindow,hwnd,SW_SHOWDEFAULT
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
.if uMsg==WM_CREATE

.elseif uMsg==WM_COMMAND

.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
(I come from china ,and english is poor ,will make you a friend,
my email is:devspace@etang.com)



Nice to meet you, devspace. I'm from China, too. I've seen your post in CSDN. My id there is "itaolu".

Your problem is caused by this line:

#define IDI_ICON 102 ;???

remember that ";" is only available in ASM Code, NOT in .rc file.

if you delete ";???", the problem will be solved.


???????????????????????????
????????????????????CSDN??????????????????????????
???_??????????????http://laoluoc.yeah.net
Posted on 2002-10-05 06:34:29 by pazuluo