Page 1 sur 2
Question pour les Toolbar()
Publié : sam. 15/mai/2004 10:00
par Guimauve
Comment forcer les ToolBars à utiliser des icônes 32X32 au lieu de 16X16 ?
Je veux dire des ToolBarImageButton(#Bouton1, UseImage(#Image)) bien sûr.
Merci à l'avance
A+
Guimauve
Publié : sam. 15/mai/2004 22:32
par Guimauve
J'ai trouvé la documentation pour les Barres d'outil
MSDN a écrit :Toolbar styles Description
TBSTYLE_AUTOSIZE Calculates a button width based on the text of the button, not on the size of the image.
TBSTYLE_BUTTON Creates a toolbar button that looks like a standard Windows CE push button.
TBSTYLE_CHECK Creates a button that toggles between the pressed and not pressed states each time the user clicks it. The button has a different background color when it is in the pressed state.
TBSTYLE_CHECKGROUP Creates a check button that stays pressed until another button in the group is pressed.
TBSTYLE_CUSTOMERASE Creates a toolbar that generates NM_CUSTOMDRAW notification messages when it processes WM_ERASEBKGND messages.
TBSTYLE_DROPDOWN Creates a drop-down list button.
TBSTYLE_FLAT Creates a flat toolbar, in which both the toolbar and the buttons are transparent. Button text appears under button bitmaps.
TBSTYLE_GROUP Creates a button that stays pressed until another button in the group is pressed.
TBSTYLE_LIST Places button text to the right of button bitmaps. This style can only be used with the TBSTYLE_FLAT style. In Windows CE, the TBSTYLE_LIST style creates a toolbar with variable width buttons. If you want to use the TBSTYLE_LIST style with fixed width buttons, you can override the default behavior by sending a TB_SETBUTTONSIZE or TB_SETBUTTONWIDTH message.
TBSTYLE_SEP Creates a separator, which provides a small gap between button groups. A button that has this style does not receive user input.
TBSTYLE_TOOLTIPS Creates a ToolTip control that an application can use to display descriptive text for the buttons in the toolbar.
TBSTYLE_TRANSPARENT Creates a transparent toolbar, in which the toolbar is transparent, but the buttons are not. Button text appears under button bitmaps.
TBSTYLE_WRAPABLE Creates a toolbar that can have multiple rows of buttons. Toolbar buttons can wrap to the next line when the toolbar becomes too narrow to include all buttons on the same line. Wrapping occurs on separation and non-group boundaries.
Apparamment c'est possible avec un SendMessage_().
A+
Guimauve
Publié : sam. 15/mai/2004 23:00
par Le Soldat Inconnu
et avec la lib machin (me rapelle plus du nom, Denis, aide moi) de Danilo, on peut pas faire des barres d'outils avec des gros boutons ? (vive l'acné

)
Publié : dim. 16/mai/2004 0:09
par Guimauve
Merd... Ça fait 6 heures que je VARGE la code pour que ça marche.
Elle s'appelle PureTool la lib en question de Danilo.
Une bonne douche et on reprend le tout demain.
A+
Guimauve
Publié : dim. 16/mai/2004 6:20
par Anonyme2
Les Toolbars utilisent des ImagesList qui sont définies avec une taille X et Y pour toutes les images qu'elles contiennent.
Il faudrait faire des essais en récupérant le Handle de listimage immédiatement après avoir utilisé ToolBarImageButton puis en redimensionnant les tailles de la liste. Après avoir été redimensionnée, la liste est vide, il faut donc réutiliser ToolBarImageButton avec l'image utilisée précédement. Ca pourrait marcher.
Publié : dim. 16/mai/2004 7:15
par Guimauve
Le format Icone n'est pas supporté dans la lib de Danilo. Faudrait s'amuser à défaire les icônes en 2, le masque sur un fichier et l'image sur un autre fichier. Il faut passer les 2 handles à la commande SetTBimage( hImage , hMask , #TYPE_of_TB-Image ). Je suis pas vraiment intéressé...
TBSTYLE_LIST Places button text to the right of button bitmaps. This style can only be used with the TBSTYLE_FLAT style. In Windows CE, the TBSTYLE_LIST style creates a toolbar with variable width buttons. If you want to use the TBSTYLE_LIST style with fixed width buttons, you can override the default behavior by sending a TB_SETBUTTONSIZE or TB_SETBUTTONWIDTH message.
Quand je lis ça, je comprends qu'il faut faire quelque chose du genre :
hToolbar = CreateToolBar(... , ...) et plus loin dans le code
SendMessage_(hToolbar,#TBSTYLE_LIST | #TB_SETBUTTONSIZE,32,0)
Mais ça marche pas, moi et l'API Windows...
Si je me fie à ce qui est dis plus haut c'est la commande CreateToolBar() qui contrôle la grosseur des boutons. Si on charge des images ou des icônes qui font déja 24X24 ou 32X32 le système fait un resize de l'image. Donc si on lui envoi un message pour lui dire qu'on veut des gros boutons 32X32 ça deverait marcher.
Dans MS Internet Explorer, on peut choisir entre des grosses ou des petites icônes pour la toolbar, avoir l'étiquette texte, changer la position du texte, etc. Donc c'est possible.
Si quelqu'un trouve l'astuce avant moi ... SVP
Merci à l'avance.
A+
Guimauve
Publié : dim. 16/mai/2004 7:39
par Anonyme2
En fait, il y a 2 façons de faire soit avec une imageList soit avec des Bitmaps.
Tu utilises quoi, des images perso ?
Publié : dim. 16/mai/2004 8:22
par Guimauve
Je charge les images comme ceci :
Code : Tout sélectionner
ListeIcone$(#Icone_Nouveau) = "Icônes\New Doc.ico"
ListeIcone$(#Icone_Ouvrir) = "Icônes\Browse 3.ico"
ListeIcone$(#Icone_Sauver) = "Icônes\Save.ico"
ListeIcone$(#Icone_Couper) = "Icônes\Cut.ico"
ListeIcone$(#Icone_Copier) = "Icônes\Copy.ico"
ListeIcone$(#Icone_Coller) = "Icônes\Paste.ico"
ListeIcone$(#Icone_Annuler) = "Icônes\Back 2.ico"
ListeIcone$(#Icone_Retablir) = "Icônes\Forward 2.ico"
ListeIcone$(#Icone_Quitter) = "Icônes\Stop 2.ico"
For Icone = #Icone_Nouveau To #Icone_Quitter
LoadImage(Icone, ListeIcone$(Icone))
Next
Et la ToolBar comme ceci :
Code : Tout sélectionner
If CreateToolBar(#BarreOutil, WindowID(#Fenetre))
ToolBarImageButton(#Nouveau,UseImage(#Icone_nouveau))
ToolBarToolTip(#Nouveau, TexteGUI$(#Menutxt07))
ToolBarImageButton(#Ouvrir, UseImage(#Icone_Ouvrir))
ToolBarToolTip(#Ouvrir, TexteGUI$(#Menutxt08))
ToolBarImageButton(#Sauver, UseImage(#Icone_Sauver))
ToolBarToolTip(#Sauver, TexteGUI$(#Menutxt09))
ToolBarSeparator()
ToolBarImageButton(#Couper, UseImage(#Icone_Couper))
ToolBarToolTip(#Couper, TexteGUI$(#Menutxt01))
ToolBarImageButton(#Copier, UseImage(#Icone_Copier))
ToolBarToolTip(#Copier, TexteGUI$(#Menutxt02))
ToolBarImageButton(#Coller, UseImage(#Icone_Coller))
ToolBarToolTip(#Coller, TexteGUI$(#Menutxt03))
ToolBarSeparator()
ToolBarImageButton(#Annuler, UseImage(#Icone_Annuler))
ToolBarToolTip(#Annuler, TexteGUI$(#Menutxt04))
ToolBarImageButton(#Retablir, UseImage(#Icone_retablir))
ToolBarToolTip(#Retablir, TexteGUI$(#Menutxt05))
ToolBarSeparator()
ToolBarImageButton(#Quitter, UseImage(#Icone_Quitter))
ToolBarToolTip(#Quitter, TexteGUI$(#Menutxt21))
EndIf
Présentement les icônes font 16X16. Et il y a une icône pour chaque bouton. Et chaque icône contient le format 16X16, 24X24,32X32, 48X48, 64X64,96X96 et 128X128, des icônes au format XP. Pour les besoins de la cause je vais garder seulement le format 24X24 ou 32X32.
C'est ça mon problème.
A+
Guimauve
Publié : dim. 16/mai/2004 14:20
par Anonyme2
Essaye ce bout de code qui change la taille des images.
Sous WIn98, je n'ai pas un bon résultat (mes icônes font 16x16) mais je n'ai pas essayé sous XP
Le code est à adapter pour tes images
Code : Tout sélectionner
#Fenetre = 0
#BarreOutil = 1
#TB_SETIMAGELIST = 1072
If OpenWindow(#Fenetre, 0, 0, 200, 320, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Toolbars 32x32")
ShowWindow_(WindowID(), #SW_MAXIMIZE)
ToolBarHwnd = CreateToolBar(1, WindowID())
; on charge l'imae
LoadImage(1000, "")
If ToolBarHwnd
; on récupère le handle de la listimage si elle existe
ListImageHwnd = SendMessage_(ToolBarHwnd, #TB_GETIMAGELIST, 0, 0)
If ListImageHwnd
; on redimensionne la taille des images de la listimage en 32x 32
; après redimensionnement, la listeIlmage est vide
If ImageList_SetIconSize_(ListImageHwnd, 32, 32)
; si ImageList_SetIconSize réussi, le resultat retourné est <> 0
; on ajoute la première image puisque la liste est vide
ToolBarImageButton(1001 , UseImage(1000))
; etc ...
EndIf
EndIf
Else
End
EndIf
While WaitWindowEvent() <> #PB_EventCloseWindow And EventWindowID() <> WindowID()
Wend
EndIf
End
Publié : dim. 16/mai/2004 17:22
par Guimauve
J'ai un petit problème, la constante #TB_GETIMAGELIST n'est pas défini. Quelle est sa valeur ?
Guimauve
Publié : dim. 16/mai/2004 17:27
par Chris
#WM_USER + 49
WM_USER est défini dans PB: valeur 1024
Chris

Publié : dim. 16/mai/2004 17:41
par Guimauve
Denis ton code semble fonctionner pour la taille des boutons mais pas la taille de la toolbar. Donc si la hauteur du bouton dépasse 20 environ, le bouton est coupé.
Il faut envoyer 2 messages, 1 pour la dimension des boutons et un autre pour la hauteur de la Toolbar.
Je verrai ça durant la semaine prochaine.
A+
Guimauve
Publié : dim. 16/mai/2004 21:31
par Anonyme2
On devrait pouvoir redimensionner facilement la fenêtre ToolBar.
Je regarde ça demain
Publié : lun. 17/mai/2004 8:52
par Anonyme2
Je pense qu'il n'est pas possible de changer la hauteur de la Toolbar créée par PB car voici ce que dit la doc MS
Specifying Toolbar Size and Position
If you create a toolbar using CreateToolbarEx, the function enables you to specify in pixels the height and width of the toolbar. However, the CreateWindowEx function does not have parameters for specifying toolbar size. The toolbar window procedure automatically sets the size and position of the toolbar window. The height is based on the height of the buttons in the toolbar. The width is the same as the width of the parent window's client area. To change the automatic size settings, send a TB_SETBUTTONSIZE message. The CCS_TOP and CCS_BOTTOM common control styles determine whether the toolbar is positioned along the top or bottom of the client area. By default, a toolbar has the CCS_TOP style.
J'ai d'abord essayé l'API MoveWindow() pour redimensionner en récupérant les infos avec l'API GetWindowInfo() mais la Toolbar n'était pas redimensionnée. J'ai consulté la doc et là, donc il faut envoyer un message TB_SETBUTTONSIZE avant d'envoyer des images pour dimensionner la hauteur de la Toolbar.
J'ai fait des essais immédiatement après avoir créé la Toolbar mais ça ne marche pas.
J'ai utilisé ce code
Code : Tout sélectionner
TailleBouton = 32
TailleBouton << 16 + 32
Debug TailleBouton
Debug SendMessage_(ToolBarHwnd, #TB_SETBITMAPSIZE, 0, TailleBouton)
Si quelqu'un trouve, je prend
Il ne reste plus qu'à créer la toolbar puis à gérer tous les événements dans une callback
Publié : lun. 17/mai/2004 9:53
par Chris
J'ai testé un peu aussi, j'arrive à redimensionner les boutons, mais pas les images. (C'est comme toi, je pense

)
Code : Tout sélectionner
Hauteur = 72
Largeur = 72
hImage_0 = CreateImage(0,72,72)
StartDrawing(ImageOutput())
Box(0,0,72,72,RGB($0,$0,$FF))
StopDrawing()
hImage_1 = CreateImage(1,72,72)
StartDrawing(ImageOutput())
Box(0,0,72,72,RGB($FF,$0,$0))
StopDrawing()
If OpenWindow(0, 100, 200, 195, 260, #PB_Window_SystemMenu | #PB_Window_SizeGadget, "ToolBar example")
hToolBar = CreateToolBar(0, WindowID())
SendMessage_(hToolBar, #TB_SETBUTTONSIZE, 0, Largeur + (Hauteur<<16))
ToolBarImageButton(5, hImage_0)
ToolBarImageButton(10, hImage_1)
;SendMessage_(hToolBar, #TB_SETBITMAPSIZE, 0, Largeur + (Hauteur<<16))
If CreateMenu(0, WindowID())
MenuTitle("")
; MenuItem(0, "New")
; MenuItem(1, "Open")
; MenuItem(2, "Save")
EndIf
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_EventMenu
MessageRequester("Information", "ToolBar or Menu ID: "+Str(EventMenuID()), 0)
Case #PB_EventCloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
End
Par contre, dans ce code, (piqué dans les exemples de PB), si je retire le menu, les boutons ne sont redimensionnés que sur la largeur, alors que, si je le laisse, même vide, ils sont redimensionnés sur la hauteur et sur la largeur.
Chris
