cs_epson1
Messages postés89Date d'inscriptiondimanche 12 novembre 2000StatutMembreDernière intervention29 mars 2013
-
15 juin 2007 à 02:27
cs_epson1
Messages postés89Date d'inscriptiondimanche 12 novembre 2000StatutMembreDernière intervention29 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)
cavo789
Messages postés168Date d'inscriptionvendredi 9 janvier 2004StatutMembreDernière intervention28 juillet 20091 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
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