Global NI As NOTIFYICONDATAPrivate Sub Form_Resize() If IsIconic(Me.hwnd) Then Me.Hide Timer1.Enabled = True Timer2.Enabled = False NI.cbSize = Len(NI) NI.hwnd = Picture1.hwnd NI.uID = 0 NI.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP NI.uCallbackMessage = WM_MOUSEMOVE NI.hIcon = Me.Icon NI.szTip = "abcdefg" + Chr(0) Do NI.uID = NI.uID + 1 Result = Shell_NotifyIconA(NIM_ADD, NI) Loop While Result = 0 Else Me.Width = 4410 Me.Height = 1860 Result = Shell_NotifyIconA(NIM_DELETE, NI) Timer2.Enabled = True Timer1.Enabled = False Image1.Left = 3930 End If End Sub
VB光盘里有个systray控件。这个问题我在这里告诉过大家好多次了。
老问题 Shell_NotifyIconA的前面没有空格Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
If IsIconic(Me.hwnd) Then
Me.Hide
Timer1.Enabled = True
Timer2.Enabled = False
NI.cbSize = Len(NI)
NI.hwnd = Picture1.hwnd
NI.uID = 0
NI.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
NI.uCallbackMessage = WM_MOUSEMOVE
NI.hIcon = Me.Icon
NI.szTip = "abcdefg" + Chr(0)
Do
NI.uID = NI.uID + 1
Result = Shell_NotifyIconA(NIM_ADD, NI)
Loop While Result = 0
Else
Me.Width = 4410
Me.Height = 1860
Result = Shell_NotifyIconA(NIM_DELETE, NI)
Timer2.Enabled = True
Timer1.Enabled = False
Image1.Left = 3930
End If
End Sub
Shell_NotifyIconA的前面没有空格Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long