Toolbar & Splitter

Just starting out? Need help? Post your questions and find answers here.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Toolbar & Splitter

Post by Progi1984 »

This code runs ok on Linux : we see the toolbar and the content of the splitter

But on Windows, we just see the splitter without the toolbar. When the mouse goes up the location of the toolbar, icons appears.

Code: Select all

  If OpenWindow(0, 0, 0, 230, 210, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateToolBar(0, WindowID(0))
      ToolBarStandardButton(0, #PB_ToolBarIcon_New)
      ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
      ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
    EndIf
    If CreateGadgetList(WindowID(0))
      
      #Bouton1    = 0 
      #Bouton2    = 1
      #Separateur = 2
      
      ButtonGadget(#Bouton1, 0, 0, 0, 0, "Bouton 1") ; Inutile de préciser la taille ou les coordonnées
      ButtonGadget(#Bouton2, 0, 0, 0, 0, "Bouton 2") ; car elles seront déterminées automatiquement
      SplitterGadget(#Separateur, 5, 5, 220, 120, #Bouton1, #Bouton2, #PB_Splitter_Separator)
      
      TextGadget(3, 10, 135, 210, 70, "Le composant d'interface graphique ci-dessus affiche deux boutons automatiquement redimensionnés à l'intérieur de la zone séparée de taille 220x120.",#PB_Text_Center)
      
      Repeat 
      Until WaitWindowEvent() = #PB_Event_CloseWindow
    EndIf
  EndIf
And the fix (anti bug) :

Code: Select all

  If OpenWindow(0, 0, 0, 230, 210, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateToolBar(0, WindowID(0))
      ToolBarStandardButton(0, #PB_ToolBarIcon_New)
      ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
      ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
    EndIf
    If CreateGadgetList(WindowID(0))
      
      #Bouton1    = 0 
      #Bouton2    = 1
      #Separateur = 2
      
      ButtonGadget(#Bouton1, 0, 0, 0, 0, "Bouton 1") ; Inutile de préciser la taille ou les coordonnées
      ButtonGadget(#Bouton2, 0, 0, 0, 0, "Bouton 2") ; car elles seront déterminées automatiquement
      
      CompilerSelect #PB_Compiler_OS
        CompilerCase #PB_OS_Windows
          SplitterGadget(#Separateur, 5, 5+ToolBarHeight(0), 220, 120, #Bouton1, #Bouton2, #PB_Splitter_Separator)
        CompilerCase #PB_OS_Linux
          SplitterGadget(#Separateur, 5, 5, 220, 120, #Bouton1, #Bouton2, #PB_Splitter_Separator)
      CompilerEndSelect
      TextGadget(3, 10, 135, 210, 70, "Le composant d'interface graphique ci-dessus affiche deux boutons automatiquement redimensionnés à l'intérieur de la zone séparée de taille 220x120.",#PB_Text_Center)
      
      Repeat 
      Until WaitWindowEvent() = #PB_Event_CloseWindow
    EndIf
  EndIf