;编写一个记事本是学习各种语言的一个基本功。
;本文不完善,在不断的完善中。
;需要的图标等文件,自己制作。
;rc文件如下:
#include <resource.h>
#define ICO_BIG 0x1000
#define me 0x7777
#define ICO_BIG 0x1000
#define me 0x7777
#define IDM_open 9
#define IDM_save 99
#define IDM_exit 999
#define IDM_about 9999
#define IDM_save 99
#define IDM_exit 999
#define IDM_about 9999
me ICON "me.ico"
//meBMP BITMAP "me.BMP"
//meBMP BITMAP "me.BMP"
meno_correy menu discardable
BEGIN
popup "文件(&F)"
BEGIN
menuitem "打开(&o)",IDM_open
menuitem "保存(&s)",IDM_save
menuitem "退出(&X)",IDM_exit
END
popup "帮助(&h)"
BEGIN
menuitem "关于",IDM_about
END
END
BEGIN
popup "文件(&F)"
BEGIN
menuitem "打开(&o)",IDM_open
menuitem "保存(&s)",IDM_save
menuitem "退出(&X)",IDM_exit
END
popup "帮助(&h)"
BEGIN
menuitem "关于",IDM_about
END
END
1 VERSIONINFO
FILEVERSION 9,9,9,9
PRODUCTVERSION 9,9,9,9
FILEOS 0
FILETYPE 0
FILESUBTYPE 0
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "Comments", "我要找一个人。"
VALUE "CompanyName", "correy "
VALUE "FileVersion", "made by correy "
VALUE "FileDescription", "made by correy"
VALUE "InternalName", "made by correy"
VALUE "LegalCopyright", "made by correy"
VALUE "LegalTrademarks", "made by correy"
VALUE "OriginalFilename", "made by correy"
VALUE "ProductName", "made by correy"
VALUE "ProductVersion", "made by correy"
VALUE "PrivateBuild", "made by correy"
VALUE "SpecialBuild", "made by correy"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 2052, 1200
}
}
FILEVERSION 9,9,9,9
PRODUCTVERSION 9,9,9,9
FILEOS 0
FILETYPE 0
FILESUBTYPE 0
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "Comments", "我要找一个人。"
VALUE "CompanyName", "correy "
VALUE "FileVersion", "made by correy "
VALUE "FileDescription", "made by correy"
VALUE "InternalName", "made by correy"
VALUE "LegalCopyright", "made by correy"
VALUE "LegalTrademarks", "made by correy"
VALUE "OriginalFilename", "made by correy"
VALUE "ProductName", "made by correy"
VALUE "ProductVersion", "made by correy"
VALUE "PrivateBuild", "made by correy"
VALUE "SpecialBuild", "made by correy"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 2052, 1200
}
}
;asm文件如下:
;made by correy
;Email:leguanyuan@126.com
;QQ:112426112
;rc me.rc
;ml /coff test.asm /link /subsystem:windows me.res
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
includelib user32.lib
includelib kernel32.lib
include comdlg32.inc
includelib comdlg32.lib
include Comctl32.inc
includelib Comctl32.lib
;Email:leguanyuan@126.com
;QQ:112426112
;rc me.rc
;ml /coff test.asm /link /subsystem:windows me.res
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
includelib user32.lib
includelib kernel32.lib
include comdlg32.inc
includelib comdlg32.lib
include Comctl32.inc
includelib Comctl32.lib
.data
mebmp db "mebmp",0
szClassName db "made by correy",0
menocorrey db "meno_correy",0
szButton db "button",0
szButtonText db "OK",0
SZEDIT DB "eDIT",0
SZsTATIC DB "Static",0
szFilter db 'Text Files(*.txt)',0,'*.txt',0,'All Files(*.*)',0,'*.*',0,0
szSaveCaption db 'save as',0
szDefExt db 'txt',0
szClass db "msctls_statusbar32",0
mebmp db "mebmp",0
szClassName db "made by correy",0
menocorrey db "meno_correy",0
szButton db "button",0
szButtonText db "OK",0
SZEDIT DB "eDIT",0
SZsTATIC DB "Static",0
szFilter db 'Text Files(*.txt)',0,'*.txt',0,'All Files(*.*)',0,'*.*',0,0
szSaveCaption db 'save as',0
szDefExt db 'txt',0
szClass db "msctls_statusbar32",0
.data?
hInstance dd ?
hMenu dd ?
stWndClass WNDCLASSEX <>
stMsg MSG <>
stOF OPENFILENAME <>
szFileName db MAX_PATH dup (?)
szBuffer db 1024 dup (?)
hWinMain dd ?
hInstance dd ?
hMenu dd ?
stWndClass WNDCLASSEX <>
stMsg MSG <>
stOF OPENFILENAME <>
szFileName db MAX_PATH dup (?)
szBuffer db 1024 dup (?)
hWinMain dd ?
.const
me equ 07777h
IDM_open equ 9
IDM_save equ 99
IDM_exit equ 999
IDM_about equ 9999
me equ 07777h
IDM_open equ 9
IDM_save equ 99
IDM_exit equ 999
IDM_about equ 9999
.code
liuchunli proc hWnd,uMsg,wParam,lParam
LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC
LOCAL hMemDC:HDC
LOCAL rect:RECT
mov eax,uMsg
.if eax == WM_CREATE
invoke LoadIcon,hInstance,me
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
invoke CreateWindowEx,NULL,offset SZEDIT,offset szClassName,\
WS_CHILD or WS_VISIBLE OR ES_LEFT OR WS_BORDER OR WS_TABSTOP or ES_MULTILINE or ES_WANTRETURN or ES_NOHIDESEL or ES_AUTOHSCROLL or ES_AUTOVSCROLL,\
0,0,999,713,hWnd,1,hInstance,NULL
;invoke CreateWindowEx,NULL,addr szClass,NULL,WS_CHILD OR WS_VISIBLE OR SBS_SIZEGRIP,0,0,0,0,hWnd,1,hInstance,NULL
ret
.elseif uMsg==WM_PAINT
;invoke BeginPaint,hWnd,addr ps
;invoke EndPaint,hWnd,addr ps
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
.IF ax==9
invoke RtlZeroMemory,addr stOF,sizeof stOF
mov stOF.lStructSize,sizeof stOF
push hWinMain
pop stOF.hwndOwner
mov stOF.lpstrFilter,offset szFilter
mov stOF.lpstrFile,offset szFileName
mov stOF.nMaxFile,MAX_PATH
mov stOF.Flags,OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST
invoke GetOpenFileName,addr stOF
.ELSEIF ax==99
invoke RtlZeroMemory,addr stOF,sizeof stOF
mov stOF.lStructSize,sizeof stOF
push hWinMain
pop stOF.hwndOwner
mov stOF.lpstrFilter,offset szFilter
mov stOF.lpstrFile,offset szFileName
mov stOF.nMaxFile,MAX_PATH
mov stOF.Flags,OFN_PATHMUSTEXIST
mov stOF.lpstrDefExt,offset szDefExt
mov stOF.lpstrTitle,offset szSaveCaption
invoke GetSaveFileName,addr stOF
liuchunli proc hWnd,uMsg,wParam,lParam
LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC
LOCAL hMemDC:HDC
LOCAL rect:RECT
mov eax,uMsg
.if eax == WM_CREATE
invoke LoadIcon,hInstance,me
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
invoke CreateWindowEx,NULL,offset SZEDIT,offset szClassName,\
WS_CHILD or WS_VISIBLE OR ES_LEFT OR WS_BORDER OR WS_TABSTOP or ES_MULTILINE or ES_WANTRETURN or ES_NOHIDESEL or ES_AUTOHSCROLL or ES_AUTOVSCROLL,\
0,0,999,713,hWnd,1,hInstance,NULL
;invoke CreateWindowEx,NULL,addr szClass,NULL,WS_CHILD OR WS_VISIBLE OR SBS_SIZEGRIP,0,0,0,0,hWnd,1,hInstance,NULL
ret
.elseif uMsg==WM_PAINT
;invoke BeginPaint,hWnd,addr ps
;invoke EndPaint,hWnd,addr ps
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
.IF ax==9
invoke RtlZeroMemory,addr stOF,sizeof stOF
mov stOF.lStructSize,sizeof stOF
push hWinMain
pop stOF.hwndOwner
mov stOF.lpstrFilter,offset szFilter
mov stOF.lpstrFile,offset szFileName
mov stOF.nMaxFile,MAX_PATH
mov stOF.Flags,OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST
invoke GetOpenFileName,addr stOF
.ELSEIF ax==99
invoke RtlZeroMemory,addr stOF,sizeof stOF
mov stOF.lStructSize,sizeof stOF
push hWinMain
pop stOF.hwndOwner
mov stOF.lpstrFilter,offset szFilter
mov stOF.lpstrFile,offset szFileName
mov stOF.nMaxFile,MAX_PATH
mov stOF.Flags,OFN_PATHMUSTEXIST
mov stOF.lpstrDefExt,offset szDefExt
mov stOF.lpstrTitle,offset szSaveCaption
invoke GetSaveFileName,addr stOF
.ELSEIF ax==999
invoke DestroyWindow,hWnd
.ELSEIF ax==9999
invoke MessageBox,NULL,ADDR szClassName, OFFSET szClassName, MB_OK
.ELSE
;invoke MessageBox,NULL,ADDR szClassName, OFFSET szClassName, MB_OK
.ENDIF
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
ret
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
liuchunli endp
invoke DestroyWindow,hWnd
.ELSEIF ax==9999
invoke MessageBox,NULL,ADDR szClassName, OFFSET szClassName, MB_OK
.ELSE
;invoke MessageBox,NULL,ADDR szClassName, OFFSET szClassName, MB_OK
.ENDIF
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
ret
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
liuchunli endp
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke LoadMenu, 0, OFFSET menocorrey
mov hMenu,eax
push hInstance
pop stWndClass.hInstance
mov stWndClass.cbSize,sizeof WNDCLASSEX
mov stWndClass.hbrBackground,6
invoke LoadCursor,0,IDC_ARROW
mov stWndClass.hCursor,eax
;mov stWndClass.lpszMenuName,OFFSET menocorrey
mov stWndClass.lpszClassName,offset szClassName
mov stWndClass.lpfnWndProc,offset liuchunli
invoke RegisterClassEx,addr stWndClass
invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szClassName,\
WS_OVERLAPPEDWINDOW OR WS_VSCROLL,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,hMenu,hInstance,0
mov hInstance,eax
invoke ShowWindow,hInstance,1
invoke UpdateWindow,hInstance
.while TRUE
invoke GetMessage,addr stMsg,NULL,0,0
.break .if eax == 0
invoke TranslateMessage,addr stMsg
invoke DispatchMessage,addr stMsg
.endw
invoke ExitProcess,NULL
end start
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke LoadMenu, 0, OFFSET menocorrey
mov hMenu,eax
push hInstance
pop stWndClass.hInstance
mov stWndClass.cbSize,sizeof WNDCLASSEX
mov stWndClass.hbrBackground,6
invoke LoadCursor,0,IDC_ARROW
mov stWndClass.hCursor,eax
;mov stWndClass.lpszMenuName,OFFSET menocorrey
mov stWndClass.lpszClassName,offset szClassName
mov stWndClass.lpfnWndProc,offset liuchunli
invoke RegisterClassEx,addr stWndClass
invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szClassName,\
WS_OVERLAPPEDWINDOW OR WS_VSCROLL,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,hMenu,hInstance,0
mov hInstance,eax
invoke ShowWindow,hInstance,1
invoke UpdateWindow,hInstance
.while TRUE
invoke GetMessage,addr stMsg,NULL,0,0
.break .if eax == 0
invoke TranslateMessage,addr stMsg
invoke DispatchMessage,addr stMsg
.endw
invoke ExitProcess,NULL
end start
没有评论:
发表评论