Code : Tout sélectionner
;Mon lanceur applis
;créé et conçu par Micoute
;le 15 mars 2025 ave PB 6.20 (x64)
EnableExplicit
Enumeration Fenetres
#Fenetre_principale
EndEnumeration
Enumeration Gadgets
#Lst_Applications
#Btn_Lancer
EndEnumeration
Enumeration Polices
#police
EndEnumeration
Structure Application
Nom.s
Chemin.s
EndStructure
Global NewList Applications.Application()
Global Evenement, Index, Nom.s, Chemin.s, NbElements, HauteurElement, HauteurTotale
;- Init position
ExamineDesktops()
Global Xmax = DesktopWidth(0)
Global LargeurInterface = 300
DataSection
Donnees:
;Mettre les données Nom et chemin dans les lignes de Datas
Data$ "", ""
Data$ "999","999"
EndDataSection
Procedure ChargerDonnees()
Restore Donnees
Repeat
Read.s Nom
Read.s Chemin
If Nom = "999" And Chemin = "999"
Break
EndIf
AddElement(Applications())
Applications()\Nom = Nom
Applications()\Chemin = Chemin
ForEver
SortStructuredList(Applications(), #PB_Sort_Ascending, OffsetOf(Application\Nom), TypeOf(Application\Nom))
EndProcedure
Procedure LancerApplication(Chemin.s)
If FindString(Chemin, "http", 1)
RunProgram("explorer.exe", Chemin, "")
ElseIf FileSize(Chemin) > 0
RunProgram(Chemin)
Else
MessageRequester("Erreur", "Fichier introuvable : " + Chemin, #PB_MessageRequester_Error)
EndIf
EndProcedure
LoadFont(#police, "FontAwesome", 12, #PB_Font_Bold)
SetGadgetFont(#PB_Default, FontID(#police))
If OpenWindow(#Fenetre_principale, Xmax-LargeurInterface-10, 0, 300, 375, "Mon menu applis diabète")
ListViewGadget(#Lst_Applications, 10, 10, 280, 320)
ButtonGadget(#Btn_Lancer, 100+10, 340, 100, 25, "Lancer")
ChargerDonnees()
; Définir taille dynamique du ListViewGadget()
NbElements = 0
ForEach Applications()
AddGadgetItem(#Lst_Applications, -1, Applications()\Nom)
NbElements + 1
Next
; Ajuster la hauteur du ListView en fonction du nombre d'éléments
HauteurElement = 17 ; Approximatif, ajustez selon FontAwesome
HauteurTotale = NbElements * HauteurElement
; Limiter la hauteur maximale à la taille originale (320)
If HauteurTotale > 320
HauteurTotale = 320
EndIf
ResizeGadget(#Lst_Applications, #PB_Ignore, #PB_Ignore, #PB_Ignore, HauteurTotale)
ResizeGadget(#Btn_Lancer, #PB_Ignore, GadgetHeight(#Lst_Applications) + 20, #PB_Ignore, #PB_Ignore)
ResizeWindow(#Fenetre_principale, #PB_Ignore, #PB_Ignore, #PB_Ignore,GadgetHeight(#Lst_Applications) + 55)
Repeat
Evenement = WaitWindowEvent()
If Evenement = #PB_Event_Gadget And EventGadget() = #Btn_Lancer ; Bouton "Lancer" cliqué
Index = GetGadgetState(#Lst_Applications)
If Index >= 0
SelectElement(Applications(), Index)
LancerApplication(Applications()\Chemin)
Else
MessageRequester("Attention", "Veuillez sélectionner une application.")
EndIf
EndIf
Until Evenement = #PB_Event_CloseWindow
EndIf