bah , c'est surtout parceque tu ne capte que TV BreizhOllivier a écrit :Je n'ai pas la TV mais ton code est utile pour la création conviviale de liens sur Internet. Bon travail Chris!

Code : Tout sélectionner
;{- Enumérations
Enumeration
#Win_Channel
#Window_0
EndEnumeration
Enumeration
;/ Fenêtre principale
#Web_1
#Adresse
#Btn_Add_Button
#Btn_Add_Current
;/ Ajoute
#Cont
#Btn_Add_Channel
#Frm_0
#Str_Add_Url
#Str_Add_Channel
#Txt_0
#Txt_1
;/ Supprime / Modifie
#Btn_Mod_Channel
#Btn_DelChannel
#Btn_Up
#Btn_Down
#Cmb_Channels
#Frm_1
;/ Navigation
#Btn_Fresh
#Btn_Home
#Btn_Next
#Btn_Prev
#Btn_Stop
EndEnumeration
;}
;{- Structures
Structure BOUTON
IdBouton.l
xBouton.l
yBouton.l
wBouton.l
hBouton.l
txtBouton.s
UrlBouton.s
EndStructure
;}
;{- Global (Variables, Tableaux, Listes)
Global NewList Boutons.BOUTON()
Global WebFlag
;}
Declare MakeImage(Lettre.s, Fonte.s, Taille, L_Bout, H_Bout)
;{- Procédures
Procedure OpenWindow_Win_Main()
If OpenWindow(#Window_0, 431, 152, 815, 520, "Programmes TV", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ButtonImageGadget(#Btn_Prev, 5, 5, 25, 25, MakeImage("Å", "WingDings", 150, 25, 25)) : GadgetToolTip(#Btn_Prev, "Aller à la page Précédente")
ButtonImageGadget(#Btn_Next, 30, 5, 25, 25, MakeImage("Æ", "WingDings", 150, 25, 25)) : GadgetToolTip(#Btn_Next, "Aller à la page Suivante")
ButtonImageGadget(#Btn_Home, 55, 5, 25, 25, MakeImage("H", "WebDings", 150, 25, 25)) : GadgetToolTip(#Btn_Home, "Aller à la page d'Accueil")
ButtonImageGadget(#Btn_Stop, 80, 5, 25, 25, MakeImage("r", "WebDings", 150, 25, 25)) : GadgetToolTip(#Btn_Stop, "Arreter le chargement")
ButtonImageGadget(#Btn_Fresh, 105, 5, 25, 25, MakeImage("q", "WebDings", 150, 25, 25)) : GadgetToolTip(#Btn_Fresh, "Recharger la page actuelle")
ButtonImageGadget(#Btn_Add_Current, 135, 5, 25, 25, MakeImage("+", "Arial", 200, 25, 25)) : GadgetToolTip(#Btn_Add_Current, "Ajouter l'adresse de la page à la liste des chaines")
WebGadget(#Web_1, 135, 35, 675, 480, "http://www.programme-tv.net")
StringGadget(#Adresse, 165, 5, 645, 25, "", #PB_String_ReadOnly)
ScrollAreaGadget(#Cont, 0, 35, 130, 520, 110, 500, 1, #PB_ScrollArea_Raised)
ButtonImageGadget(#Btn_Add_Button, 5, 5, 95, 20, MakeImage("Modif/Suppr", "Arial", 80, 95, 20)) : GadgetToolTip(#Btn_Add_Button, "Opérations sur la liste de chaines")
CloseGadgetList()
EndIf
AddKeyboardShortcut(#Window_0, #PB_Shortcut_Left, 0)
AddKeyboardShortcut(#Window_0, #PB_Shortcut_Right, 1)
AddKeyboardShortcut(#Window_0, #PB_Shortcut_F5, 2)
AddKeyboardShortcut(#Window_0, #PB_Shortcut_Control|#PB_Shortcut_Add, #Btn_Add_Current)
EndIf
SetWindowColor(#Window_0, $80FF9C)
SetGadgetColor(#Cont, #PB_Gadget_BackColor, $80FF9C)
SetGadgetColor(#Adresse, #PB_Gadget_BackColor, $BFFFCE)
SetGadgetColor(#Adresse, #PB_Gadget_FrontColor, $008000)
SetGadgetFont(#Adresse, LoadFont(10, "Arial", 14))
EndProcedure
Procedure Open_Win_Channels()
If OpenWindow(#Win_Channel, 45, 45, 395, 180, "Ajouter / Supprimer une chaine", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Win_Channel))
Frame3DGadget(#Frm_0, 5, 5, 385, 100, "Ajouter une chaine")
TextGadget(#Txt_0, 10, 30, 35, 15, "Nom") : StringGadget(#Str_Add_Channel, 45, 25, 340, 20, "", #PB_String_UpperCase)
TextGadget(#Txt_1, 10, 55, 35, 15, "Url") : StringGadget(#Str_Add_Url, 45, 50, 340, 20, "")
ButtonGadget(#Btn_Add_Channel, 285, 80, 100, 20, "Ajouter")
Frame3DGadget(#Frm_1, 5, 105, 385, 70, "Supprimer / Modifier une chaine")
ComboBoxGadget(#Cmb_Channels, 10, 120, 375, 20)
ButtonGadget(#Btn_DelChannel, 295, 150, 85, 20, "Supprimer")
ButtonGadget(#Btn_Mod_Channel, 205, 150, 85, 20, "Modifier")
ButtonGadget(#Btn_Up, 15, 150, 90, 20, "Monter")
ButtonGadget(#Btn_Down, 110, 150, 90, 20, "Descendre")
EndIf
EndIf
AddKeyboardShortcut(#Win_Channel, #PB_Shortcut_Return, #Btn_Add_Channel)
ForEach Boutons()
AddGadgetItem(#Cmb_Channels, -1, Boutons()\txtBouton)
Next
EndProcedure
Procedure TimerProc(hwnd.l, uMsg.l, idEvent.l, dwTime.l)
Select uMsg
Case #WM_TIMER
Select idEvent
Case 1
SetGadgetText(#Adresse, GetGadgetText(#Web_1))
WebFlag = 0 : KillTimer_(WindowID(#Window_0), 1)
EndSelect
EndSelect
EndProcedure
Procedure Main_Callback(WindowID, message, wParam, lParam)
Resultat = #PB_ProcessPureBasicEvents
Select message
Case #WM_SIZE
ResizeGadget(#Web_1, 135, 35, WindowWidth(#Window_0)-140, WindowHeight(#Window_0)-40)
ResizeGadget(#Adresse, 165, 5, WindowWidth(#Window_0)-170, 25)
ResizeGadget(#Cont, 0, 35, 130, WindowHeight(#Window_0))
Case #WM_PAINT
If CountList(Boutons()) > 0
LastElement(Boutons())
y = Boutons()\yBouton + Boutons()\hBouton
ResetList(Boutons())
If GetGadgetAttribute(#Cont, #PB_ScrollArea_InnerHeight) <> y +10
SetGadgetAttribute(#Cont, #PB_ScrollArea_InnerHeight, y + 10)
RedrawWindow_(WindowID(#Window_0), 0, 0,#RDW_INTERNALPAINT|#RDW_INVALIDATE|#RDW_ALLCHILDREN )
EndIf
EndIf
EndSelect
ProcedureReturn Resultat
EndProcedure
Procedure LoadList()
ClearList(Boutons())
If OpenPreferences("ChannelList.cfg")
If ExaminePreferenceGroups()
While NextPreferenceGroup()
If Left(PreferenceGroupName(), 8) = "Channel_"
AddElement(Boutons())
If ExaminePreferenceKeys()
While NextPreferenceKey()
If PreferenceKeyName() = "Id" : Boutons()\IdBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "x" : Boutons()\xBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "y" : Boutons()\yBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "w" : Boutons()\wBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "h" : Boutons()\hBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "Txt" : Boutons()\txtBouton = PreferenceKeyValue() : EndIf
If PreferenceKeyName() = "Url" : Boutons()\UrlBouton = PreferenceKeyValue() : EndIf
Wend
EndIf
EndIf
Wend
EndIf
EndIf
ClosePreferences()
ProcedureReturn 1
EndProcedure
Procedure SaveList()
If CreatePreferences("ChannelList.cfg")
Channel = 100 : y = 35
ForEach Boutons()
PreferenceGroup("Channel_"+Str(Channel -100))
WritePreferenceLong("Id", Channel)
WritePreferenceLong("x", Boutons()\xBouton)
WritePreferenceLong("y", y)
WritePreferenceLong("w", Boutons()\wBouton)
WritePreferenceLong("h", Boutons()\hBouton)
WritePreferenceString("Txt", Boutons()\txtBouton)
WritePreferenceString("Url", Boutons()\UrlBouton)
Channel + 1 : y + 25
Next
ClosePreferences()
Delay(100)
EndIf
ProcedureReturn 1
EndProcedure
Procedure UpdateButtons(Flag)
If Flag = 1
ForEach Boutons()
FreeGadget(Boutons()\IdBouton)
Next
Else
OpenGadgetList(#Cont)
ForEach Boutons()
ButtonImageGadget(Boutons()\IdBouton, Boutons()\xBouton, Boutons()\yBouton, Boutons()\wBouton, Boutons()\hBouton, MakeImage(Boutons()\txtBouton, "Arial", 80, Boutons()\wBouton, Boutons()\hBouton) )
GadgetToolTip(Boutons()\IdBouton, "Afficher la page de "+ Boutons()\txtBouton)
Next
CloseGadgetList()
EndIf
RedrawWindow_(WindowID(#Window_0), 0, 0,#RDW_INTERNALPAINT|#RDW_INVALIDATE|#RDW_ALLCHILDREN )
EndProcedure
Procedure AddCurrent()
Channel$ = GetGadgetText(#Adresse)
DisableWindow(#Window_0, 1)
Open_Win_Channels()
SetGadgetText(#Str_Add_Url, Channel$)
SetActiveGadget(#Str_Add_Channel)
EndProcedure
Procedure AddChannel()
Titre$ = GetGadgetText(#Str_Add_Channel)
Url$ = GetGadgetText(#Str_Add_Url)
If Titre$ <> "" And Url$ <> ""
If CountList(Boutons()) > 0
LastElement(Boutons())
id = Boutons()\IdBouton +1
y = Boutons()\yBouton +25
Else
id = 100
y = 35
EndIf
AddElement(Boutons())
Boutons()\IdBouton = id
Boutons()\xBouton = 5
Boutons()\yBouton = y
Boutons()\wBouton = 95
Boutons()\hBouton = 20
Boutons()\txtBouton = Titre$
Boutons()\UrlBouton = Url$
UpdateButtons(0)
EndIf
SaveList()
CloseWindow(#Win_Channel)
DisableWindow(#Window_0, 0)
SetActiveWindow(#Window_0)
EndProcedure
Procedure MakeImage(Lettre.s, Fonte.s, Taille, L_Bout, H_Bout)
l = L_Bout *10 : h = H_Bout *10
Font = LoadFont(0, Fonte, Taille)
Img = CreateImage(#PB_Any, l, h)
If Img
StartDrawing(ImageOutput(Img))
For i = 0 To h
FrontColor(RGB(0, 244, i))
Line(0, i, l, 0)
Next
DrawingFont(FontID(0))
L_Text = TextWidth(Lettre) : H_Text = TextHeight(Lettre)
;/ Ombre
DrawingMode(1)
FrontColor($808080)
DrawText((l/2) - (L_Text/2) +15, (h/2) - (H_Text/2) +15, Lettre)
;/ Texte
DrawingMode(1)
FrontColor($000000)
DrawText((l/2) - (L_Text/2), (h/2) - (H_Text/2), Lettre)
StopDrawing()
ResizeImage(Img, L_Bout, H_Bout)
EndIf
ProcedureReturn ImageID(Img)
EndProcedure
;}
LoadList()
OpenWindow_Win_Main() : SetWindowCallback(@Main_Callback())
UpdateButtons(0)
Browser.IWebBrowser2 = GetWindowLong_(GadgetID(#Web_1), #GWL_USERDATA)
Repeat
Delay(1) : Browser\get_Busy(@IsBusy.l)
If IsBusy <> 0 And WebFlag = 0
WebFlag = 1 : SetTimer_(WindowID(#Window_0), 1, 50, @TimerProc())
EndIf
Select WaitWindowEvent();{
;/ Raccourcis clavier
Case #PB_Event_Menu;{
Select EventMenu()
Case 0 : SetGadgetState(#Web_1, #PB_Web_Back)
Case 1 : SetGadgetState(#Web_1, #PB_Web_Forward)
Case 2 : SetGadgetState(#Web_1, #PB_Web_Refresh)
Case #Btn_Add_Channel : AddChannel()
Case #Btn_Add_Current : AddCurrent()
EndSelect;}
;/ Gadgets volants
Case #PB_Event_Gadget;{
If EventGadget() >= 100
If CountList(Boutons()) > 0
SelectElement(Boutons(), EventGadget()-100)
SetGadgetText(#Web_1, Boutons()\UrlBouton)
EndIf
EndIf;}
;/ Gadgets fixes : fenêtre principale
Select EventGadget()
Case #Btn_Add_Button;{
DisableWindow(#Window_0, 1)
Open_Win_Channels();}
Case #Btn_Add_Current;{
AddCurrent();}
Case #Btn_Fresh : SetGadgetState(#Web_1, #PB_Web_Refresh);{
;}
Case #Btn_Home : SetGadgetText(#Web_1, "http://www.programme-tv.net/");{
;}
Case #Btn_Next : SetGadgetState(#Web_1, #PB_Web_Forward);{
;}
Case #Btn_Prev : SetGadgetState(#Web_1, #PB_Web_Back);{
;}
Case #Btn_Stop : SetGadgetState(#Web_1, #PB_Web_Stop);{
;}
;/ Fenêtre Modifier / Supprimer
Case #Cmb_Channels;{
If EventType() = #CBN_SELCHANGE
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
SetGadgetText(#Str_Add_Channel, Boutons()\txtBouton)
SetGadgetText(#Str_Add_Url, Boutons()\UrlBouton)
EndIf;}
Case #Btn_Add_Channel;{
AddChannel();}
Case #Btn_DelChannel ;{
If GetGadgetState(#Cmb_Channels) > -1
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
Select MessageRequester("Supprimer une chaine","Voulez-vous supprimer cette chaine?", #PB_MessageRequester_YesNo|#MB_ICONQUESTION)
Case #IDYES
DeleteElement(Boutons(), 1)
ClearGadgetItemList(#Cmb_Channels)
UpdateButtons(1)
If SaveList()
If LoadList()
UpdateButtons(0)
SetGadgetText(#Str_Add_Channel, "")
SetGadgetText(#Str_Add_Url, "")
ForEach Boutons()
AddGadgetItem(#Cmb_Channels, -1, Boutons()\txtBouton)
Next
EndIf
EndIf
Case #IDNO
EndSelect
EndIf;}
Case #Btn_Mod_Channel;{
If GetGadgetState(#Cmb_Channels) > -1
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
Select MessageRequester("Modifier une chaine", "Voulez-vous mofier cette chaine?", #PB_MessageRequester_YesNo|#MB_ICONQUESTION)
Case #IDYES
Boutons()\txtBouton = GetGadgetText(#Str_Add_Channel)
Boutons()\UrlBouton = GetGadgetText(#Str_Add_Url)
If SaveList() : LoadList() : EndIf
Case #IDNO
EndSelect;}
EndIf
Case #Btn_Up;{
If GetGadgetState(#Cmb_Channels) > -1
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
Index = ListIndex(Boutons())
If ListIndex(Boutons()) > 0
*First = @Boutons()
SelectElement(Boutons(), ListIndex(Boutons()) - 1)
*Scnd = @Boutons()
SwapElements(Boutons(), *First, *Scnd)
ClearGadgetItemList(#Cmb_Channels)
If SaveList()
If LoadList()
UpdateButtons(1) : UpdateButtons(0)
ForEach Boutons()
AddGadgetItem(#Cmb_Channels, -1, Boutons()\txtBouton)
Next
SelectElement(Boutons(), Index -1)
SetGadgetState(#Cmb_Channels, ListIndex(Boutons()))
SetGadgetText(#Str_Add_Channel, Boutons()\txtBouton)
SetGadgetText(#Str_Add_Url, Boutons()\UrlBouton)
EndIf
EndIf
EndIf
EndIf;}
Case #Btn_Down;{
If GetGadgetState(#Cmb_Channels) > -1
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
Index = ListIndex(Boutons())
If ListIndex(Boutons()) < CountList(Boutons())
*First = @Boutons()
SelectElement(Boutons(), ListIndex(Boutons()) + 1)
*Scnd = @Boutons()
SwapElements(Boutons(), *First, *Scnd)
ClearGadgetItemList(#Cmb_Channels)
If SaveList()
If LoadList()
UpdateButtons(1) : UpdateButtons(0)
ForEach Boutons()
AddGadgetItem(#Cmb_Channels, -1, Boutons()\txtBouton)
Next
SelectElement(Boutons(), Index +1)
SetGadgetState(#Cmb_Channels, ListIndex(Boutons()))
SetGadgetText(#Str_Add_Channel, Boutons()\txtBouton)
SetGadgetText(#Str_Add_Url, Boutons()\UrlBouton)
EndIf
EndIf
EndIf
EndIf;}
EndSelect;}
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Win_Channel
CloseWindow(#Win_Channel)
DisableWindow(#Window_0, 0)
SetActiveWindow(#Window_0)
Case #Window_0 : SaveList() : Quit = #True
EndSelect
EndSelect
Until Quit
End
;
Code : Tout sélectionner
;{- Enumérations
Enumeration
#Win_Channel
#Window_0
EndEnumeration
Enumeration
;/ Fenêtre principale
#Web_1
#Adresse
#Btn_Add_Button
#Btn_Add_Current
;/ Ajoute
#Cont
#Btn_Add_Channel
#Frm_0
#Str_Add_Url
#Str_Add_Channel
#Txt_0
#Txt_1
;/ Supprime / Modifie
#Btn_Mod_Channel
#Btn_DelChannel
#Btn_Up
#Btn_Down
#Cmb_Channels
#Frm_1
;/ Navigation
#Btn_Fresh
#Btn_Home
#Btn_Next
#Btn_Prev
#Btn_Stop
EndEnumeration
;}
;{- Structures
Structure BOUTON
IdBouton.l
xBouton.l
yBouton.l
wBouton.l
hBouton.l
txtBouton.s
UrlBouton.s
EndStructure
;}
;{- Global (Variables, Tableaux, Listes)
Global NewList Boutons.BOUTON()
Global WebFlag
;}
Declare MakeImage(Lettre.s, Fonte.s, Taille, L_Bout, H_Bout)
;{- Procédures
Procedure OpenWindow_Win_Main()
OpenFile(1,"pos_fenetre.txt")
xw=Val(ReadString(1))
yw=Val(ReadString(1))
Hauteurw=Val(ReadString(1))
Largeurw=Val(ReadString(1))
CloseFile(1)
If Hauteurw<20 : Hauteurw=150:EndIf
If Largeurw<20 : Largeurw=150:EndIf
If OpenWindow(#Window_0, xw, yw, Largeurw, Hauteurw, "Programmes TV", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ButtonImageGadget(#Btn_Prev, 5, 5, 25, 25, MakeImage("Å", "WingDings", 150, 25, 25)) : GadgetToolTip(#Btn_Prev, "Aller à la page Précédente")
ButtonImageGadget(#Btn_Next, 30, 5, 25, 25, MakeImage("Æ", "WingDings", 150, 25, 25)) : GadgetToolTip(#Btn_Next, "Aller à la page Suivante")
ButtonImageGadget(#Btn_Home, 55, 5, 25, 25, MakeImage("H", "WebDings", 150, 25, 25)) : GadgetToolTip(#Btn_Home, "Aller à la page d'Accueil")
ButtonImageGadget(#Btn_Stop, 80, 5, 25, 25, MakeImage("r", "WebDings", 150, 25, 25)) : GadgetToolTip(#Btn_Stop, "Arreter le chargement")
ButtonImageGadget(#Btn_Fresh, 105, 5, 25, 25, MakeImage("q", "WebDings", 150, 25, 25)) : GadgetToolTip(#Btn_Fresh, "Recharger la page actuelle")
ButtonImageGadget(#Btn_Add_Current, 135, 5, 25, 25, MakeImage("+", "Arial", 200, 25, 25)) : GadgetToolTip(#Btn_Add_Current, "Ajouter l'adresse de la page à la liste des chaines")
WebGadget(#Web_1, 135, 35, Largeurw-140, Hauteurw-40, "http://www.programme-tv.net")
StringGadget(#Adresse, 165, 5, 645, 25, "", #PB_String_ReadOnly)
ScrollAreaGadget(#Cont, 0, 35, 130, 520, 110, 500, 1, #PB_ScrollArea_Raised)
ButtonImageGadget(#Btn_Add_Button, 5, 5, 95, 20, MakeImage("Modif/Suppr", "Arial", 80, 95, 20)) : GadgetToolTip(#Btn_Add_Button, "Opérations sur la liste de chaines")
CloseGadgetList()
EndIf
AddKeyboardShortcut(#Window_0, #PB_Shortcut_Left, 0)
AddKeyboardShortcut(#Window_0, #PB_Shortcut_Right, 1)
AddKeyboardShortcut(#Window_0, #PB_Shortcut_F5, 2)
AddKeyboardShortcut(#Window_0, #PB_Shortcut_Control|#PB_Shortcut_Add, #Btn_Add_Current)
EndIf
SetWindowColor(#Window_0, $80FF9C)
SetGadgetColor(#Cont, #PB_Gadget_BackColor, $80FF9C)
SetGadgetColor(#Adresse, #PB_Gadget_BackColor, $BFFFCE)
SetGadgetColor(#Adresse, #PB_Gadget_FrontColor, $008000)
SetGadgetFont(#Adresse, LoadFont(10, "Arial", 14))
EndProcedure
Procedure Open_Win_Channels()
If OpenWindow(#Win_Channel, 45, 45, 395, 180, "Ajouter / Supprimer une chaine", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Win_Channel))
Frame3DGadget(#Frm_0, 5, 5, 385, 100, "Ajouter une chaine")
TextGadget(#Txt_0, 10, 30, 35, 15, "Nom") : StringGadget(#Str_Add_Channel, 45, 25, 340, 20, "", #PB_String_UpperCase)
TextGadget(#Txt_1, 10, 55, 35, 15, "Url") : StringGadget(#Str_Add_Url, 45, 50, 340, 20, "")
ButtonGadget(#Btn_Add_Channel, 285, 80, 100, 20, "Ajouter")
Frame3DGadget(#Frm_1, 5, 105, 385, 70, "Supprimer / Modifier une chaine")
ComboBoxGadget(#Cmb_Channels, 10, 120, 375, 20)
ButtonGadget(#Btn_DelChannel, 295, 150, 85, 20, "Supprimer")
ButtonGadget(#Btn_Mod_Channel, 205, 150, 85, 20, "Modifier")
ButtonGadget(#Btn_Up, 15, 150, 90, 20, "Monter")
ButtonGadget(#Btn_Down, 110, 150, 90, 20, "Descendre")
EndIf
EndIf
AddKeyboardShortcut(#Win_Channel, #PB_Shortcut_Return, #Btn_Add_Channel)
ForEach Boutons()
AddGadgetItem(#Cmb_Channels, -1, Boutons()\txtBouton)
Next
EndProcedure
Procedure TimerProc(hwnd.l, uMsg.l, idEvent.l, dwTime.l)
Select uMsg
Case #WM_TIMER
Select idEvent
Case 1
SetGadgetText(#Adresse, GetGadgetText(#Web_1))
WebFlag = 0 : KillTimer_(WindowID(#Window_0), 1)
EndSelect
EndSelect
EndProcedure
Procedure Main_Callback(WindowID, message, wParam, lParam)
Resultat = #PB_ProcessPureBasicEvents
Select message
Case #WM_SIZE
ResizeGadget(#Web_1, 135, 35, WindowWidth(#Window_0)-140, WindowHeight(#Window_0)-40)
ResizeGadget(#Adresse, 165, 5, WindowWidth(#Window_0)-170, 25)
ResizeGadget(#Cont, 0, 35, 130, WindowHeight(#Window_0))
Case #WM_PAINT
If CountList(Boutons()) > 0
LastElement(Boutons())
y = Boutons()\yBouton + Boutons()\hBouton
ResetList(Boutons())
If GetGadgetAttribute(#Cont, #PB_ScrollArea_InnerHeight) <> y +10
SetGadgetAttribute(#Cont, #PB_ScrollArea_InnerHeight, y + 10)
RedrawWindow_(WindowID(#Window_0), 0, 0,#RDW_INTERNALPAINT|#RDW_INVALIDATE|#RDW_ALLCHILDREN )
EndIf
EndIf
EndSelect
ProcedureReturn Resultat
EndProcedure
Procedure LoadList()
ClearList(Boutons())
If OpenPreferences("ChannelList.cfg")
If ExaminePreferenceGroups()
While NextPreferenceGroup()
If Left(PreferenceGroupName(), 8) = "Channel_"
AddElement(Boutons())
If ExaminePreferenceKeys()
While NextPreferenceKey()
If PreferenceKeyName() = "Id" : Boutons()\IdBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "x" : Boutons()\xBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "y" : Boutons()\yBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "w" : Boutons()\wBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "h" : Boutons()\hBouton = Val(PreferenceKeyValue()) : EndIf
If PreferenceKeyName() = "Txt" : Boutons()\txtBouton = PreferenceKeyValue() : EndIf
If PreferenceKeyName() = "Url" : Boutons()\UrlBouton = PreferenceKeyValue() : EndIf
Wend
EndIf
EndIf
Wend
EndIf
EndIf
ClosePreferences()
ProcedureReturn 1
EndProcedure
Procedure SaveList()
If CreatePreferences("ChannelList.cfg")
Channel = 100 : y = 35
ForEach Boutons()
PreferenceGroup("Channel_"+Str(Channel -100))
WritePreferenceLong("Id", Channel)
WritePreferenceLong("x", Boutons()\xBouton)
WritePreferenceLong("y", y)
WritePreferenceLong("w", Boutons()\wBouton)
WritePreferenceLong("h", Boutons()\hBouton)
WritePreferenceString("Txt", Boutons()\txtBouton)
WritePreferenceString("Url", Boutons()\UrlBouton)
Channel + 1 : y + 25
Next
ClosePreferences()
Delay(100)
EndIf
ProcedureReturn 1
EndProcedure
Procedure UpdateButtons(Flag)
If Flag = 1
ForEach Boutons()
FreeGadget(Boutons()\IdBouton)
Next
Else
OpenGadgetList(#Cont)
ForEach Boutons()
ButtonImageGadget(Boutons()\IdBouton, Boutons()\xBouton, Boutons()\yBouton, Boutons()\wBouton, Boutons()\hBouton, MakeImage(Boutons()\txtBouton, "Arial", 80, Boutons()\wBouton, Boutons()\hBouton) )
GadgetToolTip(Boutons()\IdBouton, "Afficher la page de "+ Boutons()\txtBouton)
Next
CloseGadgetList()
EndIf
RedrawWindow_(WindowID(#Window_0), 0, 0,#RDW_INTERNALPAINT|#RDW_INVALIDATE|#RDW_ALLCHILDREN )
EndProcedure
Procedure AddCurrent()
Channel$ = GetGadgetText(#Adresse)
DisableWindow(#Window_0, 1)
Open_Win_Channels()
SetGadgetText(#Str_Add_Url, Channel$)
SetActiveGadget(#Str_Add_Channel)
EndProcedure
Procedure AddChannel()
Titre$ = GetGadgetText(#Str_Add_Channel)
Url$ = GetGadgetText(#Str_Add_Url)
If Titre$ <> "" And Url$ <> ""
If CountList(Boutons()) > 0
LastElement(Boutons())
id = Boutons()\IdBouton +1
y = Boutons()\yBouton +25
Else
id = 100
y = 35
EndIf
AddElement(Boutons())
Boutons()\IdBouton = id
Boutons()\xBouton = 5
Boutons()\yBouton = y
Boutons()\wBouton = 95
Boutons()\hBouton = 20
Boutons()\txtBouton = Titre$
Boutons()\UrlBouton = Url$
UpdateButtons(0)
EndIf
SaveList()
CloseWindow(#Win_Channel)
DisableWindow(#Window_0, 0)
SetActiveWindow(#Window_0)
EndProcedure
Procedure MakeImage(Lettre.s, Fonte.s, Taille, L_Bout, H_Bout)
l = L_Bout *10 : h = H_Bout *10
Font = LoadFont(0, Fonte, Taille)
Img = CreateImage(#PB_Any, l, h)
If Img
StartDrawing(ImageOutput(Img))
For i = 0 To h
FrontColor(RGB(0, 244, i))
Line(0, i, l, 0)
Next
DrawingFont(FontID(0))
L_Text = TextWidth(Lettre) : H_Text = TextHeight(Lettre)
;/ Ombre
DrawingMode(1)
FrontColor($808080)
DrawText((l/2) - (L_Text/2) +15, (h/2) - (H_Text/2) +15, Lettre)
;/ Texte
DrawingMode(1)
FrontColor($000000)
DrawText((l/2) - (L_Text/2), (h/2) - (H_Text/2), Lettre)
StopDrawing()
ResizeImage(Img, L_Bout, H_Bout)
EndIf
ProcedureReturn ImageID(Img)
EndProcedure
;}
LoadList()
OpenWindow_Win_Main() : SetWindowCallback(@Main_Callback())
UpdateButtons(0)
Browser.IWebBrowser2 = GetWindowLong_(GadgetID(#Web_1), #GWL_USERDATA)
Repeat
Delay(1) : Browser\get_Busy(@IsBusy.l)
If IsBusy <> 0 And WebFlag = 0
WebFlag = 1 : SetTimer_(WindowID(#Window_0), 1, 50, @TimerProc())
EndIf
Select WaitWindowEvent();{
;/ Raccourcis clavier
Case #PB_Event_Menu;{
Select EventMenu()
Case 0 : SetGadgetState(#Web_1, #PB_Web_Back)
Case 1 : SetGadgetState(#Web_1, #PB_Web_Forward)
Case 2 : SetGadgetState(#Web_1, #PB_Web_Refresh)
Case #Btn_Add_Channel : AddChannel()
Case #Btn_Add_Current : AddCurrent()
EndSelect;}
;/ Gadgets volants
Case #PB_Event_Gadget;{
If EventGadget() >= 100
If CountList(Boutons()) > 0
SelectElement(Boutons(), EventGadget()-100)
SetGadgetText(#Web_1, Boutons()\UrlBouton)
EndIf
EndIf;}
;/ Gadgets fixes : fenêtre principale
Select EventGadget()
Case #Btn_Add_Button;{
DisableWindow(#Window_0, 1)
Open_Win_Channels();}
Case #Btn_Add_Current;{
AddCurrent();}
Case #Btn_Fresh : SetGadgetState(#Web_1, #PB_Web_Refresh);{
;}
Case #Btn_Home : SetGadgetText(#Web_1, "http://www.programme-tv.net/");{
;}
Case #Btn_Next : SetGadgetState(#Web_1, #PB_Web_Forward);{
;}
Case #Btn_Prev : SetGadgetState(#Web_1, #PB_Web_Back);{
;}
Case #Btn_Stop : SetGadgetState(#Web_1, #PB_Web_Stop);{
;}
;/ Fenêtre Modifier / Supprimer
Case #Cmb_Channels;{
If EventType() = #CBN_SELCHANGE
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
SetGadgetText(#Str_Add_Channel, Boutons()\txtBouton)
SetGadgetText(#Str_Add_Url, Boutons()\UrlBouton)
EndIf;}
Case #Btn_Add_Channel;{
AddChannel();}
Case #Btn_DelChannel ;{
If GetGadgetState(#Cmb_Channels) > -1
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
Select MessageRequester("Supprimer une chaine","Voulez-vous supprimer cette chaine?", #PB_MessageRequester_YesNo|#MB_ICONQUESTION)
Case #IDYES
DeleteElement(Boutons(), 1)
ClearGadgetItemList(#Cmb_Channels)
UpdateButtons(1)
If SaveList()
If LoadList()
UpdateButtons(0)
SetGadgetText(#Str_Add_Channel, "")
SetGadgetText(#Str_Add_Url, "")
ForEach Boutons()
AddGadgetItem(#Cmb_Channels, -1, Boutons()\txtBouton)
Next
EndIf
EndIf
Case #IDNO
EndSelect
EndIf;}
Case #Btn_Mod_Channel;{
If GetGadgetState(#Cmb_Channels) > -1
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
Select MessageRequester("Modifier une chaine", "Voulez-vous mofier cette chaine?", #PB_MessageRequester_YesNo|#MB_ICONQUESTION)
Case #IDYES
Boutons()\txtBouton = GetGadgetText(#Str_Add_Channel)
Boutons()\UrlBouton = GetGadgetText(#Str_Add_Url)
If SaveList() : LoadList() : EndIf
Case #IDNO
EndSelect;}
EndIf
Case #Btn_Up;{
If GetGadgetState(#Cmb_Channels) > -1
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
Index = ListIndex(Boutons())
If ListIndex(Boutons()) > 0
*First = @Boutons()
SelectElement(Boutons(), ListIndex(Boutons()) - 1)
*Scnd = @Boutons()
SwapElements(Boutons(), *First, *Scnd)
ClearGadgetItemList(#Cmb_Channels)
If SaveList()
If LoadList()
UpdateButtons(1) : UpdateButtons(0)
ForEach Boutons()
AddGadgetItem(#Cmb_Channels, -1, Boutons()\txtBouton)
Next
SelectElement(Boutons(), Index -1)
SetGadgetState(#Cmb_Channels, ListIndex(Boutons()))
SetGadgetText(#Str_Add_Channel, Boutons()\txtBouton)
SetGadgetText(#Str_Add_Url, Boutons()\UrlBouton)
EndIf
EndIf
EndIf
EndIf;}
Case #Btn_Down;{
If GetGadgetState(#Cmb_Channels) > -1
SelectElement(Boutons(), GetGadgetState(#Cmb_Channels))
Index = ListIndex(Boutons())
If ListIndex(Boutons()) < CountList(Boutons())
*First = @Boutons()
SelectElement(Boutons(), ListIndex(Boutons()) + 1)
*Scnd = @Boutons()
SwapElements(Boutons(), *First, *Scnd)
ClearGadgetItemList(#Cmb_Channels)
If SaveList()
If LoadList()
UpdateButtons(1) : UpdateButtons(0)
ForEach Boutons()
AddGadgetItem(#Cmb_Channels, -1, Boutons()\txtBouton)
Next
SelectElement(Boutons(), Index +1)
SetGadgetState(#Cmb_Channels, ListIndex(Boutons()))
SetGadgetText(#Str_Add_Channel, Boutons()\txtBouton)
SetGadgetText(#Str_Add_Url, Boutons()\UrlBouton)
EndIf
EndIf
EndIf
EndIf;}
EndSelect;}
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Win_Channel
CloseWindow(#Win_Channel)
DisableWindow(#Window_0, 0)
SetActiveWindow(#Window_0)
Case #Window_0 : SaveList() : Quit = #True
xw=WindowX(#Window_0)
yw=WindowY(#Window_0)
Hauteurw = WindowHeight(#Window_0)
Largeurw = WindowWidth(#Window_0)
OpenFile(1,"pos_fenetre.txt")
WriteStringN(1,Str(xw))
WriteStringN(1,Str(yw))
WriteStringN(1,Str(Hauteurw))
WriteStringN(1,Str(Largeurw))
CloseFile(1)
EndSelect
EndSelect
Until Quit
End
;