Show Balloon Tooltip on the tray

zhaozj2021-02-16  48

The premise of running this example is that the system requires Windows 2000 OR XP (Shell Version 5 or Better). Everyone may be familiar with the tray program. I don't talk more here. This small code is just a new feature of the tray: Show Balloon Tooltip. As for what is balloon tooltip, just post the code to VB, you will see fresh effect, and remind you to pay attention to the operating environment!

1. Establish a standard EXE project, change the ICON of a PP for Form1, join a module, renamed SystractRaySystray.bas code:

Option ExplicitDeclare function shell_notifyicon lib "shell32.dll" alias _ "shell_notifyecona" (Byval DwMessage As Long, _ LPDATA AS Notifyicondata) AS Long

Public Type NOTIFYICONDATA cbSize As Long hwnd As Long uId As Long uFlags As Long uCallBackMessage As Long hIcon As Long szTip As String * 128 dwState As Long dwStateMask As Long szInfo As String * 256 uTimeoutOrVersion As Long 'Because there is no Union VB type, only Use long-type Szinfotitle As String * 64 dwinfoflags as longend type public const notifyicon_version = 3PUBLIC Const Notifyicon_OldVersion = 0

Public const nim_add = & h0public const nim_modify = & h1public const nim_delete = & h2

Public const nim_setfocus = & h3public const nim_setversion = & h4 public const nif_message = & h1public const nif_icon = & h2public const nif_tip = & h4

Public const nif_state = & h8public const nif_info = & h10 public const nis_hidden = & h1public const nis_sharedicon = & h2

Public const niif_none = & h0public const niif_warning = & h2public const niif_error = & h3public const niif_info = & h1

Public nficondata as Notifyicondata

2. Form1 code: Option Explicit

Private Sub Form_Load () with nficondata .cbsize = len (nficondata) .hwnd = me.hwnd .uid = vbnull .uflags = nif_info or nif_icon or nif_tip or nif_message .hicon = me.icon .sztip = "Your small message can be put Here ... "& vbnullchar .dwstate = 0 .dwStatemask = 0 .szinfo =" This is a balloon style tool-tip! Another tip can be applied "& chr (13) &" :) "& vbnullchar. UtimeoutorVersion = 15000 .szinfotitle = "Haha, see" & vbnullchar .dwinfoflags = niif_info endew withcall shell_notifyicon (nim_add, nficondata) End Sub

Private Sub Form_Unload (Cancel As Integer) Call Shell_notifyicon (Nim_Delete, nficondata) Endend Sub

This program code uses VB6 WIN2000 debugging

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

New Post(0)