Tray icon prompt

xiaoxiao2021-03-06  64

Tray icon prompt [source author Yefanqiu, Posted by TEST 2004-10-17 19:19:11]

Form code '******************************************************** ************************** ** module name: frmTest '**: YFSoft Copyright 2004-2005 (C) '** Created: Ye Fan' ** Japan: 2004-10-14 09:08:28 '** Modified:' ** Japan: '** Description: Tray Balloon Tips' ** Version: v1.0.0 '***************************************************** ***************************** OPTION Explicit '***************** *********************************************************** ****** '** function name: cmddel_click' ** input: no '** output: no' ** function description: Delete icon '** global variable:' ** Call Module: '* * Author: Ye Fan '** Japan: 2004-10-14 09:34:58' ** Modified: '** Japan:' ** version: v1.0.0 '***** *********************************************************** ************************* Private Sub Cmddel_Click () Delnotifyicon Me End Sub '********************** *********************************************************** * '** function name: cmdshow_click' ** input: no '** output: no' ** function description: Show prompt '** global variable:' ** Call Module: '** Author: Leaves Sail '** Japanese: 2004-10-14 09:34:44' ** Modified: '** Japan:' ** version: v1.0.0 '********* *********************************************************** ************ Privat E SUB CMDSHOW_CLICK () ShownotifyiCon Me, TXTTITECI, TXTINFO, CMBTYPE.LISTINDEX End Sub '******************************************* **************************************** ** ************* ** 输 入: No '** output: no' ** function description: '** Global variable:' ** Call Module: Initialization '** Author: Ye Fan' ** Japan: 2004-10- 14 09:08:57 '** repair people:

'** date:' ** version: v1.0.0 '******************************************** ******************************************************************************* Private Sub Form_Load () CMBTYPE.LISTINDEX = 1 ' Information icon cmdshow_click 'display information end sub' ************************************************************ ******************************** ** function name: form_unload '** input: Cancel (Integer) - '** output: no' ** function description: End '** global variable:' ** Call Module: '** Server: Ye Fan' ** Japan: 2004-10-14 09:35: 32 '** modified:' ** Japan: '** version: v1.0.0' ************************* *************************************************************** Private Sub Form_Unloyad (Cancel As INTEGER) 'Remove Icon CMDDEL_CLICK' Uninstall All Forms DIM FRM AS FORM for EACH FRM in Forms Unload FRM Next End Sub ---------------------------------------------------------------------------------------------- -------------------------------------------------- -------- 'Module Code' ************************************************ *********************************** ** module name: mdlnotifybase '**: YFSoft Copyright 2004 - 2005 (C) '** Created: Ye Fan' ** Japan: 2004-10-14 09:17:46 '** Modified:' ** Japan: '** Release: Show tray prompt Module '** version: v1.0.0' *********************************************** ********************************** OPTION Explicit Private Declare Function SetWindowlong Lib "User32.dll" Alias ​​"SetWindowlonga" (BYVAL HWND As Long, Byval Nindex As Long, Byval Dwnewlong As Long AS Long Private Declare Function CallWindowProc LIB "User32.dll" Alias ​​"CallWindowProca"

(ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Const WM_RBUTTONUP = & H205 Private Const WM_USER = & H400 Private Const WM_NOTIFYICON = WM_USER 1 'custom message Private const WM_LBUTTONDBLCLK = & H203 Private const GWL_WNDPROC = (-4) 'custom message on a balloon tip is not generated 2000 Private const NIN_BALLOONSHOW = (WM_USER & H2) messages' performs Private const NIN_BALLOONHIDE when balloon tips pop = (WM_USER & H3) 'When the Balloon TIPS disappears (such as Systrayicon is deleted),' But the specified Timeout time is or the mouse clicked after the disappearance of Balloon Tips does not send this message private const nin_balloontimeout = (WM_USER & H4) "When Balloon Tips TIMEOUT Time is time to perform private const nin_balloonuserclick = (WM_USER & H5) 'is executed when the mouse click on Balloon TIPS. 'Note: There is a closed button on the Balloon TIPS when executed under XP,' If the mouse point will receive the Nin_ballOontimeout message on the button.

Handle uId Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias ​​"Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long Private Type NOTIFYICONDATA cbSize As Long 'structure size (in bytes) hwnd As Long' window message processing As long 'unique identifier uflags as long' Flags UcallbackMessage As Long 'Handling Messages HiCon As long' tray icon Handle SZTIP AS STRING * 128 'Tooltip Tips DWSTATE AS long' tray icon status DWSTATEMASK As long ' Status mask SZINFO AS STRING * 256 Balloon Tips Text UtimeOutorVersion As Long 'Balloon Tips Disappear Time or Version' Utimeout - Balloon Tips Disappearance Time (Unit: MS, 1000 - 30000) 'Uversion - Version (0 for v4, 3 for V5) Szinfotitle As String * 64 'Balloon Tip Title DWINFOFLAGS AS Long' Balloon Tips End Type 'DWState To Notifyicondata Structure Private Const NIS_HIDDEN = & H1' Hide Icon Private Const Nis_Sharedicon = & H2 'share icon' dwInfoFlags to NOTIFIICONDATA structure Private Const NIIF_NONE = & H0 'no icon Private Const NIIF_INFO = & H1' "Messages" icon Private Const NIIF_WARNING = & H2 ' "warning" icon Private Const NIIF_ERROR = & H3' "error" icon 'uFlags to NOTIFYICONDATA structure Private Const NIF_ICON As Long = & H2 Private Const NIF_INFO As Long = & H10 Private Const NIF_MESSAGE As Long = & H1 Private Const NIF_STATE As Long = & H8 Private Const NIF_TIP As Long = & H4 '

dwMessage to Shell_NotifyIcon Private Const NIM_ADD As Long = & H0 Private Const NIM_DELETE As Long = & H2 Private Const NIM_MODIFY As Long = & H1 Private Const NIM_SETFOCUS As Long = & H3 Private Const lngNIM_SETVERSION As Long = & H4 Private lngPreWndProc As Long '******* *********************************************************** **************** ** Function Name: Shownotifyicon '** Infit: FRM (Form) - Form' **: start - Tray Title ' **: STRINFO (STRING) - Tray Tip Information '**: Optional LNGTYPE (long = 1) - Tray Tip Type 0 None 1 Information 2 Warning 3 Error' **: Optional LngTime (long = 10000) - Fast Time '* * Out: no '** function description: Show tray icon prompt information' ** global variable: '** Call Module:' ** Author: Ye Fan '** Japan: 2004-10-14 09:23 : 14 '** Model:' ** Japan: '** version: v1.0.0' ************************ ******************************************************* Public SUB Shownotifyicon (FRM As Form, Strtitle As String, Strinfo As String, Optional LNGTYPE AS long = 1, Optional LNGTIME AS long = 10000) 'Add icon to the tray area DIM ICONDATA A s NOTIFYICONDATA strTitle = strTitle & vbNullChar strInfo = strInfo & vbNullChar With IconData .cbSize = Len (IconData) .hwnd = frm.hwnd .uId = 0 .uFlags = NIF_TIP Or NIF_ICON Or NIF_MESSAGE Or NIF_INFO Or NIF_STATE .uCallBackMessage = WM_NOTIFYICON .szTip = Strtitle .hicon = frm.icon.handle .dwstate = 0 .dwstatemask = 0 .szinfo =

strInfo .szInfoTitle = strTitle .dwInfoFlags = lngType .uTimeoutOrVersion = lngTime End With If lngPreWndProc = 0 Then 'not initialized Shell_NotifyIcon NIM_ADD, IconData lngPreWndProc = SetWindowLong (frm.hwnd, GWL_WNDPROC, AddressOf WindowProc) Else' initialized Shell_NotifyIcon NIM_MODIFY, IconData End If End Sub '*********************************************** ************************** ** Function Name: Delnotifyicon '** input: fm (form) - Form' ** Out: no '** function description: Delete tray icon' ** global variable: '** call module:' ** author: Ye Fan '** Japan: 2004-10-14 09:33:01' ** Model: '** Japan:' ** version: v1.0.0 '*********************************** ****************************************************** Public Sub Delnotifyicon (FRM AS FORM) IF LNGPREWNDPROC <> 0 THEN 'Delete Tray area icon DIM ICONDATA AS NOTIFYICONDATA with icondata .cbsize = len (icondata) .hwnd = frm.hwnd .uid = 0 .uflags = nif_tip or nif_icon or ni F_MESSAGE .uCallBackMessage = WM_NOTIFYICON .szTip = "" .hIcon = frm.Icon.Handle End With Shell_NotifyIcon NIM_DELETE, IconData SetWindowLong frm.hwnd, GWL_WNDPROC, lngPreWndProc lngPreWndProc = 0 End If End Sub '********** *********************************************************** ************* ** function name: windowproc '** input: byval hwnd (long) -' **: byval msg (long) - '**: byval wparam Long) - '

**: BYVAL LPARAM (long) - '** Out: (long) -' ** Function Description: FRMTEST window entry function '** global variable:' ** Call Module: '** Author: Ye Fan' ** Japan: 2004-10-14 09:19:06 '** Modified:' ** Japan: '** version: v1.0.0' *********** *********************************************************** *********** Function WindowProc (ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long 'message interception WM_NOTIFYICON If msg = WM_NOTIFYICON Then Select Case lParam Case WM_RBUTTONUP 'Right-click the icon is the code that runs here, you can add a pop-up right-click menu CASE WM_LBUTTONDBLCLK' Left-click Display Forms FRMTEST.SHOW CASE NIN_BALLOONSHOW Debug.Print "Show balloon prompt" case nin_balloonhide debug.print "Delete Tray icon "case nin_balloontimeout debug.print" balloon prompt disappears "Case nin_balloonuserclick debug.print" Click Balloon Tips "End Select End IF WINDOPROC = CallWindowProc (LNGPREWNDPROC, HWND, MSG, WPARAM , Lparam) End Function The following is the other article published by this author

转载请注明原文地址:https://www.9cbs.com/read-85444.html

New Post(0)