Code : Tout sélectionner
; crée par Mr dieppedalle david le mercredi 30 juin 2010
; ce programme permet de redimensionner en temps réel les string gadget suivent leur contenu
Enumeration
#Window_0
#String_0
#String_1
#String_2
#String_3
#String_4
#String_5
#String_6
#String_7
#String_8
#String_9
#Fond
#fond_neutre
#Fond2
#Fond3
#Fond4
#Fond5
#Fond6
#Fond7
#Fond8
#Fond9
#Fond10
EndEnumeration
Procedure Open_Window_0()
If OpenWindow(#Window_0, 382, 195, 800, 600, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
SmartWindowRefresh(#Window_0, 1)
StringGadget(#String_0, 10, 10, 145, 20, "")
SetGadgetFont(#String_0, LoadFont(#Fond, "arial", 10))
ResizeGadget(#String_0, #PB_Ignore, #PB_Ignore, 18, #PB_Ignore)
StringGadget(#String_1, 10, 10, 145, 20, "")
SetGadgetFont(#String_1, LoadFont(#Fond2, "arial", 10))
ResizeGadget(#String_1, GadgetX(#String_0) + GadgetWidth(#String_0) , #PB_Ignore, 18, #PB_Ignore)
StringGadget(#String_2, 10, 10, 145, 20, "")
SetGadgetFont(#String_2, LoadFont(#Fond3, "arial", 10))
ResizeGadget(#String_2, GadgetX(#String_1) + GadgetWidth(#String_1) , #PB_Ignore, 18, #PB_Ignore)
StringGadget(#String_3, 10, 10, 145, 20, "")
SetGadgetFont(#String_3, LoadFont(#Fond4, "arial", 10))
ResizeGadget(#String_3, GadgetX(#String_2) + GadgetWidth(#String_2) , #PB_Ignore, 18, #PB_Ignore)
StringGadget(#String_4, 10, 10, 145, 20, "")
SetGadgetFont(#String_4, LoadFont(#Fond5, "arial", 10))
ResizeGadget(#String_4, GadgetX(#String_3) + GadgetWidth(#String_3) , #PB_Ignore, 18, #PB_Ignore)
StringGadget(#String_5, 10, 10, 145, 20, "")
SetGadgetFont(#String_5, LoadFont(#Fond6, "arial", 10))
ResizeGadget(#String_5, GadgetX(#String_4) + GadgetWidth(#String_4) , #PB_Ignore, 18, #PB_Ignore)
StringGadget(#String_6, 10, 10, 145, 20, "")
SetGadgetFont(#String_6, LoadFont(#Fond7, "arial", 10))
ResizeGadget(#String_6, GadgetX(#String_5) + GadgetWidth(#String_5) , #PB_Ignore, 18, #PB_Ignore)
StringGadget(#String_7, 10, 10, 145, 20, "")
SetGadgetFont(#String_7, LoadFont(#Fond8, "arial", 10))
ResizeGadget(#String_7, GadgetX(#String_6) + GadgetWidth(#String_6) , #PB_Ignore, 18, #PB_Ignore)
StringGadget(#String_8, 10, 10, 145, 20, "")
SetGadgetFont(#String_8, LoadFont(#Fond9, "arial", 10))
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7) , #PB_Ignore, 18, #PB_Ignore)
StringGadget(#String_9, 10, 10, 145, 20, "")
SetGadgetFont(#String_9, LoadFont(#Fond10, "arial", 10))
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8) , #PB_Ignore, 18, #PB_Ignore)
EndIf
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
EvenMenue = EventMenu()
If Event = #PB_Event_Gadget
If GadgetID = #String_0
If EventType = #PB_EventType_Change
texte$ = GetGadgetText(#String_0)
fond = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond)
Longueur_texte = TextWidth(texte$)
StopDrawing()
ResizeGadget(#String_0, #PB_Ignore, #PB_Ignore, Longueur_texte + 18, #PB_Ignore)
ResizeGadget(#String_1, GadgetX(#String_0) + GadgetWidth(#String_0), #PB_Ignore, Longueur_texte2 + 18, #PB_Ignore)
ResizeGadget(#String_2, GadgetX(#String_1) + GadgetWidth(#String_1), #PB_Ignore, Longueur_texte3 + 18, #PB_Ignore)
ResizeGadget(#String_3, GadgetX(#String_2) + GadgetWidth(#String_2), #PB_Ignore, Longueur_texte4 + 18, #PB_Ignore)
ResizeGadget(#String_4, GadgetX(#String_3) + GadgetWidth(#String_3), #PB_Ignore, Longueur_texte5 + 18, #PB_Ignore)
ResizeGadget(#String_5, GadgetX(#String_4) + GadgetWidth(#String_4), #PB_Ignore, Longueur_texte6 + 18, #PB_Ignore)
ResizeGadget(#String_6, GadgetX(#String_5) + GadgetWidth(#String_5), #PB_Ignore, Longueur_texte7 + 18, #PB_Ignore)
ResizeGadget(#String_7, GadgetX(#String_6) + GadgetWidth(#String_6), #PB_Ignore, Longueur_texte8 + 18, #PB_Ignore)
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7), #PB_Ignore, Longueur_texte9 + 18, #PB_Ignore)
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_1)
SetActiveGadget(#String_2)
SetActiveGadget(#String_3)
SetActiveGadget(#String_4)
SetActiveGadget(#String_5)
SetActiveGadget(#String_6)
SetActiveGadget(#String_7)
SetActiveGadget(#String_8)
SetActiveGadget(#String_9)
SetActiveGadget(#String_0)
EndIf
ElseIf GadgetID = #String_1
If EventType = #PB_EventType_Change
texte2$ = GetGadgetText(#String_1)
fond2 = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond2)
Longueur_texte2 = TextWidth(texte2$)
StopDrawing()
ResizeGadget(#String_1, GadgetX(#String_0) + GadgetWidth(#String_0), #PB_Ignore, Longueur_texte2 + 18, #PB_Ignore)
ResizeGadget(#String_2, GadgetX(#String_1) + GadgetWidth(#String_1), #PB_Ignore, Longueur_texte3 + 18, #PB_Ignore)
ResizeGadget(#String_3, GadgetX(#String_2) + GadgetWidth(#String_2), #PB_Ignore, Longueur_texte4 + 18, #PB_Ignore)
ResizeGadget(#String_4, GadgetX(#String_3) + GadgetWidth(#String_3), #PB_Ignore, Longueur_texte5 + 18, #PB_Ignore)
ResizeGadget(#String_5, GadgetX(#String_4) + GadgetWidth(#String_4), #PB_Ignore, Longueur_texte6 + 18, #PB_Ignore)
ResizeGadget(#String_6, GadgetX(#String_5) + GadgetWidth(#String_5), #PB_Ignore, Longueur_texte7 + 18, #PB_Ignore)
ResizeGadget(#String_7, GadgetX(#String_6) + GadgetWidth(#String_6), #PB_Ignore, Longueur_texte8 + 18, #PB_Ignore)
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7), #PB_Ignore, Longueur_texte9 + 18, #PB_Ignore)
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_0)
SetActiveGadget(#String_2)
SetActiveGadget(#String_3)
SetActiveGadget(#String_4)
SetActiveGadget(#String_5)
SetActiveGadget(#String_6)
SetActiveGadget(#String_7)
SetActiveGadget(#String_8)
SetActiveGadget(#String_9)
SetActiveGadget(#String_1)
EndIf
ElseIf GadgetID = #String_2
If EventType = #PB_EventType_Change
texte3$ = GetGadgetText(#String_2)
fond3 = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond3)
Longueur_texte3 = TextWidth(texte3$)
StopDrawing()
ResizeGadget(#String_2, GadgetX(#String_1) + GadgetWidth(#String_1), #PB_Ignore, Longueur_texte3 + 18, #PB_Ignore)
ResizeGadget(#String_3, GadgetX(#String_2) + GadgetWidth(#String_2), #PB_Ignore, Longueur_texte4 + 18, #PB_Ignore)
ResizeGadget(#String_4, GadgetX(#String_3) + GadgetWidth(#String_3), #PB_Ignore, Longueur_texte5 + 18, #PB_Ignore)
ResizeGadget(#String_5, GadgetX(#String_4) + GadgetWidth(#String_4), #PB_Ignore, Longueur_texte6 + 18, #PB_Ignore)
ResizeGadget(#String_6, GadgetX(#String_5) + GadgetWidth(#String_5), #PB_Ignore, Longueur_texte7 + 18, #PB_Ignore)
ResizeGadget(#String_7, GadgetX(#String_6) + GadgetWidth(#String_6), #PB_Ignore, Longueur_texte8 + 18, #PB_Ignore)
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7), #PB_Ignore, Longueur_texte9 + 18, #PB_Ignore)
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_0)
SetActiveGadget(#String_1)
SetActiveGadget(#String_3)
SetActiveGadget(#String_4)
SetActiveGadget(#String_5)
SetActiveGadget(#String_6)
SetActiveGadget(#String_7)
SetActiveGadget(#String_8)
SetActiveGadget(#String_9)
SetActiveGadget(#String_2)
EndIf
ElseIf GadgetID = #String_3
If EventType = #PB_EventType_Change
texte4$ = GetGadgetText(#String_3)
fond4 = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond4)
Longueur_texte4 = TextWidth(texte4$)
StopDrawing()
ResizeGadget(#String_3, GadgetX(#String_2) + GadgetWidth(#String_2), #PB_Ignore, Longueur_texte4 + 18, #PB_Ignore)
ResizeGadget(#String_4, GadgetX(#String_3) + GadgetWidth(#String_3), #PB_Ignore, Longueur_texte5 + 18, #PB_Ignore)
ResizeGadget(#String_5, GadgetX(#String_4) + GadgetWidth(#String_4), #PB_Ignore, Longueur_texte6 + 18, #PB_Ignore)
ResizeGadget(#String_6, GadgetX(#String_5) + GadgetWidth(#String_5), #PB_Ignore, Longueur_texte7 + 18, #PB_Ignore)
ResizeGadget(#String_7, GadgetX(#String_6) + GadgetWidth(#String_6), #PB_Ignore, Longueur_texte8 + 18, #PB_Ignore)
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7), #PB_Ignore, Longueur_texte9 + 18, #PB_Ignore)
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_0)
SetActiveGadget(#String_1)
SetActiveGadget(#String_2)
SetActiveGadget(#String_4)
SetActiveGadget(#String_5)
SetActiveGadget(#String_6)
SetActiveGadget(#String_7)
SetActiveGadget(#String_8)
SetActiveGadget(#String_9)
SetActiveGadget(#String_3)
EndIf
ElseIf GadgetID = #String_4
If EventType = #PB_EventType_Change
texte5$ = GetGadgetText(#String_4)
fond5 = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond5)
Longueur_texte5 = TextWidth(texte5$)
StopDrawing()
ResizeGadget(#String_4, GadgetX(#String_3) + GadgetWidth(#String_3), #PB_Ignore, Longueur_texte5 + 18, #PB_Ignore)
ResizeGadget(#String_5, GadgetX(#String_4) + GadgetWidth(#String_4), #PB_Ignore, Longueur_texte6 + 18, #PB_Ignore)
ResizeGadget(#String_6, GadgetX(#String_5) + GadgetWidth(#String_5), #PB_Ignore, Longueur_texte7 + 18, #PB_Ignore)
ResizeGadget(#String_7, GadgetX(#String_6) + GadgetWidth(#String_6), #PB_Ignore, Longueur_texte8 + 18, #PB_Ignore)
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7), #PB_Ignore, Longueur_texte9 + 18, #PB_Ignore)
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_0)
SetActiveGadget(#String_1)
SetActiveGadget(#String_2)
SetActiveGadget(#String_3)
SetActiveGadget(#String_5)
SetActiveGadget(#String_6)
SetActiveGadget(#String_7)
SetActiveGadget(#String_8)
SetActiveGadget(#String_9)
SetActiveGadget(#String_4)
EndIf
ElseIf GadgetID = #String_5
If EventType = #PB_EventType_Change
texte6$ = GetGadgetText(#String_5)
fond6 = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond6)
Longueur_texte6 = TextWidth(texte6$)
StopDrawing()
ResizeGadget(#String_5, GadgetX(#String_4) + GadgetWidth(#String_4), #PB_Ignore, Longueur_texte6 + 18, #PB_Ignore)
ResizeGadget(#String_6, GadgetX(#String_5) + GadgetWidth(#String_5), #PB_Ignore, Longueur_texte7 + 18, #PB_Ignore)
ResizeGadget(#String_7, GadgetX(#String_6) + GadgetWidth(#String_6), #PB_Ignore, Longueur_texte8 + 18, #PB_Ignore)
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7), #PB_Ignore, Longueur_texte9 + 18, #PB_Ignore)
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_0)
SetActiveGadget(#String_1)
SetActiveGadget(#String_2)
SetActiveGadget(#String_3)
SetActiveGadget(#String_4)
SetActiveGadget(#String_6)
SetActiveGadget(#String_7)
SetActiveGadget(#String_8)
SetActiveGadget(#String_9)
SetActiveGadget(#String_5)
EndIf
ElseIf GadgetID = #String_6
If EventType = #PB_EventType_Change
texte7$ = GetGadgetText(#String_6)
fond7 = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond7)
Longueur_texte7 = TextWidth(texte7$)
StopDrawing()
ResizeGadget(#String_6, GadgetX(#String_5) + GadgetWidth(#String_5), #PB_Ignore, Longueur_texte7 + 18, #PB_Ignore)
ResizeGadget(#String_7, GadgetX(#String_6) + GadgetWidth(#String_6), #PB_Ignore, Longueur_texte8 + 18, #PB_Ignore)
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7), #PB_Ignore, Longueur_texte9 + 18, #PB_Ignore)
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_0)
SetActiveGadget(#String_1)
SetActiveGadget(#String_2)
SetActiveGadget(#String_3)
SetActiveGadget(#String_4)
SetActiveGadget(#String_5)
SetActiveGadget(#String_7)
SetActiveGadget(#String_8)
SetActiveGadget(#String_9)
SetActiveGadget(#String_6)
EndIf
ElseIf GadgetID = #String_7
If EventType = #PB_EventType_Change
texte8$ = GetGadgetText(#String_7)
fond8 = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond8)
Longueur_texte8 = TextWidth(texte8$)
StopDrawing()
ResizeGadget(#String_7, GadgetX(#String_6) + GadgetWidth(#String_6), #PB_Ignore, Longueur_texte8 + 18, #PB_Ignore)
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7), #PB_Ignore, Longueur_texte9 + 18, #PB_Ignore)
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_0)
SetActiveGadget(#String_1)
SetActiveGadget(#String_2)
SetActiveGadget(#String_3)
SetActiveGadget(#String_4)
SetActiveGadget(#String_5)
SetActiveGadget(#String_6)
SetActiveGadget(#String_8)
SetActiveGadget(#String_9)
SetActiveGadget(#String_7)
EndIf
ElseIf GadgetID = #String_8
If EventType = #PB_EventType_Change
texte9$ = GetGadgetText(#String_8)
fond9 = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond9)
Longueur_texte9 = TextWidth(texte9$)
StopDrawing()
ResizeGadget(#String_8, GadgetX(#String_7) + GadgetWidth(#String_7), #PB_Ignore, Longueur_texte9 + 18, #PB_Ignore)
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_0)
SetActiveGadget(#String_1)
SetActiveGadget(#String_2)
SetActiveGadget(#String_3)
SetActiveGadget(#String_4)
SetActiveGadget(#String_5)
SetActiveGadget(#String_6)
SetActiveGadget(#String_7)
SetActiveGadget(#String_9)
SetActiveGadget(#String_8)
EndIf
ElseIf GadgetID = #String_9
If EventType = #PB_EventType_Change
texte10$ = GetGadgetText(#String_9)
fond10 = LoadFont(#fond_neutre, "arial", 10)
StartDrawing(WindowOutput(#Window_0))
DrawingFont(fond10)
Longueur_texte10 = TextWidth(texte10$)
StopDrawing()
ResizeGadget(#String_9, GadgetX(#String_8) + GadgetWidth(#String_8), #PB_Ignore, Longueur_texte10 + 18, #PB_Ignore)
; ceci sert pour ré-afficher correctement les gadget, sinon certain sons parfois pas bien afficher
SetActiveGadget(#String_0)
SetActiveGadget(#String_1)
SetActiveGadget(#String_2)
SetActiveGadget(#String_3)
SetActiveGadget(#String_4)
SetActiveGadget(#String_5)
SetActiveGadget(#String_6)
SetActiveGadget(#String_7)
SetActiveGadget(#String_8)
SetActiveGadget(#String_9)
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
EndProcedure
Open_Window_0()