Announcement

Collapse
No announcement yet.

Toolbars 101

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

  • Toolbars 101

    Am I missing a core concept (or document) about Toolbars? It seems
    that searching POFFS and the forums that all the examples using toolbars use the same icons
    (like %STD_DELETE and %IDM_SAVE)

    I know the %STD and %IDM are key letters but as to what I don't know (guessing %STD means standard though) %IDM I am not sure of but its in practically every example)

    My key question is where to find out this info and how to make a toolbar using my own custom icons?

    Preferably I would like to load my *.pbr file with icons and then create a toolbar that uses these icons

    Any ideas?

    ------------------
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

  • #2
    The toolbar has four builtin bitmaps which it can use for icons:

    IDB_STD_LARGE_COLOR
    IDB_STD_SMALL_COLOR
    IDB_VIEW_LARGE_COLOR
    IDB_VIEW_SMALL_COLOR

    You can select any one of these by sending the TB_ADDBITMAP
    message to the control.

    You can also select your own user define bitmap by sending this
    message too.

    Toolbars do not use Bitmaps or icons directly !

    They use ImageLists !

    The TB_ADDBITMAP message simply selects a bitmap which is then
    added to the internal imagelist.

    Toolbar Bitmaps are simply a row of icon images side by side.
    For example if you has 24 x 24 pixels icons and has 10 of them
    the bitmap would be 240 x 24 pixels in size.

    As you add more bitmaps, they are simply appended to the internal
    imagelist.

    You define system colors in your bitmap see the LoadImage function
    info in the API docs. There it defines 3 system colors:

    rgb(128,128,128)
    rgb(192,192,192)
    rgb(223,223,223)

    which can be converted to the actual system colors, when LoadImage
    is used with the LR_LOADMAP3DCOLORS flag.

    Once you have your bitmap in memory with your icons, you can use
    the TB_ADDBITMAP message to add the bitmap to the toolbars
    internal imagelist.

    You can also convert your bitmaps directlt to imagelists and then
    define that in the toolbar as an external imagelist using the
    TB_SETIMAGELIST message.




    ------------------
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment


    • #3
      I would recommend downloading the freeware program:

      ToolBar Paint

      http://www.assembler.ca

      It is an amazing piece of work and it makes creating toolbar
      bitmaps easy !

      You should also be able to find info about building plugins for
      it and there is a template for building plugins using Powerbasic
      (which I sent the author). I haven't made any plugins myself yet,
      but with a little effort one could do some interesting things
      with it.



      ------------------
      Chris Boss
      Computer Workshop
      Developer of "EZGUI"
      http://cwsof.com
      Chris Boss
      Computer Workshop
      Developer of "EZGUI"
      http://cwsof.com
      http://twitter.com/EZGUIProGuy

      Comment


      • #4
        The toolbar has four builtin bitmaps which it can use for icons:

        IDB_STD_LARGE_COLOR
        IDB_STD_SMALL_COLOR
        IDB_VIEW_LARGE_COLOR
        IDB_VIEW_SMALL_COLOR
        Well, yes and no.
        The toolbar is part of the common control DLL (COMCTL32.DLL) which contains resources
        such as bitmaps and strings. Six of those bitmap resources are used by the toolbar. Also,
        a programmer can access these bitmaps directly using EnumResourceNames and LoadBitmap/LoadImage,
        or just LoadBitmap/LoadImage with the appropriate resource ID.

        The bitmaps are organized as follows:
        Code:
           
                Bitmaps               |     ID in CommCtrl.in     |  Resource ID in COMCTL32.DLL
        ------------------------------|---------------------------|-----------------------------
        "standard" small color images | IDB_STD_SMALL_COLOR  (0)  |             0
        "standard" large color images | IDB_STD_LARGE_COLOR  (1)  |             1
        "view" small color images     | IDB_VIEW_SMALL_COLOR (4)  |             2
        "view" large color images     | IDB_VIEW_LARGE_COLOR (5)  |             3
        "history" small color images  | IDB_HIST_SMALL_COLOR (8)  |             4
        "history" large color images  | IDB_HIST_LARGE_COLOR (9)  |             5
        The resource IDs are useful to apps such as visual designers. IDB_XXX are the identifiers used
        when working with the toolbar via the toolbar messages(TB_XXX).

        Use TB_SETIMAGELIST when working with the toolbar. TB_ADDBITMAP is too limited. Its color depth is limited
        to 8 bpp and it cannot use icons.


        ------------------
        Dominic Mitchell
        Phoenix Visual Designer
        http://www.phnxthunder.com
        Dominic Mitchell
        Phoenix Visual Designer
        http://www.phnxthunder.com

        Comment


        • #5
          >Any ideas?

          Just for the hell of it, I tried search, "toolbar", forum "Source Code" , subject only, all dates.

          While I didn't 'drill down' and view all the hits, the titles of the postings did find sure indicate that many of the answers you seek are right here.

          Michael Mattias
          Tal Systems Inc. (retired)
          Racine WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            I have posted a thread in my forum that covers the subject in detail,
            with lots of examples ready to compile, including the use of image lists,
            dropdown buttons, floating toolbars, vertical toolbars, popup toolbars,
            double toolbars, placing a combobox in the toolbar, and toolbar customization.

            Also links to download free image lists generators and sets of free icons.
            As my forum allows attachments, the examples aren't limited to the use
            of the STD_XXX buttons, but also use bitmap strips for the image lists.

            http://www.forum.it-berater.org/index.php?topic=384.0


            ------------------
            Website: http://com.it-berater.org
            SED Editor, TypeLib Browser, COM Wrappers.
            Forum: http://www.forum.it-berater.org

            [This message has been edited by José Roca (edited October 23, 2006).]
            Forum: http://www.jose.it-berater.org/smfforum/index.php

            Comment


            • #7
              Three cheers for Jose!

              ------------------

              Comment


              • #8
                Thanks all,
                I didn't realize the Imagelist concept, I thought as I added buttons, that I link each one to a bitmap (either from memory or from harddrive)

                I guess the examples were somewhat vauge (or it just did not click in my head what was really being done)

                ------------------
                Engineer's Motto: If it aint broke take it apart and fix it

                "If at 1st you don't succeed... call it version 1.0"

                "Half of Programming is coding"....."The other 90% is DEBUGGING"

                "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                Comment


                • #9
                  you can make a toolbar bitmap strip from icons: http://www.powerbasic.com/support/pb...ad.php?t=23258

                  ------------------
                  regards,
                  peter
                  Regards,
                  Peter

                  Comment


                  • #10
                    That's awesome work Jose!

                    To complete a really good tutorial, how about using the DockiT demo with a toolbar?
                    Just need to add the toolbar code...
                    http://www.powerbasic.com/files/pub/...ls/Dock-It.zip

                    Regards,
                    Jules



                    ------------------
                    Best regards
                    Jules
                    www.rpmarchildon.com

                    Comment


                    • #11
                      If you're more comfortable with buttons with images, you can make something which "looks like" a toolbar using the BS_PUSHLIKE style...

                      I haven't tried it, but you might be able to get images on these buttons by adding style BS_BITMAP and setting the picture with the BM_SETIMAGE message..

                      Code:
                      ' Test_pushlike_button.bas
                      ' 7.12.06  Test program for usernotes functions
                      ' pretty cool effect! Can't believe I never tried this before!
                      ' 7.14.06   Add a set of four option buttons, mututally exclusive
                      
                      #COMPILE  EXE
                      #DEBUG    ERROR ON
                      #REGISTER NONE
                      #DIM      ALL
                      #TOOLS    OFF
                      
                      %NOMMIDS = 1
                      %NOGDI  = 1
                      #INCLUDE "WIN32API.INC"
                      
                      %ID_PUSH         = 101
                      %ID_EXIT         = 102
                      %ID_OPTION_BASE  = 200
                      
                      
                      FUNCTION PBMAIN() AS LONG
                      
                      
                          LOCAL hDLG AS LONG, Style AS LONG, I AS LONG
                      
                          DIALOG NEW  0, "Pushlike Button Demo", 50, 100, 100, 120  TO hDlg
                          Style = %WS_CHILD OR %WS_VISIBLE OR %BS_CHECKBOX OR %BS_PUSHLIKE OR %WS_TABSTOP
                          CONTROL  ADD BUTTON, hDlg, %ID_PUSH,    "Off", 5, 20, 40, 14, Style
                          CONTROL  ADD BUTTON, hDlg, %ID_EXIT   , "Done", 55, 20, 40, 14
                          ' 1.19.06   Create a set of mututally exclusive option buttons with same style
                      
                          CONTROL ADD LABEL, HDlg, -1&, "Pick one",  5, 72, 60, 12
                          FOR I = 1 TO 4
                              IF I = 1 THEN  ' start the option group...
                                  Style = %WS_CHILD OR %WS_VISIBLE OR %BS_AUTORADIOBUTTON OR %BS_PUSHLIKE OR %WS_TABSTOP OR %WS_GROUP
                              ELSE           ' continue it
                                  Style = %WS_CHILD OR %WS_VISIBLE OR %BS_AUTORADIOBUTTON OR %WS_TABSTOP OR %BS_PUSHLIKE  ' no group
                              END IF
                              CONTROL ADD BUTTON, hDlg, %ID_OPTION_BASE+I, FORMAT$(I),  5 + (I-1) * 20, 85, 18,15, Style
                          NEXT
                      
                      
                          DIALOG SHOW MODAL hDlg, CALL DialogProc
                      
                      
                      END FUNCTION
                      
                      CALLBACK FUNCTION DialogPRoc() AS LONG
                      
                       LOCAL iCheck AS LONG , w AS STRING, I AS LONG
                      
                          SELECT CASE AS LONG CBMSG
                              CASE %WM_INITDIALOG
                                    ' nothing to do
                                    ' pre-select option three of "toolbar"
                                    CONTROL SET CHECK CBHNDL, %ID_OPTION_BASE+3, 1   ' control # 3, state = checked
                      
                              CASE %WM_COMMAND
                                  SELECT CASE AS LONG CBCTL
                      
                                      CASE %ID_PUSH   ' toggle the status
                                          CONTROL GET CHECK CBHNDL, %ID_PUSH TO iCheck
                                          CONTROL SET CHECK CBHNDL, %ID_PUSH, IIF&(iCheck, 0,1)
                                          CONTROL SET TEXT  CBHNDL, %ID_PUSH, IIF$(iCheck, "Off", "On")
                                          ' try setting color when on? Cannot get this to work
                                          ' that's because buttons don't work with CONTROL SET COLOR. (requires
                                          ' ownerdraw buttons). Documented limitation.
                                          'CONTROL SET COLOR  CBHNDL, %ID_PUSH, IIF& (ICheck, -1&, %YELLOW), -2&
                                          'CONTROL REDRAW CBHNDL, %ID_PUSH
                      
                                      CASE %ID_EXIT
                                          ' show status at exit for both On-Off and option
                                          CONTROL GET CHECK CBHNDL, %ID_PUSH TO iCheck
                                          W  = "On/Off button is " & IIF$(iCheck, "On", "Off")
                                          FOR I = 1 TO 4
                                              CONTROL GET CHECK CBHNDL, %ID_OPTION_BASE + I TO iCheck
                                              IF iCheck THEN
                                                  W = W & $CRLF & USING$("Option # is selected", I)
                                                  EXIT FOR
                                              END IF
                                          NEXT
                                          MSGBOX W,,"Status at exit"
                      
                                          DIALOG END CBHNDL, 0
                      
                                   END SELECT
                           END SELECT
                      
                      END FUNCTION
                      Michael Mattias
                      Tal Systems Inc. (retired)
                      Racine WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment

                      Working...
                      X