Si tu as encore mon dossier exemple, Voici l'exemple dans lequel ta fenetre sera également noir.
Code : Tout sélectionner
EnableExplicit
; /// DECLARATION DE L'ENUMERARION
Enumeration Window
#mf
EndEnumeration
Enumeration gadget
#drapeauFR
#drapeauUS
#grille
#reset
EndEnumeration
Enumeration Gadget_lang
#G1
#G2
#G3
#G4
EndEnumeration
; Langue
Enumeration Langue
#GB
#FR
#GE
EndEnumeration
; TITRES DES MENUS
Enumeration menus
#ME_GAM
#ME_TON
EndEnumeration
; ITEMS DU MENU GAMME
Enumeration Gamme
#GA_CHR
#GA_DIAMA
#GA_DIAMI
#GA_PMA
#GA_PMI
EndEnumeration
; ITEMS DU MENU TONALITÉ
Enumeration Tonalite #PB_Compiler_EnumerationValue
#TO_C
#TO_Db
#TO_D
#TO_Eb
#TO_E
#TO_F
#TO_Gb
#TO_G
#TO_Ab
#TO_A
#TO_Bb
#TO_B
EndEnumeration
;/// INTERFACE UTILISATEUR (FENETRE, MENU, ETC ...)
#LA_FEN = 1024
#HA_FEN = 768
#CA_SIZE = 20
#GD_SIZE = 16 * (#CA_SIZE + 2) + 2
#GD_YST = (#HA_FEN-#GD_SIZE) / 2
#GD_XST = (#LA_FEN-#GD_SIZE) / 2
#TXT_X = #GD_XST + #GD_SIZE / 2
#TXT_Y = #GD_YST + #GD_SIZE + 10
#CLEAR = "RESET"
;/// DECLARATION DES VARIABLES
Global event, police, drapeauFR, drapeauUS
Global A$, ix, iy, xx, yy, TX_LEN, TX_HA, XF, Event, Lang
; Déclaration des procédures
Declare mk_menus (id)
;- Ca commence ici
Police = LoadFont(0, "Arial", 16, #PB_Font_Bold)
; Ouverture de la fenetre
If OpenWindow(#mf, 0, 0, #LA_FEN, #HA_FEN, "Manque un titre", #PB_Window_ScreenCentered | #PB_Window_TitleBar | #PB_Window_SystemMenu)
; Si tu veux une fenetre sur fond noir, decommente la ligne qui suit
SetWindowColor(#mf, RGB(0, 0, 0))
UseJPEGImageDecoder()
CanvasGadget(#drapeauFR, 20, 20, 40, 40, 0)
CanvasGadget(#drapeauUS, 70, 20, 40, 40, 0)
drapeauFR = CatchImage(#PB_Any, ?drapeauFR)
drapeauUS = CatchImage(#PB_Any, ?drapeauUS)
ResizeImage(drapeauFR, GadgetWidth(#drapeauFR), GadgetHeight(#drapeauFR))
ResizeImage(drapeauUS, GadgetWidth(#drapeauFR), GadgetHeight(#drapeauFR))
SetGadgetAttribute(#drapeauFR, #PB_Button_Image, ImageID(drapeauFR))
SetGadgetAttribute(#drapeauUS, #PB_Button_Image, ImageID(drapeauUS))
; Menu FR par défaut
mk_menus(#FR)
; Création de la grille (id 0)
If CreateImage(0, #GD_SIZE, #GD_SIZE) And StartDrawing(ImageOutput(0))
Box(0 , 0, #GD_SIZE, #GD_SIZE, RGB(200, 0, 0))
For ix = 0 To 15
xx = 2 + ix*(#CA_SIZE+2) ;
For iy = 0 To 15
yy = 2 + iy*(#CA_SIZE+2) ;
Box(xx, yy, #CA_SIZE, #CA_SIZE, RGB(0,0,0))
Next
Next
; Mémorisation des dimensions du reset
DrawingFont(Police)
TX_LEN = TextWidth(#CLEAR)
TX_HA = TextHeight(#CLEAR)
StopDrawing()
; Affichage de la grille
ImageGadget(#grille, (#LA_FEN-#GD_SIZE)/2, (#HA_FEN-#GD_SIZE)/2, #GD_SIZE, #GD_SIZE, ImageID(0))
EndIf
If CreateImage(1, TX_LEN+20, TX_HA+20) And StartDrawing(ImageOutput(1))
Box(0, 0, TX_LEN+20, TX_HA+20, RGB(100,100,100))
DrawingMode(#PB_2DDrawing_Transparent )
DrawingFont(Police)
DrawText(10, 10, #CLEAR, RGB(200, 200, 0))
StopDrawing()
; Affichage du reset
ButtonImageGadget(#reset, (#LA_FEN-TX_LEN)/2, (#HA_FEN+#GD_SIZE)/2 + 20, TX_LEN+10, TX_HA+10, ImageID(1))
EndIf
; Gestion des événements
Repeat
Event = WaitWindowEvent() ; pour l'instant test : on affiche un message et c'est tout.
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #drapeauFR
If EventType() = #PB_EventType_LeftClick
mk_menus(#FR)
EndIf
Case #drapeauUS
If EventType() = #PB_EventType_LeftClick
mk_menus(#GB)
EndIf
Case #reset
Debug "reset"
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case #GA_CHR
MessageRequester( A$, GetMenuItemText(#ME_GAM, #GA_CHR))
Case #GA_DIAMA
MessageRequester( A$, GetMenuItemText(#ME_GAM, #GA_DIAMA))
Case #GA_DIAMI
MessageRequester( A$, GetMenuItemText(#ME_GAM, #GA_DIAMI))
Case #GA_PMA
MessageRequester( A$, GetMenuItemText(#ME_GAM, #GA_PMA))
Case #GA_PMI
MessageRequester( A$, GetMenuItemText(#ME_GAM, #GA_PMI))
; Menu tonalié
Case #TO_C
MessageRequester( A$, "C")
Case #TO_Db
MessageRequester( A$, "C#")
Case #TO_D
MessageRequester( A$, "D")
Case #TO_Eb
MessageRequester( A$, "Eb")
Case #TO_E
MessageRequester( A$, "E")
Case #TO_F
MessageRequester( A$, "F")
Case #TO_Gb
MessageRequester( A$, "F#")
Case #TO_G
MessageRequester( A$, "G")
Case #TO_Ab
MessageRequester( A$, "Ab")
Case #TO_A
MessageRequester( A$, "A")
Case #TO_Bb
MessageRequester( A$, "Bb")
Case #TO_B
MessageRequester( A$, "B")
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
;- Procédures
Procedure mk_menus (id)
Select id
Case #GB
CreateMenu(#ME_GAM, WindowID(0))
; MENU GAMME
MenuTitle("Scale")
MenuItem(#GA_CHR, "Chromatic")
MenuItem(#GA_DIAMA, "Major Diatonic")
MenuItem(#GA_DIAMI, "Minor Diatonic")
MenuItem(#GA_PMA, "Major Pentatonic")
MenuItem(#GA_PMI , "Minor Pentatonic")
; MENU TONALITÉ de DO à SI Par demis-tons
MenuTitle("Key")
MenuItem(#TO_C, "C")
MenuItem(#TO_Db, "C#")
MenuItem(#TO_D, "D#")
MenuItem(#TO_Eb, "Eb#")
MenuItem(#TO_E, "E")
MenuItem(#TO_F, "F")
MenuItem(#TO_Gb, "F#")
MenuItem(#TO_G, "G")
MenuItem(#TO_Ab, "Ab")
MenuItem(#TO_A, "A")
MenuItem(#TO_Bb, "Bb")
MenuItem(#TO_B, "B")
Case #Fr
CreateMenu(#ME_GAM, WindowID(0))
; MENU GAMME
MenuTitle("Gamme")
MenuItem(#GA_CHR, "Chromatique")
MenuItem(#GA_DIAMA, "Diatonique Majeure")
MenuItem(#GA_DIAMI, "Diatonique Mineure")
MenuItem(#GA_PMA, "Pentatonique Majeure")
MenuItem(#GA_PMI , "Pentatonique Mineure")
; MENU TONALITÉ de DO à SI Par demis-tons
MenuTitle("Tonalité")
MenuItem(#TO_C, "Do")
MenuItem(#TO_Db, "Do#")
MenuItem(#TO_D, "Ré")
MenuItem(#TO_Eb, "Mib")
MenuItem(#TO_E, "Mi")
MenuItem(#TO_F, "Fa")
MenuItem(#TO_Gb, "Fa#")
MenuItem(#TO_G, "Sol")
MenuItem(#TO_Ab, "Lab")
MenuItem(#TO_A, "La")
MenuItem(#TO_Bb, "Sib")
MenuItem(#TO_B, "Si")
Case #GE
CreateMenu(#ME_GAM, WindowID(0))
; MENU GAMME
MenuTitle("Gamme")
MenuItem(#GA_CHR, "Chromatique")
MenuItem(#GA_DIAMA, "Diatonique Majeure")
MenuItem(#GA_DIAMI, "Diatonique Mineure")
MenuItem(#GA_PMA, "Pentatonique Majeure")
MenuItem(#GA_PMI , "Pentatonique Mineure")
; MENU TONALITÉ de DO à SI Par demis-tons
MenuTitle("Tonalité")
MenuItem(#TO_C, "Do")
MenuItem(#TO_Db, "Do#")
MenuItem(#TO_D, "Ré")
MenuItem(#TO_Eb, "Mib")
MenuItem(#TO_E, "Mi")
MenuItem(#TO_F, "Fa")
MenuItem(#TO_Gb, "Fa#")
MenuItem(#TO_G, "Sol")
MenuItem(#TO_Ab, "Lab")
MenuItem(#TO_A, "La")
MenuItem(#TO_Bb, "Sib")
MenuItem(#TO_B, "Si")
EndSelect
EndProcedure
DataSection
drapeauFR:
IncludeBinary "fr.bmp"
drapeauUS:
IncludeBinary "us.bmp"
EndDataSection