Bulle sortant d'icone
Publié : mer. 01/déc./2010 11:38
comment faire pour faire une bulle d'une icone se trouvant dans le system tray, et y afficher du texte?
c'est quoi?case a écrit :cherche du coté des tooltypes peut être
venom a écrit :tu lance purebasic et tu fait F1 c'est le béaba dans la programmation![]()
@++
Code : Tout sélectionner
Procedure GetTaskBarPosition(*TaskBarRect.RECT = 0)
Protected TaskBarArea.RECT, TaskBar_Hwnd.l, Find_Hwnd.l, Find_Class.s, ScreenH.l, TaskBarPosition.l
#TaskBar_Down = 0
#TaskBar_Up = 1
#TaskBar_Left = 2
#TaskBar_Right = 3
TaskBarPosition = -1
; On recherche la barre des taches
TaskBar_Hwnd = 0
Find_Hwnd.l = FindWindow_(0, 0)
While Find_Hwnd <> 0 And TaskBar_Hwnd = 0
Find_Class.s = Space(255)
GetClassName_(Find_Hwnd, @Find_Class, 256)
If Find_Class = "Shell_TrayWnd"
TaskBar_Hwnd = Find_Hwnd
EndIf
Find_Hwnd = GetWindow_(Find_Hwnd, #GW_HWNDNEXT)
Wend
If TaskBar_Hwnd
; Taille de la barre des taches
GetWindowRect_(TaskBar_Hwnd, @TaskBarArea)
; Taille de l'écran
If ExamineDesktops()
ScreenH = DesktopHeight(0)
If 0 >= TaskBarArea\left And 0 <= TaskBarArea\right ; Si la barre touche la gauche de l'écran
If 0 >= TaskBarArea\top And 0 <= TaskBarArea\bottom And ScreenH >= TaskBarArea\top And ScreenH <= TaskBarArea\bottom ; Barre verticale à gauche, on touche le bord haut et bas de l'écran
TaskBarPosition = #TaskBar_Left
ElseIf 0 >= TaskBarArea\top And 0 <= TaskBarArea\bottom ; On touche le bord haut de l'écran
TaskBarPosition = #TaskBar_Up
Else ; Sinon, on touche uniquement le bord bas
TaskBarPosition = #TaskBar_Down
EndIf
Else ; Barre verticale à droite
TaskBarPosition = #TaskBar_Right
EndIf
EndIf
If *TaskBarRect <>0
CopyMemory(@TaskBarArea, *TaskBarRect, SizeOf(RECT))
EndIf
EndIf
ProcedureReturn TaskBarPosition
EndProcedure
Procedure NotificationWindow(Window, Space = 0)
Protected TaskBarArea.RECT, TaskBarPosition.l, ScreenH.l, ScreenW.l
StickyWindow(Window, 1)
SetWindowLong_(WindowID(Window), #GWL_EXSTYLE, GetWindowLong_(WindowID(Window), #GWL_EXSTYLE) | #WS_EX_TOOLWINDOW)
TaskBarPosition = GetTaskBarPosition(@TaskBarArea)
; Juste pour voir le retour de la fonction
CompilerIf #PB_Compiler_Debugger
Select TaskBarPosition
Case #TaskBar_Down
Debug "Barre des taches en bas"
Case #TaskBar_Up
Debug "Barre des taches en haut"
Case #TaskBar_Left
Debug "Barre des taches à gauche"
Case #TaskBar_Right
Debug "Barre des taches à droite"
Default
Debug "Erreur"
EndSelect
Debug "Position de la barre des taches"
Debug TaskBarArea\left
Debug TaskBarArea\right
Debug TaskBarArea\top
Debug TaskBarArea\bottom
Debug ""
CompilerEndIf
; Taille de l'écran
If ExamineDesktops()
ScreenH = DesktopHeight(0)
ScreenW = DesktopWidth(0)
EndIf
; On déplace la fenêtre pour la mettre proche de la zone de notification
Select TaskBarPosition
Case #TaskBar_Down
ResizeWindow(Window, ScreenW - Space - WindowWidth(Window), TaskBarArea\top - Space - WindowHeight(Window), #PB_Ignore, #PB_Ignore)
Case #TaskBar_Up
ResizeWindow(Window, ScreenW - Space - WindowWidth(Window), TaskBarArea\bottom + Space, #PB_Ignore, #PB_Ignore)
Case #TaskBar_Left
ResizeWindow(Window, TaskBarArea\right + Space, ScreenH - Space - WindowHeight(Window), #PB_Ignore, #PB_Ignore)
Case #TaskBar_Right
ResizeWindow(Window, TaskBarArea\left - Space - WindowWidth(Window), ScreenH - Space - WindowHeight(Window), #PB_Ignore, #PB_Ignore)
EndSelect
HideWindow(Window, 0)
EndProcedure
; Création de la fenêtre et de la GadgetList
If OpenWindow(0, 0, 0, 150, 150, "Test", #PB_Window_BorderLess | #PB_Window_Invisible) = 0
End
EndIf
NotificationWindow(0, 10)
; une petite image sur la fenêtre pour faire jolie
CreateImage(0, WindowWidth(0), WindowHeight(0))
StartDrawing(ImageOutput(0))
Box(1, 1, WindowWidth(0) - 2, WindowHeight(0) - 2, $FFFFFF)
StopDrawing()
ImageGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), ImageID(0))
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
Select EventMenu() ; Menus
EndSelect
Case #PB_Event_Gadget
Select EventGadget() ; Gadgets
Case 0
Select EventType()
Case #PB_EventType_LeftClick
Event = #PB_Event_CloseWindow ; On ferme
EndSelect
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
End