初始化资源的时候已经调用了LoadIcon和SendDlgItemMessage,可还是不行。
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
ICON_MAIN equ 1001
DLG_MAIN equ 1000
IDC_EXIT equ 1002
.data?
hInstance dd ?
.const
.code
_ProcDlgMain proc uses ebx esi edi hWnd,wMsg,wParam,lParam
mov eax,wMsg
.if eax == WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif eax == WM_INITDIALOG
invoke LoadIcon,hInstance,ICON_MAIN
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
.elseif eax == WM_COMMAND
mov eax,wParam
.if ax == IDC_EXIT
invoke EndDialog,hWnd,NULL
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
end start
dlgDlg.rc:
#define DLG_MAIN 1000
#define IDC_EXIT 1002
#define ICON_MAIN 1001
DLG_MAIN DIALOGEX 6,6,129,70
CAPTION "消息框"
FONT 9,"宋体",400,0,134
STYLE 0x10CF0000
EXSTYLE 0x00000000
BEGIN
CONTROL "演示对话框",-1,"Static",0x50000000,58,22,56,10,0x00000000
CONTROL "OK",IDC_EXIT,"Button",0x50010000,62,52,52,14,0x00000000
CONTROL "",-1,"Static",0x50000010,10,48,102,1,0x00000000
CONTROL "#1001",ICON_MAIN,"Static",0x50000203,6,6,42,38,0x00000000
END
questionRes.rc:
#define ICON_MAIN 1001
ICON_MAIN ICON DISCARDABLE "Main.ico"
我想是不是因为我那句定义图标的话写错了啊?
CONTROL "#1001",ICON_MAIN,"Static",0x50000203,6,6,42,38,0x00000000
教程里生成的语句是:
ICON ICO_MAIN, -1, 10, 11, 18, 21
就这句不一样,所以我想是不是我在工具栏选择的控件不对?
下面这个是教程里面的rc文件:
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#include <resource.h>
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define ICO_MAIN 0x1000 //图标
#define DLG_MAIN 1
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ICO_MAIN ICON "Main.ico"
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DLG_MAIN DIALOG 50, 50, 113, 64
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "对话框模板"
FONT 9, "宋体"
{
ICON ICO_MAIN, -1, 10, 11, 18, 21
CTEXT "简单的对话框例子\n用Win32ASM编写", -1, 36, 14, 70, 19
DEFPUSHBUTTON "退出(&X)", IDOK, 58, 46, 50, 14
CONTROL "", -1, "Static", SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 6, 39, 103, 1
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
就这个小图标本人弄了两天了。实在没办法了。请高手帮忙吧。直接把资源当成附件给大家看看吧。我的是用RadASM编译的。
上传的附件: