今天抽空做了一个,LZ可以参考一下:
.ASM文件
*************************************************
;隐藏模态对话框例子程序
;功能:当按下"隐藏"按钮时,该窗口将隐藏,
;然后放一个小图标到系统托盘中。当双击小图标时,应
;用程序将恢复自己,并把小图标从系统托盘中删除。
;编译器:MASMPlus
;作者:ONEPROBLEM 日期:2009年2月12日
;================================================
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
include shell32.inc
includelib shell32.lib
ICO_MAIN equ 1000
IDD_DIALOG equ 1000
WM_SHELLNOTIFY equ WM_USER+100 ;自定义消息
.data?
hInstance dd ?
stICONDATA NOTIFYICONDATA <?>
.const
szText db '模态对话框例子程序',0
.code
;================================================
_ProcDlgMain proc uses ebx edi esi hWnd,uMsg,wParam,lParam
mov eax,uMsg
.if eax == WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif eax == WM_INITDIALOG
invoke LoadIcon,hInstance,ICO_MAIN
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
.elseif eax == WM_COMMAND
mov eax,wParam
.if ax == IDOK
mov stICONDATA.cbSize,sizeof NOTIFYICONDATA
push hWnd
pop stICONDATA.hwnd
mov stICONDATA.uID,ICO_MAIN
mov stICONDATA.uFlags,NIF_ICON+NIF_MESSAGE+NIF_TIP
mov stICONDATA.uCallbackMessage,WM_SHELLNOTIFY
invoke LoadIcon,NULL,IDI_WINLOGO
mov stICONDATA.hIcon,eax
invoke lstrcpy,addr stICONDATA.szTip,addr szText
invoke ShowWindow,hWnd,SW_HIDE
invoke Shell_NotifyIcon,NIM_ADD,addr stICONDATA
.elseif ax == IDCANCEL
invoke EndDialog,hWnd,NULL
.endif
.elseif eax == WM_SHELLNOTIFY
mov eax,lParam
.if eax == WM_LBUTTONDBLCLK
invoke ShowWindow,hWnd,SW_RESTORE ;恢复窗口界面
invoke Shell_NotifyIcon,NIM_DELETE,addr stICONDATA;删除小图标
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
;================================================
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,IDD_DIALOG,NULL,\
offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
end start
;================================================