@microdevweb : j'ai de nouveau modifié le code que tu connais déja de telle manière que si un utilisateur cache la fenêtre de l'application, une infobulle en zone de notification rappelle à l'utilisateur quelle est la touche à presser pour faire apparaître de nouveau cette fenêtre.
Code : Tout sélectionner
Enumeration
#Mainform
#MenuPopUp
#Time
#StartTime
#ElapsedTime
#NOTIFYICONDATA_V4_SIZE = 508
EndEnumeration
;NOTIFYICONDATA structure
;http://msdn.microsoft.com/en-us/library/windows/desktop/bb773352(v=vs.85).aspx
Structure NOTIFYICONDATA_
cbSize.l
hwnd.i
uId.l
uFlags.l
uCallbackMessage.l
hIcon.i
StructureUnion
szTip.c[64]
szTipEx.c[128]
EndStructureUnion
dwState.l
dwStateMask.l
szInfo.c[256]
StructureUnion
uTimeout.l
uVersion.l
EndStructureUnion
szInfoTitle.c[64]
dwInfoFlags.l
guidItem.GUID
hBalloonIcon.i
EndStructure
Global MainformStatus.b
;Le temps qui passe
Procedure Compte_Temps()
SetGadgetText(#Time, FormatDate("%hh:%ii:%ss", Date()))
SetGadgetData(#Time, Date())
SetGadgetText(#ElapsedTime, FormatDate("%hh:%ii:%ss", GetGadgetData(#Time)-GetGadgetData(#StartTime)))
EndProcedure
;Afficher un message dans la zone de notification (By : em_uk)
Procedure SysTrayIconBalloon_(uId, hWindow, Title$, Message$, timeOut, flags)
Protected nId.NOTIFYICONDATA_
If OSVersion() >= #PB_OS_Windows_Vista
nId\cbSize = #NOTIFYICONDATA_V3_SIZE
ElseIf OSVersion() >= #PB_OS_Windows_XP
nId\cbSize = #NOTIFYICONDATA_V3_SIZE
ElseIf OSVersion() >= #PB_OS_Windows_2000
nId\cbSize = #NOTIFYICONDATA_V2_SIZE
Else
nId\cbSize = #NOTIFYICONDATA_V1_SIZE
EndIf
If nId\cbSize
nId\uVersion = 4
Shell_NotifyIcon_(#NIM_SETVERSION, @nId)
nId\uId = uId
nId\hwnd = hWindow
nId\dwInfoFlags = flags
nId\uFlags = #NIF_INFO
nId\uTimeout = timeOut
PokeS(@nId\szInfo, Message$, SizeOf(nId\szInfo))
PokeS(@nId\szInfoTitle, Title$, SizeOf(nId\szInfoTitle))
ProcedureReturn Shell_NotifyIcon_(#NIM_MODIFY, @nId)
EndIf
ProcedureReturn #False
EndProcedure
;Affiche ou chache la fenetre
Procedure ShowHideWindow(*Value)
Repeat
If GetAsyncKeyState_(#VK_F8) & $1 ;Touche F8
If MainformStatus = #False
HideWindow(#MainForm, #False)
MainformStatus = #True
Else
HideWindow(#Mainform, #True)
MainformStatus = #False
SysTrayIconBalloon_(1, WindowID(#Mainform),"Information","Touche F8 pour Pour afficher la fenetre", 50, #NIIF_INFO)
EndIf
EndIf
ForEver
EndProcedure
MainformStatus=#True
OpenWindow(#MainForm, 100, 150, 300, 150, "SysTray Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreatePopupMenu(#MenuPopUp)
MenuItem(0, "Afficher la fenetre")
MenuItem(1, "Quitter")
TextGadget(#PB_Any, 10, 20, 80, 20, "Il est")
StringGadget(#Time,100, 20, 80, 24, "00:00:00")
TextGadget(#PB_Any, 10, 45, 80, 20, "Début")
StringGadget(#StartTime,100, 45, 80, 24, "00:00:00")
TextGadget(#PB_Any, 10, 75, 80, 20, "Temps passé")
StringGadget(#ElapsedTime,100, 75, 80, 24, "00:00:00")
AddSysTrayIcon(1, WindowID(#Mainform), LoadIcon_(#Null, #IDI_WARNING))
SysTrayIconToolTip(1, "Touche F8" +#CRLF$+ "Pour afficher la fenetre")
AddWindowTimer(#Mainform, 123, 100)
CreateThread(@ShowHideWindow(), #Null)
;Initialisation de l'heure de début d"exécution
SetGadgetText(#StartTime, FormatDate("%hh:%ii:%ss", Date()))
SetGadgetData(#StartTime, Date())
TextGadget(#PB_Any, 10, 120, 280, 20, "Touche F8 pour cacher/afficher la fenêtre")
Repeat
Event = WaitWindowEvent(100)
If Event = #PB_Event_Timer And EventTimer() = 123
Compte_Temps()
EndIf
Select Event
Case #PB_Event_Menu
Select EventMenu()
Case 0
HideWindow(#Mainform, #False)
Case 1
End
EndSelect
Case #PB_Event_SysTray
If EventType() = #PB_EventType_LeftDoubleClick
HideWindow(#Mainform, #False)
EndIf
If EventType() = #PB_EventType_RightClick
DisplayPopupMenu(#MenuPopUp, WindowID(#Mainform))
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
ForEver