Soyez le premier à donner votre avis sur cette source.
Vue 13 196 fois - Téléchargée 604 fois
'Dans le Form Option Explicit Private Sub Form_Load() InstalleHookSystray Me.HWnd IconeT.cbSize = Len(IconeT) IconeT.HWnd = Me.HWnd IconeT.uID = 1& IconeT.uFlags = ICONE Or TIP Or MESSAGE IconeT.uCallbackMessage = MOUSEMOVE IconeT.hIcon = Form1.Icon Shell_NotifyIcon AJOUT, IconeT End Sub Private Sub Form_Unload(Cancel As Integer) DesinstalleHookSystray Me.HWnd Shell_NotifyIcon SUPPRIME, IconeT End Sub 'Et dans le module Option Explicit 'APIs de Hook Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal HWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal HWnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long 'API systray Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As IconeTray) As Boolean Public Type IconeTray cbSize As Long HWnd As Long uID As Long uFlags As Long uCallbackMessage As Long hIcon As Long szTip As String * 64 End Type Public Const AJOUT = &H0 Public Const SUPPRIME = &H2 Public Const MOUSEMOVE = &H200 Public Const MESSAGE = &H1 Public Const ICONE = &H2 Public Const TIP = &H4 Private Const GWL_WNDPROC = (-4) Dim m_TaskbarCreated As Long Dim Save_WndProc_Adresse As Long Public IconeT As IconeTray Public Sub InstalleHookSystray(lHwnd As Long) 'On installe un Hook sur le message TaskbarCreated m_TaskbarCreated = RegisterWindowMessage("TaskbarCreated") Save_WndProc_Adresse = SetWindowLong(lHwnd, GWL_WNDPROC, AddressOf Capture_Message_Windows) End Sub Public Sub DesinstalleHookSystray(lHwnd As Long) SetWindowLong lHwnd, GWL_WNDPROC, Save_WndProc_Adresse End Sub Private Function Capture_Message_Windows(ByVal HWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long 'Si le message correspond alors on recrée l'icône If uMsg = m_TaskbarCreated Then Shell_NotifyIcon AJOUT, IconeT End If Capture_Message_Windows = CallWindowProc(Save_WndProc_Adresse, HWnd, uMsg, wParam, lParam) End Function
5 mai 2008 à 10:37
5 mai 2008 à 10:36
libre a vous, en fait...
4 mai 2008 à 11:02
Si vous utilisez un ctrl ToolBar utilisez un picturebox pour le hwnd sinon les cliques sur l'icone du systray ne seront pas percu. Enfin, moi c'est tout que j'ai trouvé comme alternative...
Bonne prog,
@+ JLN
26 mars 2008 à 10:23
Sinon, autre petit truc au niveau du menu que l'on affiche lors du click sur l'icon dans dans le systray : par defaut, une fois affiché, il faut absolument cliquer sur un item du menu pour le faire disparaitre. Pour réglé ce problème, dans la rocedure Form_MouseMove, ajouter "SetForegroundWindow Me.Hwnd" juste avant l'appel de "Me.PopupMenu Me.MnuSysTray..."
Exemple :
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case X / Screen.TwipsPerPixelX
Case BOUTON_CLICK_DROIT:
Call MnuHelp_Click
Case BOUTON_CLICK_GAUCHE:
SetForegroundWindow Me.Hwnd
Me.PopupMenu Me.MnuSysTray, , , , Me.MnuHelp
End Select
End Sub
A+ Patrick
4 févr. 2007 à 17:19
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.