Function: displays the balloon tooltip using the system tray icon.
Author: purpleendurer | zixiao jianxia Yu, Hechi, Guangxi
; Date content
;----------------------------------------------------------------------
; 2007.08.23 completed.
; Created in 2007.08.21.
. 386
. Model flat, stdcall
Option Casemap: None
Include/masm32/include/Windows. inc
Include/masm32/include/kernel32.inc
Includelib/masm32/lib/kernel32.lib
; Include/masm32/include/ole32.inc
; Includelib/masm32/lib/ole32.lib
Include/masm32/include/shell32.inc
Includelib/masm32/lib/shell32.lib
Include/masm32/include/user32.inc
Includelib/masm32/lib/user32.lib
; Include/masm32/include/advapi32.inc
; Includelib/masm32/lib/advapi32.lib
; Include/masm32/include/comdlg32.inc
; Includelib/masm32/lib/comdlg32.lib
; Ssssssssssssssssssssssssssssssssssssssssssss
; Prototype
; Ssssssssssssssssssssssssssssssssssssssssssss
Winmain proto: DWORD,: DWORD
; Ssssssssssssssssssssssssssssssssssssssssssss
; Const
; Ssssssssssssssssssssssssssssssssssssssssssss
Wm_shellw.y equ wm_user + 200
Idi_tray equ 0
Notifyicondata50 struct
Cbsize DWORD?
Hwnd handle?
Uid dword?
Uflags DWORD?
Ucallbackmessage DWORD?
Hicon handle?
Sztip dB 128 DUP (?) ; Version 5.0 is 128, and previously 64
Dwstate DWORD? ; Icon status: nis_hidden: the icon is hidden; nis_sharedicon: the icon is shared.
Dwstatemask DWORD? Specifies which bits of dwstate can be read. If it is set to nis_hidden, the hidden status of the icon can be read.
Szinfo byte 256 DUP (?) ; Bubble prompt content
Union
Utimeout dd? ; For the Union type system, the minimum value is 10 seconds by default, and the maximum value is 30 seconds.
Uversion dd?
Ends
Szinfotitle byte 64 DUP (?) ; Bubble prompt title
Dwinfoflags DWORD? Indicates whether the icon is displayed on the bubble prompt.
Notifyicondata50 ends
Policyicon_version = 3
Policyicon_oldversion = 0
Nim_add = 0
Nim_modify = 1
Nim_delete = 2
Nim_setfocus = 3
Nim_setversion = 4
Nif_message = 1; ucallbackmessage items contain valid information
Nif_icon = 2; hicon items contain valid information
Nif_tip = 4; The sztip item contains valid information.
Nif_state = 8
Nif_info = 010 H
Nis_hidden = 1
Nis_nvidicon = 2
;/--- Bubble prompt icon Control
Niif_none = 0; no icon displayed
Niif_info = 1; "info" icon (blue)
Niif_warning = 2; "warning" icon (yellow)
Niif_error = 3; "error" icon (red)
;---/
Nin_select = wm_user + 0;
Nin_balloonshow = wm_user + 2; the shell sends this message when the bubble prompt is displayed.
Nin_balloonhide = wm_user + 3; when the bubble prompts to disappear (for example, the notification bar icon is deleted), the shell sends the message, but the bubble prompts that the message will not be generated because it disappears due to timeout.
Nin_balloontimeout = wm_user + 4; the shell sends this message when the bubble prompts to disappear due to timeout
Nin_balloonuserclick = wm_user + 5; send this message when you click the mouse (click the bubble prompt and notification bar icon)
Ninf_key = 1
Nin_keyselect = nin_select or ninf_key
Idc_ckbshowtrayicon equ 100
Idc_ckbshowballoon equ 110
C_appquit equ 1b
C_iconshowed equ 10b
; Ssssssssssssssssssssssssssssssssssssssssssss
. Data
; Ssssssssssssssssssssssssssssssssssssssssssss
G_szclassname label byte
G_szappname DB "balloon_tooltip_demo", 0
G_szbutton DB "button", 0
G_szshowtrayicon DB "display tray icon", 0
G_szshowballoon DB "show bubble information", 0
G_szappquit DB "program exited", 0
G_szinfo DB "this is a prompt message! ", 0
G_szinfotitle DB "this is the title of the prompt! ", 0
G_szclicktrayicon DB "you hit the system tray area icon", 0
G_szclickballoonoricon DB "you hit the icon in the bubble or System Tray Area", 0
G_szmessagehide DB "information hidden", 0
G_szshowmessagenow DB "information displayed", 0
G_szmessagetimeout DB "information display time reached", 0
G_dwflag DWORD 0
; Ssssssssssssssssssssssssssssssssssssssssssss
. Data?
; Ssssssssssssssssssssssssssssssssssssssssssss
G_hinstance hinstance?
G_hwndmain hwnd?
G_stnoteicon policyicondata50 <>
. Code
Start:
Invoke getmodulehandle, null
MoV g_hinstance, eax
Invoke winmain, g_hinstance, null, null, sw_showdefault
Invoke exitprocess, eax
Winmain proc hinst: hinstance, hprevinst: hinstance, using line: 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 or cs_dblclks
MoV WC. lpfnwndproc, offset wndproc
MoV WC. cbclsextra, null
MoV WC. cbwndextra, null
MoV eax, hinst
MoV WC. hinstance, eax
MoV WC. hbrbackground, color_btnshadow
MoV WC. lpszmenuname, null
MoV WC. lpszclassname, offset g_szclassname
Invoke loadicon, null, idi_application
MoV WC. hicon, eax
MoV WC. hiconsm, eax
Invoke loadcursor, null, idc_arrow
MoV WC. hcursor, eax
Invoke registerclassex, ADDR WC
Invoke createappswex, null, ADDR g_szclassname, ADDR g_szappname ,/
Ws_overlapped + ws_caption + ws_sysmenu, 100,100,300,100 ,/
Null, null, hinst, null; ws_visible
MoV hwnd, eax
Invoke showwindow, hwnd, sw_show
. 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 hwndmain: DWORD, umsg: DWORD, wparam: DWORD, lparam: DWORD
. If umsg = wm_destroy
Invoke shell_policyicon, nim_delete, ADDR g_stnoteicon
Invoke postquitmessage, null
. Elseif umsg = wm_close
Test g_dwflag, c_iconshowed
JZ @ destroywin
Test g_dwflag, c_appquit
. If zero?
MoV g_stnoteicon.utimeout, 20
Invoke lstrcpy, ADDR g_stnoteicon.szinfo, ADDR g_szappquit
Invoke shell_policyicon, nim_modify, ADDR g_stnoteicon
Or g_dwflag, c_appquit
Invoke showwindow, g_hwndmain, sw_hide
. Else
@ Destroywin:
Invoke destroywindow, g_hwndmain
. Endif
. Elseif umsg = wm_create
MoV eax, hwndmain
MoV g_hwndmain, eax
Invoke rtlzeromemory, ADDR g_stnoteicon, sizeof g_stnoteicon
MoV eax, g_hwndmain
MoV g_stnoteicon.hwnd, eax
MoV g_stnoteicon.cbsize, sizeof g_stnoteicon
MoV g_stnoteicon.uid, idi_tray
MoV g_stnoteicon.uflags, nif_icon + nif_message + nif_tip
MoV g_stnoteicon.ucallbackmessage, wm_shellnotify
Invoke loadicon, null, idi_winlogo
MoV g_stnoteicon.hicon, eax
Invoke lstrcpy, ADDR g_stnoteicon.sztip, ADDR g_szappname
Invoke createappswex, null, ADDR g_szbutton, ADDR g_szshowtrayicon ,/
Ws_border + ws_child + ws_visible + bs_autocheckbox, 5, 5,130, 20 ,/
G_hwndmain, idc_ckbshowtrayicon, g_hinstance, null
Invoke createappswex, null, ADDR g_szbutton, ADDR g_szshowballoon ,/
Ws_border + ws_child + ws_visible, 5, 30,130, 20 ,/
G_hwndmain, idc_ckbshowballoon, g_hinstance, null
. Elseif (umsg = wm_command)
MoV eax, wparam
MoV edX, eax
SHR edX, 16
. If (dx = bn_clicked)
. If (eax = idc_ckbshowtrayicon)
Test g_dwflag, c_iconshowed
. If zero?
MoV eax, nim_add
Or g_dwflag, c_iconshowed
. Else
MoV eax, nim_delete
And g_dwflag, not c_iconshowed
. Endif
Invoke shell_policyicon, eax, ADDR g_stnoteicon
. Elseif (eax = idc_ckbshowballoon)
XOR eax, eax
MoV g_stnoteicon.dwstate, eax
MoV g_stnoteicon.dwstatemask, eax
Invoke lstrcpy, ADDR g_stnoteicon.szinfo, ADDR g_szinfo
MoV g_stnoteicon.utimeout, 200
Invoke lstrcpy, ADDR g_stnoteicon.szinfotitle, ADDR g_szinfotitle
MoV g_stnoteicon.dwinfoflags, niif_info
MoV g_stnoteicon.uflags, nif_icon + nif_message + nif_tip + nif_info
MoV eax, nim_modify
Test g_dwflag, c_iconshowed
. If zero?
Or g_dwflag, c_iconshowed
Invoke senddlgitemmessage, g_hwndmain, idc_ckbshowtrayicon, bm_setcheck, bst_checked, 0
MoV eax, nim_add
. Endif
Invoke shell_policyicon, eax, ADDR g_stnoteicon
. Endif
. Endif
. Elseif umsg = wm_shellnotify
. If wparam = idi_tray
MoV eax, lparam
. If (eax = nin_balloonshow); the shell sends this message when the bubble prompt is displayed.
Invoke MessageBox, g_hwndmain, ADDR g_szshowmessagenow, ADDR g_szappname, mb_iconinformation
. Else
Test g_dwflag, c_appquit
. If zero?
. If (eax = nin_balloonhide)
Invoke MessageBox, g_hwndmain, ADDR g_szmessagehide, ADDR g_szappname, mb_iconinformation
. Elseif (eax = wm_rbuttondown | eax = wm_lbuttondown)
Invoke MessageBox, g_hwndmain, ADDR g_szclicktrayicon, ADDR g_szappname, mb_iconinformation
. Elseif (eax = nin_balloontimeout); the shell sends this message when the bubble prompts to disappear due to timeout
Invoke MessageBox, g_hwndmain, ADDR g_szmessagetimeout, ADDR g_szappname, mb_iconinformation
. Elseif (eax = nin_balloonuserclick)
Invoke MessageBox, g_hwndmain, ADDR g_szclickballoonoricon, ADDR g_szappname, mb_iconinformation
. Endif
. Else
Invoke sendmessage, g_hwndmain, wm_close, 0, 0
. Endif
. Endif
. Endif
. Else
Invoke defwindowproc, hwndmain, umsg, wparam, lparam
RET
. Endif
XOR eax, eax
RET
Wndproc endp
End start