Announcement

Collapse
No announcement yet.

Toolbar code questions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Toolbar code questions

    As you can probably tell by my threads, I'm working my way one by one through the controls, trying to pull out what I can from Help, looking at the samples, experimenting on my own, and drawing from forum folks. I've been putting the results at my site, in the PowerBASIC tutorials section while it's fresh in my mind.

    I'm looking at toolbar code tonight.

    This code doesn't create separators as Help says it will. Does anyone know why?

    Code:
    #Compile Exe
    #Dim All
    
    Function PBMain()
        
        Dim hDlg As Dword
        Dialog New Pixels, 0, "Test",,, 300,150, %ws_overlappedwindow , To hDlg
        Control Add Toolbar, hdlg, 500,"", 0,0,0,0, %ws_ex_staticedge
        Toolbar Add Button    hdlg, 500, 0, 1, %tbstyle_button,"X"
        Toolbar Add Separator hdlg, 500, 100
        Toolbar Add Button    hdlg, 500, 0, 2, %tbstyle_button,"Y"
        Toolbar Add Separator hdlg, 500, 100
        Toolbar Add Button    hdlg, 500, 0, 3, %tbstyle_button,"Z"
        Dialog Show Modal hdlg
        
    End Function
    Here's what I get:



    The separators are in the wrong place and are buttons, not empty pixels.

    I can use Add Button with &tbstyle_sep and get somewhat better results, but %tbstyle isn't documented in Help. It (and others that are not listed in Help) are listed in *.inc but with minimal comments.

    I also expected to see a way to select text and/or image display, but didn't see any such style. What I did find out was that if text = "" for all toolbar buttons, the toolbar itself thins down. But if any one button is "", all text on the toolbar is empty. But I didn't see how to thin the toolbar if no images are selected (imagelist index = 0 is what I tried).

    All of this was in just minutes of starting on the code. I suspect there are most questions right around the corner - some pretty basic stuff.

    If anyone has a more complex example to look through, I'm all eyes.

    I can tell that writing a tutorial on toolbars will involve plenty of legwork to get the whole pictures. That seems to happen a lot with PB topics.

  • #2
    Toolbar styles are described in the win32 api helpfile...
    Regards,
    Peter

    Comment


    • #3
      It looks like it is a clear case for PB support. - please report.
      The Toolbar Add Separator statement is not functioning as documented.
      Unless I am missing something it the help file as well.

      Try this:
      Code:
          Control Add Toolbar, hDlg, 500,"", 0,0,0,0, %ccs_top, %ws_ex_staticedge
          Toolbar Add Button hDlg, 500, 0, 101, %tbstyle_button,"X"
      '    Toolbar Add Separator hdlg, 500, 100
          Toolbar Add Button hDlg, 500, 0,0, %tbstyle_sep, ""
          Toolbar Add Button hDlg, 500, 0, 102, %tbstyle_button,"Y"
      '    Toolbar Add Separator hdlg, 500, 100
          Toolbar Add Button hDlg, 500, 0,0, %tbstyle_sep, ""
          Toolbar Add Button hDlg, 500, 0, 103, %tbstyle_button,"Z"
      
          Local datav&
          Toolbar Get Count hDlg, 500 To datav&
          MsgBox "ToolBar count = " + Str$(datav&), %mb_ok Or %mb_taskmodal
      Now try it with the Add Separator statements enabled (with or without the "add button......%tbstyle_sep" statements) and then see the number of buttons found.

      Even if the size of the separator is 100, 300, 10 or anything, the separator "buttons" is still displayed the same size.
      The size is derived from the button size, which is determined by the size of the text.
      A toolbar automatically sets the width of its buttons when you add a string to the toolbar that is longer than any current toolbar string. The width is set to accommodate the longest string in the toolbar.
      Try giving one button the text of " ZZZZZZZZZZZZZZZZ" and see what it does.

      It seems that the Toolbar Add Separator somehow confuses the toolbar when it is added as a weird/unknown/funny "button" :confused2:
      Andre Jacobs
      "The problem with Computers is that they do what you tell them, not what you want them to"

      Comment

      Working...
      X