Je ne suis pas super fort avec les appis. J'aimerais savoir comment changer la taille des icones d'un TreeGadget, et à tant qu'à faire également les icones d'une ToolBar.
Si Dob..... eu Spock passe par la

Merci
Le temps de te concocter un code ...microdevweb a écrit :Une idée pour les icones du TreeGadget ?
Code : Tout sélectionner
Enumeration
#MainForm
#Tree
EndEnumeration
;Petite police pour faire jolie mais pas obligatoire
If LoadFont(1, "Arial", 15)
SetGadgetFont(#PB_Default, FontID(1))
EndIf
If OpenWindow(#MainForm, 0, 0, 700, 500, "TreeGadget Large icon", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TreeGadget(#Tree, 10, 10, 680, 480)
;N'ayant pas le temps de faire quelques icones, je prends quelques icone de l'OS
If OSVersion() > #PB_OS_Windows_2000
OpenLibrary(0, "uxtheme.dll")
;Eventuellement on peut commenter ces deux lignes. A vous de voir
;commentez pour voir la différence
CallFunction(0, "SetWindowTheme", GadgetID(#Tree), @" ", @" ")
SetThemeAppProperties_(1)
CloseLibrary(0)
EndIf
;Taille des icones
IconSize = 32
;
ImageList = ImageList_Create_(IconSize, IconSize, #ILC_COLOR32 | #ILC_MASK, 0, 10)
; Quelques icones de test extraites de shell32.dll
ico0 = ExtractIcon_(0, "shell32.dll", 43) ;Etoile
ico1 = ExtractIcon_(0, "shell32.dll", 44) ;Clé
ico2 = ExtractIcon_(0, "shell32.dll", 45) ;Dossier
ico3 = ExtractIcon_(0, "shell32.dll", 47) ;Cadenas
ico4 = ExtractIcon_(0, "shell32.dll", 23) ;Point d'interogation
;AJoute des icone dans la liste d'icone
ImageList_AddIcon_(ImageList, ico0)
ImageList_AddIcon_(ImageList, ico1)
ImageList_AddIcon_(ImageList, ico2)
ImageList_AddIcon_(ImageList, ico3)
ImageList_AddIcon_(ImageList, ico4)
;Création du tree-view
AddGadgetItem(#Tree, - 1, "Icon 43 ", ico0, 0)
AddGadgetItem(#Tree, - 1, "Icon 44 ", ico1, 0)
AddGadgetItem(#Tree, - 1, "Icon 45 ", ico2, 0)
AddGadgetItem(#Tree, - 1, "Icon 47 ", ico3, 0)
AddGadgetItem(#Tree, - 1, "Icon 23 ", ico4, 1)
;Et destruction (Pas sur que ce soit nécessaire)
DestroyIcon_(ico0)
DestroyIcon_(ico1)
DestroyIcon_(ico2)
DestroyIcon_(ico3)
DestroyIcon_(ico4)
;Le tour de magie
SendMessage_(GadgetID(#Tree), #TVM_SETIMAGELIST, #TVSIL_NORMAL, ImageList)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
;Destruction de la liste d'images (la aussi pas certain que ce soit nécessaire)
ImageList_Destroy_(ImageList)
EndIf
Code : Tout sélectionner
Enumeration
#MainForm
#ToolBar
EndEnumeration
If OpenWindow(#MainForm, 0, 0, 500, 250, "Toolbar Personnalisé", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
;Taille des icones
IconSize = 32
;Quelques images
ico0 = ExtractIcon_(0, "shell32.dll", 43) ;Etoile
ico1 = ExtractIcon_(0, "shell32.dll", 44) ;Clé
ico2 = ExtractIcon_(0, "shell32.dll", 45) ;Dossier
ico3 = ExtractIcon_(0, "shell32.dll", 47) ;Cadenas
ico4 = ExtractIcon_(0, "shell32.dll", 23) ;Point d'interogation
If CreateToolBar(#ToolBar, WindowID(#MainForm))
;Récupération de la liste des images composant le toolbar
;https://msdn.microsoft.com/en-us/library/windows/desktop/bb787337(v=vs.85).aspx
ImageList = SendMessage_(ToolBarID(#ToolBar), #TB_GETIMAGELIST,0,0)
;Nouvelle taille
ImageList_SetIconSize_(ImageList, IconSize, IconSize)
;Envoie de la liste d'images au toolbar
SendMessage_(ToolBarID(#ToolBar), #TB_SETIMAGELIST, 0, ImageList)
;Auto Resize du Tool Bar
SendMessage_(ToolBarID(#ToolBar),#TB_AUTOSIZE, 0, 0)
;Ajout des boutons
ToolBarImageButton(1, ico0)
ToolBarImageButton(2, ico1)
ToolBarImageButton(3, ico2)
ToolBarImageButton(4, ico3)
ToolBarImageButton(5, ico4)
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Code : Tout sélectionner
Enumeration
#MainForm
#Tree
EndEnumeration
UsePNGImageDecoder()
;Petite police pour faire jolie mais pas obligatoire
If LoadFont(1, "Arial", 15)
SetGadgetFont(#PB_Default, FontID(1))
EndIf
If OpenWindow(#MainForm, 0, 0, 700, 500, "TreeGadget Large icon", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TreeGadget(#Tree, 10, 10, 680, 480)
;N'ayant pas le temps de faire quelques icones, je prends quelques icone de l'OS
If OSVersion() > #PB_OS_Windows_2000
OpenLibrary(0, "uxtheme.dll")
;Eventuellement on peut commenter ces deux lignes. A vous de voir
;commentez pour voir la différence
CallFunction(0, "SetWindowTheme", GadgetID(#Tree), @" ", @" ")
SetThemeAppProperties_(1)
CloseLibrary(0)
EndIf
;Taille des icones
IconSize = 32
;
ImageList = ImageList_Create_(IconSize, IconSize, #ILC_COLOR32 | #ILC_MASK, 0, 10)
; Create a blank NULL image for the list
ImageList_ReplaceIcon_(NewImageList, - 1, ExtractIcon_(0, "Shell32.dll", 0))
; Quelques icones de test extraites de shell32.dll
; ico0 = ExtractIcon_(0, "shell32.dll", 43) ;Etoile
; ico1 = ExtractIcon_(0, "shell32.dll", 44) ;Clé
; ico2 = ExtractIcon_(0, "shell32.dll", 45) ;Dossier
; ico3 = ExtractIcon_(0, "shell32.dll", 47) ;Cadenas
; ico4 = ExtractIcon_(0, "shell32.dll", 23) ;Point d'interogation
LoadImage(0,"mathIco.ico")
LoadImage(1,"stop.ico")
;AJoute des icone dans la liste d'icone
ImageList_AddIcon_(ImageList, ImageID(0))
ImageList_AddIcon_(ImageList, ImageID(1))
; ImageList_AddIcon_(ImageList, ico1)
; ImageList_AddIcon_(ImageList, ico3)
; ImageList_AddIcon_(ImageList, ico1)
;Création du tree-view
AddGadgetItem(#Tree, - 1, "Icon 43 ",ImageID(0), 0)
AddGadgetItem(#Tree, - 1, "Icon 44 ", ImageID(1), 0)
; AddGadgetItem(#Tree, - 1, "Icon 45 ", ico2, 0)
; AddGadgetItem(#Tree, - 1, "Icon 47 ", ico3, 0)
; AddGadgetItem(#Tree, - 1, "Icon 23 ", ico4, 1)
;
;Et destruction (Pas sur que ce soit nécessaire)
DestroyIcon_(ImageID(0))
DestroyIcon_(ImageID(1))
; DestroyIcon_(ico2)
; DestroyIcon_(ico3)
; DestroyIcon_(ico4)
;Le tour de magie
SendMessage_(GadgetID(#Tree), #TVM_SETIMAGELIST, #TVSIL_NORMAL, ImageList)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
;Destruction de la liste d'images (la aussi pas certain que ce soit nécessaire)
ImageList_Destroy_(ImageList)
EndIf
Code : Tout sélectionner
DeclareModule ToolBarCustom
Declare CreateToolBarCustom(toolbarid, windowid)
EndDeclareModule
Module ToolBarCustom
Procedure CreateToolBarCustom(toolbarid, windowid)
w = WindowWidth(windowid)
hh = 25
If ContainerGadget(toolbarid,-2,0,w+4,hh+5,#PB_Container_Flat)
xx = 5
yy =2
x1 = 2
If ButtonGadget(1,xx,yy,40,hh,"Bouton") : xx + GadgetWidth(1)+x1 : EndIf
If CreateImage(0, 20,20)
If StartDrawing(ImageOutput(0))
Circle(10,10,8,#Red)
StopDrawing()
EndIf
If ButtonImageGadget(2,xx,yy,hh,hh,ImageID(0))
xx + GadgetWidth(2)+x1
EndIf
If ButtonImageGadget(3,xx,yy,hh,hh,ImageID(0))
xx + GadgetWidth(3)+x1
EndIf
If ButtonImageGadget(4,xx,yy,hh,hh,ImageID(0))
xx + GadgetWidth(4)+x1
EndIf
EndIf
If ComboBoxGadget(10,xx, yy,50,hh)
AddGadgetItem(10, 0, "Jeux")
AddGadgetItem(10, 1, "Vidéo")
AddGadgetItem(10, 2, "Slip")
EndIf
CloseGadgetList()
EndIf
EndProcedure
EndModule
w = 1024
h= 768
OpenWindow(0, 0, 0, w, h, "Toolbar customized", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ToolBarCustom::CreateToolBarCustom(0,0)
UseModule ToolBarCustom
CreateToolBarCustom(0,0)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Code : Tout sélectionner
If OpenWindow(0, 0, 0, 400, 400, "Exemple...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
IconWidth=32
IconHeight=32
ButtonIconWidth=32
ButtonIconHeight=32
ButtonIconMargin=2*6
If CreateImage(0,IconWidth,IconHeight)
StartDrawing(ImageOutput(0))
Box(0,0,IconWidth,IconHeight,RGB(255,255,255))
Box(4,4,IconWidth-8, IconHeight-8,RGB(255,0,0))
StopDrawing();<
EndIf
If CreateMenu(0, WindowID(0))
MenuTitle("Fichier")
MenuItem(1, "Ouvrir" +Chr(9)+"Ctrl+O")
MenuItem(2, "Sauvegarder" +Chr(9)+"Ctrl+S")
MenuBar()
MenuItem(4, "Quit" +Chr(9)+"Alt+F4")
EndIf
ico0 = ExtractIcon_(0, "shell32.dll", 43) ;Etoile
ico1 = ExtractIcon_(0, "shell32.dll", 44) ;Clé
ico2 = ExtractIcon_(0, "shell32.dll", 45) ;Dossier
ico3 = ExtractIcon_(0, "shell32.dll", 47) ;Cadenas
ico4 = ExtractIcon_(0, "shell32.dll", 23) ;Point d'interogation
;CONTAINER 0
containerTB0=ContainerGadget(#PB_Any, 0, 0, 210, ButtonIconHeight+ButtonIconMargin)
;SetGadgetColor(containerTB0,#PB_Gadget_BackColor,$00ff00)
hTB0=CreateToolBar(0, GadgetID(containerTB0))
hOldIList = SendMessage_(hTB0, #TB_GETIMAGELIST, 0, 0);
hNewIList = ImageList_Duplicate_(hOldIList)
ImageList_Destroy_(hOldIList)
ImageList_SetIconSize_(hNewIList, IconWidth, IconHeight)
SendMessage_(hTB0, #TB_SETIMAGELIST, 0, hNewIList)
SendMessage_(hTB0, #TB_SETBITMAPSIZE, 0, IconWidth|IconHeight<<16)
SendMessage_(hTB0, #TB_SETBUTTONSIZE, 0, ButtonIconWidth|ButtonIconHeight<<16)
SendMessage_(hTB0, #TB_AUTOSIZE, 0, 0)
ToolBarImageButton(#PB_Any,ico0)
ToolBarImageButton(#PB_Any,ico1)
ToolBarImageButton(#PB_Any,ico2)
ToolBarSeparator()
ToolBarImageButton(#PB_Any,ico3)
ToolBarImageButton(#PB_Any,ImageID(0))
CloseGadgetList()
;CONTAINER 1
containerTB1=ContainerGadget(#PB_Any, 0, GadgetHeight(containerTB0), 210, ButtonIconHeight+ButtonIconMargin)
;SetGadgetColor(containerTB1,#PB_Gadget_BackColor,$00ff00)
hTB1=CreateToolBar(1, GadgetID(containerTB1))
hOldIList1 = SendMessage_(hTB1, #TB_GETIMAGELIST, 0, 0);
hNewIList1 = ImageList_Duplicate_(hOldIList1)
ImageList_Destroy_(hOldIList1)
ImageList_SetIconSize_(hNewIList1, IconWidth, IconHeight)
SendMessage_(hTB1, #TB_SETIMAGELIST, 0, hNewIList1)
SendMessage_(hTB1, #TB_SETBITMAPSIZE, 0, IconWidth|IconHeight<<16)
SendMessage_(hTB1, #TB_SETBUTTONSIZE, 0, ButtonIconWidth|ButtonIconHeight<<16)
SendMessage_(hTB1, #TB_AUTOSIZE, 0, 0)
ToolBarImageButton(#PB_Any,ico0)
ToolBarImageButton(#PB_Any,ico1)
ToolBarImageButton(#PB_Any,ico2)
ToolBarSeparator()
ToolBarImageButton(#PB_Any,ico4)
ToolBarImageButton(#PB_Any,ImageID(0))
CloseGadgetList()
PanelGadget(0, 8, GadgetY(containerTB1)+GadgetHeight(containerTB1)+50, 300, 100)
AddGadgetItem (0, -1, "Onglet 1")
;CONTAINER 2
containerTB2=ContainerGadget(#PB_Any, 0, 0, 210, ButtonIconHeight+ButtonIconMargin)
;SetGadgetColor(containerTB1,#PB_Gadget_BackColor,$00ff00)
hTB2=CreateToolBar(2, GadgetID(containerTB2))
;>>>>>delete the upper line
SendMessage_(hTB2,#TB_SETSTYLE,0,SendMessage_(hTB2,#TB_GETSTYLE,0,0)|#CCS_NODIVIDER)
hOldIList2 = SendMessage_(hTB2, #TB_GETIMAGELIST, 0, 0);
hNewIList2 = ImageList_Duplicate_(hOldIList2)
ImageList_Destroy_(hOldIList2)
ImageList_SetIconSize_(hNewIList2, IconWidth, IconHeight)
SendMessage_(hTB2, #TB_SETIMAGELIST, 0, hNewIList2)
SendMessage_(hTB2, #TB_SETBITMAPSIZE, 0, IconWidth|IconHeight<<16)
SendMessage_(hTB2, #TB_SETBUTTONSIZE, 0, ButtonIconWidth|ButtonIconHeight<<16)
SendMessage_(hTB2, #TB_AUTOSIZE, 0, 0)
ToolBarImageButton(#PB_Any,ico0)
ToolBarImageButton(#PB_Any,ico1)
ToolBarImageButton(#PB_Any,ico2)
ToolBarSeparator()
ToolBarImageButton(#PB_Any,ico4)
ToolBarImageButton(#PB_Any,ImageID(0))
CloseGadgetList()
AddGadgetItem (0, -1,"Onglet 2")
CloseGadgetList()
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 1
CloseWindow(0)
End
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf