Page 1 of 1

Set Toolbar Size

Posted: Fri Jul 06, 2018 11:04 am
by andreasahlen
Hello,

I'm playing along with PureBasic for several days now to evaluate it. I created a Toolbar inside the UI designer. But I cannot find any property to set the Toolbar's height. On my current screen resolution all seems so small. Is there any way to set a default Toolbar.Height based on the current screen resolution (design time + runtime)?

Thanks a lot :)

Re: Set Toolbar Size

Posted: Fri Jul 06, 2018 11:09 am
by RSBasic
Is that what you mean?

Code: Select all

EnableExplicit

Define TBID

CreateImage(1, 32, 32, 24, 200)

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If CreateToolBar(0, WindowID(0))
    TBID = SendMessage_(ToolBarID(0), #TB_GETIMAGELIST, 0, 0)
    ImageList_SetIconSize_(TBID, 32, 32)
    SendMessage_(ToolBarID(0), #TB_SETIMAGELIST, 0, TBID)
    SendMessage_(ToolBarID(0), #TB_AUTOSIZE, 0, 0)
    ToolBarImageButton(1, ImageID(1))
    ToolBarImageButton(2, ImageID(1))
    ToolBarImageButton(3, ImageID(1))
  EndIf
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
(only Windows)

Re: Set Toolbar Size

Posted: Fri Jul 06, 2018 11:27 am
by RASHAD
Welcome
PureBasic is full with amazing functions
You will not regret it

Code: Select all

If OpenWindow(0, 0, 0, 400, 200, "ToolBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateToolBar(0, WindowID(0),#PB_ToolBar_Large|#PB_ToolBar_Text)
      ToolBarStandardButton(0, #PB_ToolBarIcon_New,#PB_ToolBar_Normal,"New")
      ToolBarStandardButton(1, #PB_ToolBarIcon_Open,#PB_ToolBar_Normal,"Open")
      ToolBarStandardButton(2, #PB_ToolBarIcon_Save,#PB_ToolBar_Normal,"Save")
    EndIf
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Menu
        Debug "ToolBar ID: "+Str(EventMenu())
      EndIf
    Until Event = #PB_Event_CloseWindow 
  EndIf

Re: Set Toolbar Size

Posted: Fri Jul 06, 2018 11:32 am
by RSBasic
Oops, I forgot PB could do that now. :D

Re: Set Toolbar Size

Posted: Fri Jul 06, 2018 11:38 am
by andreasahlen
Thank to both fo you. I will use these snippets as a starting point.