Systray

Résolu
cs_epson1 Messages postés 89 Date d'inscription dimanche 12 novembre 2000 Statut Membre Dernière intervention 29 mars 2013 - 15 juin 2007 à 02:27
cs_epson1 Messages postés 89 Date d'inscription dimanche 12 novembre 2000 Statut Membre Dernière intervention 29 mars 2013 - 22 juin 2007 à 22:51
Bonjours à tous,

J'ai une question toute bête :

Est-il possible de placer une icone dans le systray,  à droite de l'horloge ?

(De l'autre coté de l'horloge, à l'opposé des autres icones, au bord de l'écran, en fait)

Si quelqu'un à un tuyau ...

Merci d'avance pour vos réponses .

4 réponses

Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
15 juin 2007 à 05:31
non....

pas de manière simple, en tous cas

Renfield
Admin CodeS-SourceS- MVP Visual Basic
3
cavo789 Messages postés 168 Date d'inscription vendredi 9 janvier 2004 Statut Membre Dernière intervention 28 juillet 2009 1
18 juin 2007 à 07:33
Bonjour.  

Une piste :

Public Sub ShellTrayAdd()

   On Error Resume Next

   With TrayIcon
      .cbSize = Len(TrayIcon)
      .hWnd = frmShop.hWnd
      .uID = APP_SYSTRAY_ID
      .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
      .uCallbackMessage = WM_MOUSEMOVE
      .hIcon = frmMain.Icon
      .szTip = App.Title & Chr$(0) ' Text of the tooltip
   End With
  
   Call Shell_NotifyIcon(NIM_ADD, TrayIcon)
   
   DoEvents
   
   On Error GoTo 0
   
End Sub
 , ----
(Coloration syntaxique automatique par Kenji)

Tu peux appeller cette procédure lors du chargement de ta fenêtre.   La gestion du clic sur l'icône depuis le Systray se fait via le Form_OnMouseMove.
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
   
Dim Message As Long

   Message = x / Screen.TwipsPerPixelX

   Select Case Message
   
      ' If the user make a double-clic on the trayicon, show the main form of the Shop
         
      Case WM_LBUTTONUP:
         
         Call mnuOpen_Click         
         
      Case WM_RBUTTONUP:

         ' Right clic.  Show a popup menu called mnuTrayPanel
               
         PopupMenu mnuTrayPanel, , , , mnuQuit
               
      Case NIN_BALLOONSHOW
                  
         'Debug.Print "The balloon tip has just appeared"
                            
      Case NIN_BALLOONHIDE
                  
         'Debug.Print "The systray icon was removed when the balloon tip was displayed"
                            
      Case NIN_BALLOONUSERCLICK

         ' The user clicked on the balloon tip.   
               
      Case NIN_BALLOONTIMEOUT
                  
         'Debug.Print "The balloon tip timed-out without the user clicking it, or the user " & _
            "clicked the balloon tip's close button"
      
   End Select
   
End Sub

Pour retirer l'icône, appelle la subroutine ci-dessous

Public Sub ShellTrayRemove()

   On Error Resume Next
  
   Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)
   
   DoEvents
   
   On Error GoTo 0

End Sub 

Quelques constantes, déclarations utilisées

Public Const APP_SYSTRAY_ID = 73218999  'unique identifier

Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const NIF_STATE = &H8

Private Const NIF_INFO = &H10

Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIM_SETFOCUS = &H3
Public Const NIM_SETVERSION = &H4
Public Const NIM_VERSION = &H5

Private Type GUID
   Data1 As Long
   Data2 As Integer
   Data3 As Integer
   Data4(7) As Byte
End Type

Public Type NOTIFYICONDATA
  cbSize As Long
  hWnd As Long
  uID As Long
  uFlags As Long
  uCallbackMessage As Long
  hIcon As Long
  szTip As String * 128
  dwState As Long
  dwStateMask As Long
  szInfo As String * 256
  uTimeoutAndVersion As Long
  szInfoTitle As String * 64
  dwInfoFlags As Long
  guidItem As GUID
End Type

Public Enum IconTrayType
   NoIcon = 0
   Info = 1
   Warning = 2
   Error = 3
End Enum

'shell version / NOTIFIYICONDATA struct size constants

Private Const NOTIFYICONDATA_V1_SIZE As Long = 88  'pre-5.0 structure size
Private Const NOTIFYICONDATA_V2_SIZE As Long = 488 'pre-6.0 structure size
Private Const NOTIFYICONDATA_V3_SIZE As Long = 504 '6.0+ structure size
   
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal Message As Long, _
   Data As NOTIFYICONDATA) As Boolean

Christophe
3
cs_epson1 Messages postés 89 Date d'inscription dimanche 12 novembre 2000 Statut Membre Dernière intervention 29 mars 2013
15 juin 2007 à 14:41
Ok, merci Renfield .

@+
0
cs_epson1 Messages postés 89 Date d'inscription dimanche 12 novembre 2000 Statut Membre Dernière intervention 29 mars 2013
22 juin 2007 à 22:51
Wouaou !!! merci Cavo789.

Désolé pour le délai mais ça fait 3 jours que je me bat avec mon dur qui a laché.

Je vais decortiquer tout ça et tâcher de comprendre.

Encore merci et bravo surtout que je ne pensais pas vraiment que c'était possible.

J'éssaye et je reviens.

@+ et bonne prog
0
Rejoignez-nous