Dim toolTip1 As New ToolTip()
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序開發(fā)、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了大邑縣免費建站歡迎大家使用!
toolTip1.AutoPopDelay = 5000 '顯示停留5秒
toolTip1.InitialDelay = 1000 '1秒后顯示
toolTip1.ReshowDelay = 500 '從一個控件移到另一個控件0.5秒后顯示
toolTip1.ShowAlways = True '在窗口不活動時也顯示
ToolTip1.SetToolTip(TextBox1, "提示內(nèi)容")
詳見:
可以建立一個方向向量用來存儲氣泡運動的方向(方向值每到一定時間隨機產(chǎn)生),再定義一個表示速度的變量(如果要的是均速運動速度值就不變,否則也可以隨機產(chǎn)生)。再用速度和方向值改變氣泡位置。
我可以做個例子(qq:359394386),但分不能太低。
這不是框,這是用
NotifyIcon 做的一個提示。就是一般常說的氣泡提示。
它能使用程序最小化后在任務(wù)欄的右下角顯示。
Option Explicit Const MAX_TOOLTIP As Integer = 64 Const NIF_ICON = H2 '刪除圖標(biāo) Const NIF_MESSAGE = H1 Const NIF_TIP = H4 Const NIM_ADD = H0 '添加圖標(biāo)到任務(wù)欄提示區(qū) Const NIM_DELETE = H2 Const WM_MOUSEMOVE = H200 Const WM_LBUTTONDOWN = H201 Const WM_LBUTTONUP = H202 Const WM_LBUTTONDBLCLK = H203 Const WM_RBUTTONDOWN = H204 Const WM_RBUTTONUP = H205 Const WM_RBUTTONDBLCLK = H206 Const SW_RESTORE = 9 Const SW_HIDE = 0 Private Type NOTIFYICONDATA cbSize As Long hwnd As Long uId As Long uFlags As Long ucallbackMessage As Long hIcon As Long szTip As String * MAX_TOOLTIP End Type 就是了
首先,你要找一個手型的圖標(biāo)文件(就是擴展名為ico的文件),然后用VB創(chuàng)建一個窗體,在窗體的屬性MouseIcon里面添加你準(zhǔn)備的ico文件,然后把屬性MousePoint的屬性值改成99-ccCustom,就可以了
這個……好像不是windows氣泡,是程序窗體。需要后臺進程觸發(fā)該窗體的發(fā)生。
如果要做windows氣泡,那比較簡單。windows氣泡比如說插入新硬件的提醒等。
我記得VB里有一個控件可以做進程,就是托盤顯示圖標(biāo)的那個控件可以做,但我不會用那個控件。
若是windows氣泡,我查得一個方案,你自己看看吧【注意,代碼中有行數(shù)標(biāo)號】
01 VERSION 5.00
02 Begin VB.Form Form1
03 Caption = "Form1"
04 ClientHeight = 3120
05 ClientLeft = 60
06 ClientTop = 420
07 ClientWidth = 4680
08 LinkTopic = "Form1"
09 ScaleHeight = 3120
10 ScaleWidth = 4680
11 StartUpPosition = 3 '窗口缺省
12 End
13 Attribute VB_Name = "Form1"
14 Attribute VB_GlobalNameSpace = False
15 Attribute VB_Creatable = False
16 Attribute VB_PredeclaredId = True
17 Attribute VB_Exposed = False
18 Option Explicit
19 '置前
20 Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X AsLong, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
21 '獲取鼠標(biāo)坐標(biāo)
22 Private Declare Function GetCursorPos Lib "User32" (lpPoint As POINTAPI) As Long
23 Private Type POINTAPI
24 X As Long
25 Y As Long
26 End Type
27 '添加托盤圖標(biāo)
28 Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
29 Const NIM_ADD = H0
30 Const NIM_MODIFY = H1
31 Const NIM_DELETE = H2
32 Const NIIF_GUID = H4
33 Const WM_MOUSEMOVE = H200
34 Const WM_RBUTTONUP = H205
35 Private Type NOTIFYICONDATA
36 cbSize As Long
37 hWnd As Long
38 uID As Long
39 uFlags As Long
40 uCallbackMessage As Long
41 hIcon As Long
42 szTip As String * 128
43 dwState As Long
44 dwStateMask As Long
45 szInfo As String * 256
46 Timeout As Long
47 szInfoTitle As String * 64
48 dwInfoFlags As Long
49 End Type
50 Private TuoPan As NOTIFYICONDATA
51 Private Sub Form_Load()
52 SetWindowPos Me.hWnd, -1, 0, 0, 0, 0, H10 Or H40 Or H2 Or H1 '置前
53 '添加托盤圖標(biāo)
54 With TuoPan
55 .cbSize = Len(TuoPan)
56 .hWnd = Me.hWnd
57 .uID = 0
58 .uCallbackMessage = WM_MOUSEMOVE
59 .uFlags = H2 Or H10 Or H1 Or H4
60 .hIcon = Me.Icon
61 .szTip = "小眼軟件" vbNullChar
62 End With
63 Shell_NotifyIcon NIM_ADD, TuoPan
64 DoEvents
65 '氣泡彈窗
66 TuoPan.szInfoTitle = "小眼軟件" Chr(0) '標(biāo)題
67 TuoPan.szInfo = "右擊這里可以彈出菜單?。?!" Chr(0) '內(nèi)容
68 TuoPan.dwInfoFlags = NIIF_GUID '氣泡圖標(biāo)
69 Shell_NotifyIcon NIM_MODIFY, TuoPan
70
71 '讓菜單窗體監(jiān)聽系統(tǒng)消息
72 PreWinProc = GetWindowLong(MenuForm.hWnd, GWL_WNDPROC)
73 SetWindowLong MenuForm.hWnd, GWL_WNDPROC, AddressOf WndProc
74 End Sub
75 Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
76 Dim lMsg As Single
77 lMsg = X / Screen.TwipsPerPixelX
78 If lMsg = WM_RBUTTONUP Then
79 Dim MenuLT As POINTAPI
80 GetCursorPos MenuLT
81 MenuForm.Move MenuLT.X * 15 - MenuForm.Width, MenuLT.Y * 15 - MenuForm.Height
82 MenuForm.Show , Me
83 End If
84 End Sub
85 Private Sub Form_Unload(Cancel As Integer)
86 Shell_NotifyIcon NIM_DELETE, TuoPan '刪除托盤圖標(biāo)
87 SetWindowLong Me.hWnd, GWL_WNDPROC, PreWinProc '卸載監(jiān)聽
88 End
89 End Sub
原文地址:
msgbox ““