ze5400 Skrevet 5. november 2004 Del Skrevet 5. november 2004 Hvordan får man et program til å legge seg i systrayen når man trykker minimize knappen? Lenke til kommentar
kaffenils Skrevet 5. november 2004 Del Skrevet 5. november 2004 Her er et eksempel som viser et systray ikon når form1 minimeres, og ved klikk på systray ikonet så normaliseres form1 og systray ikone skjules igjen. Option Explicit ' Constants required by Shell_NotifyIcon API call Private Const NIM_ADD = &H0 Private Const NIM_MODIFY = &H1 Private Const NIM_DELETE = &H2 Private Const NIF_MESSAGE = &H1 Private Const NIF_ICON = &H2 Private Const NIF_TIP = &H4 Private Const WM_MOUSEMOVE = &H200 Private Const WM_LBUTTONDOWN = &H201 'Button down Private Const WM_LBUTTONUP = &H202 'Button up Private Const WM_LBUTTONDBLCLK = &H203 'Double-click Private Const WM_RBUTTONDOWN = &H204 'Button down Private Const WM_RBUTTONUP = &H205 'Button up Private Const WM_RBUTTONDBLCLK = &H206 'Double-click 'API call Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hwnd As Long) As Long Private Declare Function Shell_NotifyIcon Lib "shell32" _ Alias "Shell_NotifyIconA" _ (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean Const WM_NCLBUTTONDOWN = &HA1 Const HTCAPTION = 2 'variable declaration Private nid As NOTIFYICONDATA 'User defined type required by Shell_NotifyIcon API call Private Type NOTIFYICONDATA cbSize As Long hwnd As Long uId As Long uFlags As Long uCallBackMessage As Long hIcon As Long szTip As String * 64 End Type Private Sub Form_Load() With nid .cbSize = Len(nid) .hwnd = Me.hwnd .uId = vbNull .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE .uCallBackMessage = WM_MOUSEMOVE .hIcon = Me.Icon .szTip = App.ProductName & " " & App.Major & "." & App.Minor & ", Build " & App.Revision & vbNullChar End With End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'You can use the Hex of the X coord to findout if 'there was any MouseButton activity '2D represents a Left Button Double Click '0F represents mouse down (zero) '1E represents mouse up If Right(Hex(X), 2) = "0F" Then WindowState = vbNormal Me.Visible = True End If End Sub Private Sub Form_Resize() If WindowState = vbMinimized Then Shell_NotifyIcon NIM_ADD, nid Me.Visible = False Else Shell_NotifyIcon NIM_DELETE, nid End If End Sub Private Sub Form_Unload(Cancel As Integer) Shell_NotifyIcon NIM_DELETE, nid End Sub Lenke til kommentar
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå