New Engineering MyProject, New Forms FRMMAIN, New Module Modmain
And other components (cmdadd, cmdmodify, cmddelete, Iicon1, Iicon2), as shown:
FRMMAIN:
'********************************************************** *********************** The ** definition object '******************** *********************************************************** *** DIM MyData1 As Notifyicondatadim MyData2 as Notifyicondata
'********************************************************** *********************** The ** Add Tray Icon '******************* *********************************************************** **** Private Sub Cmdadd_click () AddSystrayicon MyData1END SUB
'********************************************************** *********************** The ** delete the tray icon '****************** *********************************************************** **** Private sub cmddelete_click () err.clear deletesystrayicon mydata1 deletesystrayicon mydata2 err.clearend Sub
'********************************************************** ************************ ** Modify the pallet icon '******************* *********************************************************** **** Private Sub CmdModify_Click () Modifyysystrayicon MyData2nd Sub
'********************************************************** *********************** ** set the tray icon '******************* *********************************************************** **** Private Sub Form_Load () With myData1 .cbSize = Len (myData1) .hwnd = Me.hwnd .uId = 0 .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP .ucallbackMessage = WM_MOUSEMOVE .hIcon = iIcon1.Picture.Handle .szTip = "tray program test!" & vbNullChar End With With myData2 .cbSize = Len (myData2) .hwnd = Me.hwnd .uId = 0 .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP .ucallbackMessage = WM_MOUSEMOVE .hIcon = iIcon2.Picture.Handle .sztip = "tray program tested!" & vbnullchaar end wirth sub '***************************************************** ************************************* ** Mouse event "******* *********************************************************** **************** Private Sub Form_MouseMove (Button As INTEGER, Shift As Integer, x askLE, Y askLE) DIM Message As Long Messag E = x / screen.twipsperpixelx select case message, "Click Right click", Vbinformation, "System Tips" case wm_lbuttonup msgbox "click left button", vbinformation, "system prompt" End Selectension Sub
-------------------------------------------------- -------------------------------------------------- -------------------------------------------
MODMAIN:
'********************************************************** *********************** The ** palplicer program '******************** *********************************************************** *** Public Declare Function Shell_notifyicon lib "shell32.dll" alias "shell_notifyicona" (Byval DwMessage As Long, LPDATA AS Notifyicondata) As long '********************************* *********************************************************** *** '** SHELL_NOTIFYICON DWMESSAGE can be one of the following nim_add, nim_delete, nim_modify identifier' ************************************ ****************************************************** PUBLIC const nim_add = & H0 'adds an icon public const nim_delete = & h2' in the taskbar to delete an icon in the taskbar in the taskbar. Public const nim_modify = & h1 'Modify the icon information in the taskbar
'********************************************************** *********************** ** get mouse information '******************* *********************************************************** **** Public Const WM_MOUSEMOVE = & H200 'moves the mouse on the icon Public Const WM_LBUTTONDOWN = & H201' mouse button pressed Public Const WM_LBUTTONUP = & H202 'left mouse button is released Public Const WM_LBUTTONDBLCLK = & H203' double click Public Const WM_RBUTTONDOWN = & H204 'mouse button Press public const wm_rbuttonup = & h205' mouse right button to release public const wm_rbuttondblclk = & h206 'Double-click the mouse button PUBLIC Const WM_SETHOTKEY = & H32' Responding to your defined hotkey
'********************************************************** ******************* ************************************************************************************************* *********************************************************** ******* Public Type Notifyicondata CBSIZIZE AS LONG 'The size of the data structure HWND As long' handling the icon window handle Uid as long 'defined in the taskbar of the icon UFLAGS As long' taskbar icon Functional control, can be a combination of the following (generally included) UCALLBACKMESSAGE AS long 'taskbar icon to handle messages with user programs, handle the window by HWND to determine the icon in the Hicon As Long' taskbar SZTIP AS STRING * 64 'icon prompt information end type' ************************************************ ******************************************** The control information of UFlags in the Notifyicondata structure in the Notifyicondata structure in Shell_Notifyicon *********************************************************** ********************** Public const nif_message = & h1 'nif_message represents send control messages; public const nif_icon = & h2' nif_icon represents icons in the display control bar; public Const nif_tip = & h4 'nif_tip indicates that the icon in the taskbar has a dynamic prompt.
'********************************************************** ************************ ** function name: addsystrayicon '** parameter: Trayicondata is a NOTIFYICONDATA type' ** function: add icon to System tray '** Return value: no' *************************************** ***************************************** PUBLIC FUNCTION ADDSYSTRAYICON (TRAYICONDATA AS NOTIFYICONDATA) Shell_notifyicon Nim_Add, TrayicondataEnd Function
'********************************************************** ************************ ** function name: delectSystrayicon '** parameter: trayicondata is notifyicondata type' ** function: delete system tray Icon '** Return Value: No' **************************************** **************************************** PUBLIC FUNCTION Deletesyicon (Trayicondata As Notifyiicondata) shell_notifyicon nim_delete, trayicondatand function '**** *********************************************************** ****************** '** Function Name: ModifySystrayicon' ** parameter: Trayicondata is the notifyicondata type '** function: modify the system pallet icon' ** return Value: No '**************************************************** ************************** PUBLIC FUNCONDATA AS NOTIFYICON (TRAYICONDATA AS NOTIMICONDATA) Shell_notifyicon Nim_Modify, TrayicondataEnd Function