Page 1 sur 1

Centrer le contenu d'une barre d'outils

Publié : lun. 04/avr./2011 18:31
par anissa
Bonjour,

Pensez-vous qu'il serait possible de centrer (ou définir la colonne) d'un gadget d'une barre d'outils?

Exemple:

Code : Tout sélectionner

If CreateToolBar(0, WindowID(0))
   ToolBarImageButton(5, "Icone1.ico")
   ToolBarImageButton(5, "Icone2.ico")
   ToolBarImageButton(5, "Icone3.ico")
EndIf
Dans cet exemple, mes 3 icones seront alignées à l'extrême gauche. Serait-il possible de les mettre un peu plus à droite ?

Merci de votre aide

Anissa

Re: Centrer le contenu d'une barre d'outils

Publié : lun. 04/avr./2011 18:34
par anissa
Merci de corriger svp: l'image id de 1 à 3 des icones..

(erreur de frappe !)

Code : Tout sélectionner

 If CreateToolBar(0, WindowID(0))
   ToolBarImageButton(1, "Icone1.ico")
   ToolBarImageButton(2, "Icone2.ico")
   ToolBarImageButton(3, "Icone3.ico")
EndIf

Re: Centrer le contenu d'une barre d'outils

Publié : lun. 04/avr./2011 18:59
par falsam
j'utilise une astuce qui fait bricolage mais qui fonctionne.

Code : Tout sélectionner

Enumeration
  #MainForm
  #Barico
EndEnumeration

Procedure MainFormShow()
  OpenWindow(#MainForm,0,0,400,400,"Barre Icone",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
  CreateToolBar(#Barico, WindowID(#MainForm))
  For i=0 To 6
    ToolBarImageButton(i, ImageID( CreateImage(#PB_Any,10,10)))
    DisableToolBarButton(#Barico, i, #True)
  Next
  
  ToolBarStandardButton(0, #PB_ToolBarIcon_New)
  ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
  ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
  
EndProcedure

MainFormShow()

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Gadget

    Case #PB_Event_CloseWindow
      End
  EndSelect
ForEver

Re: Centrer le contenu d'une barre d'outils

Publié : mar. 05/avr./2011 9:55
par Kwai chang caine
Ou peut etre ce code de TROND :roll:

Code : Tout sélectionner

Procedure StopToolbarAutoAlign(Toolbar) 
  T = ToolBarID(0) 
  SetWindowLong_(T, #GWL_STYLE, GetWindowLong_(T, #GWL_STYLE) | #CCS_NODIVIDER) 
  SetWindowLong_(T, #GWL_STYLE, GetWindowLong_(T, #GWL_STYLE) | #CCS_NOPARENTALIGN) 
  SetWindowLong_(T, #GWL_STYLE, GetWindowLong_(T, #GWL_STYLE) | #CCS_NORESIZE) 
EndProcedure 

OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 
CreateToolBar(0, WindowID(0)) 
ToolBarStandardButton(0, 0) 
ToolBarStandardButton(0, 1) 
ToolBarStandardButton(0, 2) 
ToolBarStandardButton(0, 3) 


StopToolbarAutoAlign(0) 
T = ToolBarID(0) 

MoveWindow_(ToolBarID(0), 100, 100, 512, 22, 1) 

Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_CloseWindow 
      Break 
  EndSelect 
ForEver

Re: Centrer le contenu d'une barre d'outils

Publié : mar. 05/avr./2011 10:29
par falsam
ça fait moins bricolage que mon astuce :p Allez ..... j'enfourne ce code dans ma malle.

Re: Centrer le contenu d'une barre d'outils

Publié : mar. 05/avr./2011 12:46
par anissa
Merci de votre aide, je vais essayer ce soir les deux méthodes (bien que la deuxième me semble plus indiquée).

Je vous mettrais au courant des résultats

Anissa

Re: Centrer le contenu d'une barre d'outils

Publié : mar. 05/avr./2011 18:09
par jbernard13
Merci pour le code
je le recupere