Announcement

Collapse
No announcement yet.

Trouble implementing new PB 9 Toolbar

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

  • Trouble implementing new PB 9 Toolbar

    Can't seem to get the new DDT Toolbar control in PB 9.0 to work as advertised in the help documents. I can only get a normal and hot icon to appear. Any disabled icon never shows up.
    The sample "Toolbar.bas" seems to work only when using the XPtheme and the XPthemed icons in the sample icon folder. You can see what I mean if you recompile without the "1 24 "XPTheme.xml"" line in its RC file.... but before you recompile, create the missing pdis.ico file.
    I am interested in not having to XPtheme my app since the XPtheme creates extra space under the icons for a caption, which I don't necessarily always want.
    Has anyone experienced this? Can't figure out what I'm doing wrong. The help docs don't say that this toolbar control is only good for themed programs.

  • #2
    Bill,
    You are correct in commenting that the assigned Disabled icons are not displayed.
    The PBWin9 sample program shows a grayed, disabled version of the Normal icon (instead of the expected hdis.ico).
    (I edited the hnorm.ico icon with an icon editor just to be sure).

    I did the following in the .rc file to replace the missing icon before "De-Theming"..
    Code:
    301   icon    icons\odis.ico  //pdis.ico missing (and not used anyway)
    ..
    //1   24    "XPTheme.xml"
    When I did that, the toolbar still worked OK but with these differences:

    1. The grayed, disable version of the home button had no detail (just a dark grey mask of the shape)
    2. If Text$ = "" in the Toolbar Add Button statements, the buttons were drawn without extra space -
    unlike the buttons drawn when "Themed' which always had space for text under the icons.

    Did you report this behaviour to [email protected] ?
    Attached Files
    Rgds, Dave

    Comment


    • #3
      Dave,
      Thanks for checking this out! Wasn't sure if it was just something that I wasn't doing correctly. Got mixed results between Windows XP sp2 and doing the same thing on Vista. The toolbar is nice to use, just couldn't get the disabled icons to show. I'll report this to support.

      Comment


      • #4
        While we Are on the Subject of Toolbars

        While we are talking about toolbars, perhaps some one can explain why this doesn't work.

        Code:
          ' Create an imagelist for the normal toolbar buttons
          IMAGELIST NEW ICON 32, 32, 32, 4 TO hTBNorm
          IMAGELIST ADD ICON hTBNorm, "#100"            ' Normal Home button
          IMAGELIST ADD ICON hTBNorm, "#101"            ' Normal Print button
          IMAGELIST ADD ICON hTBNorm, "#102"            ' Normal Properties button
          IMAGELIST ADD ICON hTBNorm, "MyIcon.ico"     ' Test
        The documentation doesn't specifically state that you cannot mix resource stored and disk stored icons.

        IMAGELIST ADD ICON hLst, Icn$ [TO data&]

        An icon is added to the ImageList specified by hLst. With this syntax, the icon is specified by a name string (Icn$), which is the name of an embedded resource or a disk file. If the name string contains a period, it is presumed to be a disk file. Otherwise, an attempt is made to load it from a resource - if not found, it is then presumed to be a disk file. If the icon name is a numeric resource, it should be described with a leading pound sign ("#12345"). If the TO clause is included, the index position of the first added bitmap (starting with 1) is assigned to the variable designated by data&. If the operation fails, the value 0 is assigned.

        Comment


        • #5
          This worked for me..
          Code:
          ID_BTN_TEST  = 1004
          '                           ' Color depth (doesn't matter if mixed?
          '                              ' 4 Icons initially allowed for ("can grow beyond but.."
          ImageList New Icon 32, 32, 32, 4 To hTBNorm
          '..
          IMAGELIST ADD ICON hTBNorm, ".\Icons\MyIcon.ico"     ' Test
          '..
          ' Add the buttons to the toolbar
          '..                                      ' 4th icon
          Toolbar Add Button    hDlg, %ID_TOOLBAR, 4, %ID_BTN_TEST,  %tbstyle_button, "Test"
          '..etc
          Rgds, Dave

          Comment


          • #6
            Regarding the requirement of a theme manifest for the disabled icon to appear, this is from PowerBASIC Staff:
            The use of a disabled image bitmap is only supported using the XP or Vista common control versions, which require a manifest file to specify them. If you do not use the updated common controls then Windows will create a disabled image based on the enabled image for you. This is not a PowerBASIC bug, but just how Windows works.
            In the help file, TOOLBAR SET IMAGELIST doesn't mention the manifest requirement.

            Comment


            • #7
              I still have a problem with that.
              Using the manifest file with WinXP Home SP2, I modified the hnorm.ico (added 'N') and the results shown in the screen shots below prove that the disabled image is based on the normal (enabled) icon and NOT the expected icon (hdis.ico -no 'N').

              I don't have access to Vista to check what happens there. What do you see?
              Attached Files
              Rgds, Dave

              Comment


              • #8
                Dave - that's an interesting experiment. That must be why I'm getting some mixed and confusing results between the two systems. On XPsp2 the only icons that will even display a psuedo disabled icon, as you detected, are the ones in the sample folder. For other icons that I've tried, I get the gray box. On Vista, I'll get the psuedo disabled icons for other icons besides the ones supplied in the sample folder. I'm not an icon expert, so I'm not sure what the magic is in the icons supplied with the sample.
                Your findings also explain another thing I found. In the help docs:
                TOOLBAR SET IMAGELIST hDlg, id&, hLst, type&
                The IMAGELIST specified by hLst is attached to this TOOLBAR control. The value of type& specifies the type of IMAGELIST:
                0 Default images

                1 Disabled images

                2 Hot images
                I found that the type& number for the hot button (2) doesn't effect which icon becomes the hot icon. It is the ORDER that the TOOLBAR SET IMAGELIST code lines are in.
                For example I switched the order of the sample file to this:
                Code:
                ' Set the toolbars normal button images
                  TOOLBAR SET IMAGELIST hDlg, %ID_TOOLBAR, hTBNorm, 0
                     ' Set the toolbars hot button images
                  TOOLBAR SET IMAGELIST hDlg, %ID_TOOLBAR, hTBHot, 2
                     ' Set the toolbars disabled button images
                  TOOLBAR SET IMAGELIST hDlg, %ID_TOOLBAR, hTBDis, 1
                The result is that the disabled icons become the hot icons.

                Comment


                • #9
                  Using Disk Stored Icons

                  Thanks Dave

                  Code:
                  IMAGELIST ADD ICON hTBNorm, ".\Icons\MyIcon.ico"     ' Test
                  Works great!

                  Comment


                  • #10
                    It looks like 32bit icons work best in themed toolbars.

                    A decent Icon editor is handy here, eg AWicons will let you edit your icons, set the transparent colour, change the colour depth etc.
                    ( www.awicons.com the free 'Lite' version is all I need)

                    I'm still playing with the order of the Toolbar Set Imagelist statements but so far I see the same as you - it is the THIRD statement that determines which imagelist is used as 'hot', regardless of the 'type&' number.

                    I guess it is wrong to expect that 'Toolbar Set State' will actually switch between image lists (as opposed to rendering the normal icon to appear disabled / grayed etc).

                    But if that is the case, I wonder though how the icons in the 'disabled' Imagelist would otherwise be called upon?
                    'Normal' - whenever.. 'Hot' - when mouse pointer is over. 'Disabled' - when ??? Not yet clear to me
                    Rgds, Dave

                    Comment


                    • #11
                      An image from a disabled-imagelist is displayed when a toolbar button is disabled.
                      To support three imagelists, a toolbar must have the TBSTYLE_FLAT or the TBSTYLE_LIST style.
                      This stuff works using SDK, therefore, something is amiss.
                      Last edited by Dominic Mitchell; 19 Nov 2008, 06:16 PM.
                      Dominic Mitchell
                      Phoenix Visual Designer
                      http://www.phnxthunder.com

                      Comment


                      • #12
                        Originally posted by Dave Biggs View Post
                        'Normal' - whenever.. 'Hot' - when mouse pointer is over. 'Disabled' - when ??? Not yet clear to me
                        maybe "disabled" when the control is disabled, or maybe when the left button is down - like the IE close button? That actually has a "disabled look" when you have the left mouse button down.

                        Comment


                        • #13
                          Re: 'Themed' toolbar - no text space problem

                          Jeff of PwerBASIC support suggested a way to overcome Windows behaviour in regard to unwanted spaces in toolbar buttons when text isn't wanted..

                          > You can use the TB_SETBUTTONSIZE or the TB_SETBUTTONWIDTH messages to
                          > override the default button sizes imposed by Windows.

                          I tried this..
                          Code:
                          ...
                            Toolbar Add Button    hDlg, %ID_TOOLBAR, 3, %ID_BTN_PROP,  %tbstyle_button, "" '"Properties"
                            Control Send hDlg, %ID_TOOLBAR, %TB_SETBUTTONSIZE, 0, Mak(Long, 32, 32)
                            Control Send hDlg, %ID_TOOLBAR, %TB_AUTOSIZE, 0, 0
                          and it works OK on WinXP.

                          Still looking for an answer to how the images from a "Disabled" ImageList set can be used..
                          Rgds, Dave

                          Comment


                          • #14
                            Work around - Disabled ImageList

                            Jeff at PB support has come to the rescue again
                            This appears to be an issue in the compiler. R&D is looking into this now,
                            if this is found to be an issue in the compiler an update will be available in the near future.
                            As a work around you can use:
                            CONTROL SEND hdlg, %ID_TOOLBAR, %TB_SETDISABLEDIMAGELIST, 0, hTBDis
                            instead of:
                            TOOLBAR SET IMAGELIST hDlg, %ID_TOOLBAR, hTBDis, 1
                            Tried it with both 'Themed' and 'Regular' tool bars and it works fine!
                            Rgds, Dave

                            Comment


                            • #15
                              Missing Icon

                              Here is a replacement for the the icon that is missing from the PBWin90 samlple .\Toolbar\Icons\pdis.ico

                              It's not actually used in the sample but the compiler will complain that it is missing when you recompile the Toolbar.rc file.
                              Attached Files
                              Rgds, Dave

                              Comment

                              Working...
                              X