Iconisation dans la barre des tâches.

Résolu
Mood_ Messages postés 8 Date d'inscription jeudi 11 août 2005 Statut Membre Dernière intervention 2 septembre 2005 - 1 sept. 2005 à 21:04
Mood_ Messages postés 8 Date d'inscription jeudi 11 août 2005 Statut Membre Dernière intervention 2 septembre 2005 - 2 sept. 2005 à 10:54
Bonjour à tous !



J'aimerais savoir si il est possible de faire pour qu'un programme se mette en icone dans la barre des tâche en bas à droite.



Si c'est possible qu'elle est la procédure à suivre ?



Merci d'avance.

3 réponses

philippe laschweng 1 Messages postés 278 Date d'inscription jeudi 14 avril 2005 Statut Membre Dernière intervention 13 avril 2013 2
2 sept. 2005 à 08:06
Dans un module :
'type défini par l'utilisateur requis par Shell_NotifyIcon API call
Public 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


'constantes requises par l'appel API Shell_NotifyIcon :
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201 'Button down
Public Const WM_LBUTTONUP = &H202 'Button up
Public Const WM_LBUTTONDBLCLK = &H203 'Double-click
Public Const WM_RBUTTONDOWN = &H204 'Button down
Public Const WM_RBUTTONUP = &H205 'Button up
Public Const WM_RBUTTONDBLCLK = &H206 'Double-click


Public Declare Function SetForegroundWindow Lib "user32" _
(ByVal hwnd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean


Public nid As NOTIFYICONDATA


Sur ta Form principale :
Private Sub Form_Load()
'la forme doit être entièrement visible avant d'appeler Shell_NotifyIcon
Me.Show
Me.Refresh
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 = "Compteur horaire" & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, nid
End Sub


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'cette procédure reçoit les rappels de l'icône de barre d'état système.
Dim Result As Long
Dim msg As Long
'the value of X will vary depending upon the scalemode setting
If Me.ScaleMode = vbPixels Then
msg = X
Else
msg = X / Screen.TwipsPerPixelX
End If
Select Case msg
Case WM_LBUTTONUP '514 restore form window

Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
Case WM_LBUTTONDBLCLK '515 restore form window
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
Case WM_RBUTTONUP '517 display popup menu
Result = SetForegroundWindow(Me.hwnd)
PopupMenu mpop 'NOM du menu créer dans le 'créateur de menus' ==> menu Outils
End Select
End Sub


Private Sub Form_Resize()
'Nécessaire pour assurer que la fenêtre réduite soit masquée
If Me.WindowState = vbMinimized Then Me.Hide
End Sub


Private Sub Form_Unload(Cancel As Integer)
'cela supprime l'icône de la barre d'état système
Shell_NotifyIcon NIM_DELETE, nid
End Sub


Private Sub mPopExit_Click()
'appelée quand l'utilisateur clique sur le menu contextuel Exit command
'Faut pas mettre End sinon l'icône peut rester dans le Systray une fois l'appli fermée
Unload Me
End Sub


Private Sub mPopRestore_Click()
'appelée quand l'utilisateur clique sur le menu contextuel Restore command
Me.WindowState = vbNormal
Result = SetForegroundWindow(Me.hwnd)
Me.Show
End Sub

mPopExit et mPopestore sont dans un menu de la Form (créateur de menu)

Le code fonctionne nickel et est issu de microsoft. Essayes et dis moi si tu as des problèmes (compréhension ou logicielle). Y'ara peut être des petits changements !

En espérant t'aider !
3
cs_hassen Messages postés 338 Date d'inscription mardi 28 janvier 2003 Statut Membre Dernière intervention 4 novembre 2008
1 sept. 2005 à 21:26
il existe plusieur source sur vbfrance qui traite le sujet. et ca s'appelle un Tray
fait une recherche sur "tray" ou "tray icon" et tu trouvera des sources qui t'explique
comment faire


Hassen TUNISIE
0
Mood_ Messages postés 8 Date d'inscription jeudi 11 août 2005 Statut Membre Dernière intervention 2 septembre 2005
2 sept. 2005 à 10:54
Merci vous m'avez bien aidé
0
Rejoignez-nous