Announcement

Collapse
No announcement yet.

Icons?

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

  • Icons?

    I was reading through MSDN yesterday and something I read made me wonder - is there a resource file that is distributed with Windows from which I can pull icons for my PowerBASIC apps? I'm talking about plain old standard windows icons, such as save, open, etc.

    I know I can extract icons from EXE/DLLs, and I've seen the content of the moricons.dll file. But I've never heard/seen of a pool of standard icons that is distributed with Windows.

    Normally, I just use a collection of icons that I've built up over the years. With PowerBASIC I can put them in a resource file just fine - but it would be way cool if there was a pool of icons I could pull into my PowerBASIC apps by using files already on my users' PCs.

    Has anyone heard of such a thing, something I've missed?

  • #2
    %SystemRoot%\system32\SHELL32.dll contains a good selection, but it probably varies a bit with Windows version.

    Comment


    • #3
      moricons.dll has been around for some time too. You can also use Explorer.exe and Progman.exe.
      sigpic
      Mobile Solutions
      Sys Analyst and Development

      Comment


      • #4
        - is there a resource file that is distributed with Windows from which I can pull icons for my PowerBASIC apps? I'm talking about plain old standard windows icons, such as save, open, etc.
        comctl32.dll has several toolbar bitmaps that comprise those 'standard icons'.

        Download the code samples for PBWin8.03 and take a look at the toolbar sample for an example of how they
        are accessed. http://www.powerbasic.com/files/pub/...%20Samples.zip

        In that example the IDB_STD_LARGE_COLOR bitmap is added to the toolbar and sections of it are used to populate
        the toolbar's TBBUTTON structures.

        CommCtrl.inc contains equates (e.g. %STD_FILESAVE and %STD_FILEOPEN) that are used as indexes to the standard
        images.

        See the SDK docs for TBADDBITMAP Structure info.

        There are a number of other standard icons and cursors available too. See the %IDI_ and %IDC_ equates in win32api.inc.
        (I think these 'system' icons and cursors reside in user32.dll).
        See LoadCursor and LoadIcon function descriptions in the SDK docs for more info.
        Rgds, Dave

        Comment


        • #5
          Thanks Dave,
          I'll follow your leads.

          Comment


          • #6
            Dave, and follow it I did (yes, I know it's months later).

            I looked for a toolbar example early on, but the PBWin9 toolbar example used a totally DDT approach, using a PBR to create an imagelist - whereas the PBWin8 example showed a more-or-less SDK approach (direct API) that used the standard bitmaps found in comctl32.dll. The approach I was interested in got left out of the updated example.

            So at the time, I didn't have any idea what to do with your comment, but as I got more experience with PowerBASIC the v8 example made sense.

            So today I created the DDT code below that shows how to use the comctl32.dll bitmaps in a toolbar - updated to PBWin9 syntax.

            Note that I had to INCR the Include equates because the DDT Toolbar Add Button statement is 1-based, wheres the MSDN equates are zero-based.

            I didn't experiment, but I'd guess I could add my own icons to those of the standard bitmap, plus use more than one of the comctrl32.dll bitmaps (there are 3 small and 3 large) at the same time to get a larger selection of icons?

            Code:
            'Compilable Example:
            #Compile Exe
            #Dim All
            #Include "Win32API.inc"
            #Include "CommCtrl.inc" 
            Global hDlg As Dword, hLst As Dword, hToolbar as Dword
            %IDC_Toolbar = 700
            Function PBMain()
               'create dialog
               Dialog New Pixels, 0, "Toolbar Test",,, 500,250, %WS_SysMenu, To hDlg
               'add toolbar
               Control Add Toolbar, hDlg, %IDC_Toolbar,"", 0,0,0,0
               Control Handle hDlg, %IDC_Toolbar to hToolbar
               'add standard bitmaps to imagelist
               Dim BMP As TBADDBITMAP
               BMP.hInst = %HINST_COMMCTRL
               BMP.nID = %IDB_STD_SMALL_COLOR
               Control Send hDlg, %IDC_Toolbar, %TB_ADDBITMAP, 0, VarPTR(BMP)
               'create buttons
               Toolbar Add Button hDlg, %IDC_Toolbar, %STD_FILENEW+1, 200, %TbStyle_Button, "New"
               Toolbar Add Button hDlg, %IDC_Toolbar, %STD_FILEOPEN+1, 201, %TbStyle_Button, "Open"
               'show the dialog
               Dialog Show Modal hDlg Call DlgProc
            End Function
            
            CallBack Function DlgProc() As Long
               If CB.Msg = %WM_Command AND CB.Ctl = 200 Then MsgBox "New"
               If CB.Msg = %WM_Command AND CB.Ctl = 201 Then MsgBox "Open"
            End Function
            Thanks again for your response.

            Comment


            • #7
              I tried to merge two of the standard bitmaps in order to increase the selection. I tried both ORing and +ing the equates for the comctl32.dll bitmaps. I also tried sending the %TB_AddBitmap message twice, once for each of the bitmaps I wanted to include, but neither approach worked.

              Code:
                 BMP.nID = %IDB_HIST_SMALL_COLOR Or %IDB_STD_SMALL_COLOR
              And now that I'm looking, it also not clear how I would add an image of my own (to the iimagelist created from the standard bitmap) using the DDT ImageList Add Icon. The command requires the imagelist handle, which I'm not sure how to get.

              Rats ...

              Once I have all of the standard icons in a PBR of my own, perhaps the usefulness of using the comctrl32.dll bitmaps is marginal. But it does ensure that I use the OS default icons (which may or may not be good).

              I was hoping for a much more expanded list of icons to draw on than is contained in the comctl32.dll bitmaps.

              Comment


              • #8
                The loadimage, loadicon, loadcursor and loadbitmap functions (LoadImage is kind of the new one encompassing the other three) have options to load "standard" bitmaps, icons and cursors, using the constants beginning with OBM_ (OEM bitmaps), OIC_ (OEM icons) and OCR_ (OEM cursors).

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

                Comment


                • #9
                  >..merge two of the standard bitmaps..
                  This might help Gary..
                  Code:
                  'Compilable Example:
                  #Compile Exe
                  #Dim All
                  #Include "Win32API.inc"
                  #Include "CommCtrl.inc" 
                  Global hDlg As Dword, hLst As Dword, hToolbar as Dword, hBmp As Dword
                  %IDC_Toolbar = 700
                   
                  Function PBMain()
                     ' create dialog
                     Dialog New Pixels, 0, "Toolbar Test",,, 500,250, %WS_SysMenu, To hDlg
                     ' add toolbar
                     Control Add Toolbar, hDlg, %IDC_Toolbar,"", 0,0,0,0
                     Control Handle hDlg, %IDC_Toolbar to hToolbar
                     ' add bitmaps to imagelist
                     Dim BMP  As TBADDBITMAP
                     Dim BMP2 As TBADDBITMAP
                     Dim BMP3 As TBADDBITMAP
                   
                     BMP.hInst = %HINST_COMMCTRL        ' System defined 'standard' bitmaps
                     BMP.nID   = %IDB_STD_SMALL_COLOR
                   
                     BMP2.hInst = %HINST_COMMCTRL       ' System defined 'standard' bitmaps
                     BMP2.nID   = %IDB_HIST_SMALL_COLOR
                   
                     hBmp = LoadImage(0, "16x16.bmp", %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)  ' 16x16.bmp in app folder
                     BMP3.hInst = 0                     ' User supplied bitmap
                     BMP3.nID   = hBmp
                   
                   
                   
                     Control Send hDlg, %IDC_Toolbar, %TB_ADDBITMAP, 0, VarPTR(BMP)           ' add to list of button images 
                     ' create buttons from fist toolbar bitmap (%STD_CUT to %STD_PRINT)
                     Toolbar Add Button hDlg, %IDC_Toolbar, %STD_FILENEW+1, 200, %TbStyle_Button, "New"
                     Toolbar Add Button hDlg, %IDC_Toolbar, %STD_FILEOPEN+1, 201, %TbStyle_Button, "Open"
                   
                     Control Send hDlg, %IDC_Toolbar, %TB_ADDBITMAP, 0, VarPTR(BMP2)          ' add to list of button images
                     ' create buttons from second toolbar bitmap  (%HIST_BACK to %HIST_FORWARD)
                     Toolbar Add Button hDlg, %IDC_Toolbar, %STD_PRINT+1 + %HIST_BACK+1, 202, %TbStyle_Button, "Back"
                     Toolbar Add Button hDlg, %IDC_Toolbar, %STD_PRINT+1 + %HIST_FORWARD+1, 203, %TbStyle_Button, "Forward"
                   
                     Control Send hDlg, %IDC_Toolbar, %TB_ADDBITMAP, 0, Varptr(BMP3)          ' add to list of button images
                     ' create button from individual bitmap added to end of image list
                     Toolbar Add Button hDlg, %IDC_Toolbar, %STD_PRINT+1 + %HIST_VIEWTREE+1 + 1, 204, %TbStyle_Button, "Your Btn"
                   
                     'show the dialog
                     Dialog Show Modal hDlg Call DlgProc
                    DeleteObject hBmp                                                         ' Free bitmap resources
                  End Function
                   
                  CallBack Function DlgProc() As Long
                     If CB.Msg = %WM_Command AND CB.Ctl = 200 Then MsgBox "New"
                     If CB.Msg = %WM_Command AND CB.Ctl = 201 Then MsgBox "Open"
                     If CB.Msg = %WM_Command AND CB.Ctl = 202 Then MsgBox "Back"
                     If CB.Msg = %WM_Command AND CB.Ctl = 203 Then MsgBox "Forward"
                     If CB.Msg = %WM_Command AND CB.Ctl = 204 Then MsgBox "Etcetera"
                  End Function
                  Use something like ResHacker http://www.snapfiles.com/get/resourcehacker.html to have a look at the
                  standard bitmaps that are in ComCtl32.dll.
                  Rgds, Dave

                  Comment


                  • #10
                    Dave,

                    I see. Instead of ANDing or ORing sources, you just sent the ADD_BITMAP message multiple times to accumulate images. I didn't try that. I would have guessed that each new message would replace the previous bitmap.

                    What you showed was just what I asked. Thanks!

                    But, when I tried to see if DDT would replace the LoadImage statement:

                    Code:
                       Graphic Bitmap Load "16x16.bmp", 16, 16 TO hBMP  'file is loaded, but not visible
                    vs
                       hBmp = LoadImage(0, "16x16.bmp", %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)  ' 16x16.bmp in app folder
                    The LoadImage lines works, and the Graphic Bitmap line does not (image does not appear in toolbar button).

                    Are the two statements not equivalent?

                    Comment


                    • #11
                      MCM,

                      The loadimage, loadicon, loadcursor and loadbitmap functions (LoadImage is kind of the new one encompassing the other three) have options to load "standard" bitmaps, icons and cursors, using the constants beginning with OBM_ (OEM bitmaps), OIC_ (OEM icons) and OCR_ (OEM cursors).
                      Thanks for the clarification of the API options. I see in MSDN that the LoadImage is preferred now over the other 3 API.

                      Does the resulting handle point to the same structure type as created by Graphic Bitmap Load? In the prior post you can see that I wasn't successful in getting Graphic Bitmap Load to simply replace the LoadImage line.

                      Comment


                      • #12
                        Does the resulting handle point to the same structure type as created by Graphic Bitmap Load
                        Handles do not "point" to anything. Handles are handles.

                        I believe the 'handle' returned by GRAPHIC BITMAP LOAD is a proprietary handle. But being a handle it does not point to anything, either.
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          MCM,

                          Yes, possibly confusing use of "point" on my part. A handle is simply a number "assigned" to an object. Had I said "a handle is a pointer to ..." then I'd definitely have been off mark. "Point" is too close to "pointer".

                          The question, however, was whether a handle generated by Graphic Bitmap Load can be used with the %TB_AddBitMap message.

                          While my own test said no, that could easily be because I didn't know how to do it.

                          Comment


                          • #14
                            The best way to answer the question once and for all woujld be for PowerBASIC to put some kind statement in the help file as to whether of not the handle returned by GRAPHIC BITMAP LOAD is a Windows' handle to a bitmap.

                            I can't find anything in help one way or the other. But I am almost postive this came up here before and the answer was, no, those handles are for use only with other GRAPHICS statements.

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

                            Comment


                            • #15
                              FWIW, "handle" is one of those words (along with "window," "process," " thread.." and others ) which simply cannot be carelessly tossed around in a Windows' programming forum.
                              Michael Mattias
                              Tal Systems (retired)
                              Port Washington WI USA
                              [email protected]
                              http://www.talsystems.com

                              Comment


                              • #16
                                MCM,

                                ...which simply cannot be carelessly tossed around in a Windows' programming forum.
                                The sentiment is certainly valid. In fact, two issues I had when starting out (or even last week) in the forums was finding an single definition of "SDK-style programming", and with separating out the various ways in which "message" was commonly used.

                                There's technically correct, and then there's commonly used. The first is preferred, the second is more common . (Oh, what a bad joke that is!)

                                Comment


                                • #17
                                  MCM,

                                  Well, I thought it was discussed too, but couldn't find the thread.

                                  I'll send a note to Support and see what they say.

                                  I continue to be amazed when one of my seemingly basic questions hasn't been answered a zillion times, or wasn't covered in Help. I keep thinking that the answer must be around here somewhere, but darned if I can find it. Surely other newbies, those who came to PBWin in 2008 would have beaten me to some of the questions I asked.

                                  I have seen a number of cases where a relatively new-comer to PowerBASIC talks about the hours spent getting to a solution of a problem. I'm all for self-help, but as I've said a lot I also don't like re-inventing the wheel!

                                  It must be a throwback to my hand-held days of VB6.

                                  And by the way, I'm not just whining without being willing to be part of the solution. I'll be releasing a freeware code librarian next week, written in PowerBASIC of course, with over 300 snippets of PowerBASIC code and reference material. I'll have the code categorized and available online as well. My return for what's been received.

                                  Comment


                                  • #18
                                    I keep thinking that the answer must be around here somewhere, but darned if I can find it. Surely other newbies, those who came to PBWin in 2008 would have beaten me to some of the questions I asked.
                                    A lot of these things will be easier to find when posters start tagging the words they think are important in their posts. Especially the short 2 and 3 letter words, so the searchers aren't muttering so many 4 letter words.
                                    Rod
                                    In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                                    Comment


                                    • #19
                                      Gary,

                                      The TBADDBITMAP structure doesn't seem to like being fed a bitmap handle created with GRAPHIC BITMAP LOAD.
                                      However if we get the handle of the toolbar's internal imageList with TB_GETIMAGELIST it seems we can
                                      use IMAGELIST ADD BITMAP with the GRAPHIC BITMAP LOAD handle and avoid using TB_ADDBITMAP with VarPTR(TBADDBITMAP)..

                                      Code:
                                      'Compilable Example:
                                      #Compile Exe
                                      #Dim All
                                      #Include "Win32API.inc"
                                      #Include "CommCtrl.inc" 
                                      Global hDlg As Dword, hLst As Dword, hToolbar as Dword, hBmp As Dword
                                      %IDC_Toolbar = 700
                                       
                                      Function PBMain()
                                         ' create dialog
                                         Dialog New Pixels, 0, "Toolbar Test",,, 500,250, %WS_SysMenu, To hDlg
                                         ' add toolbar
                                         Control Add Toolbar, hDlg, %IDC_Toolbar,"", 0,0,0,0
                                         Control Handle hDlg, %IDC_Toolbar to hToolbar
                                       
                                         ' add bitmaps to imagelist  - using TB_LOADIMAGES (seems a bit more direct to me)
                                       
                                        Control Send hDlg, %IDC_Toolbar, %TB_LOADIMAGES, %IDB_STD_SMALL_COLOR, %HINST_COMMCTRL 'To Res
                                        Control Send hDlg, %IDC_Toolbar, %TB_LOADIMAGES, %IDB_HIST_SMALL_COLOR, %HINST_COMMCTRL 'To Res
                                       
                                       '  hBmp = LoadImage(0, "16x16.bmp", %IMAGE_BITMAP, 0, 0, %LR_LOADFROMFILE)  ' 16x16.bmp in app folder
                                        GRAPHIC BITMAP LOAD "16x16.bmp", 16, 16 TO hBmp    ' seems PB can handle (oops!) this bitmap either way
                                       
                                        Control Send hDlg, %IDC_Toolbar, %TB_GETIMAGELIST, 0, 0 To hLst   ' handle of image list created by API
                                        IMAGELIST ADD BITMAP hLst, hBmp                                   ' using PB statement here
                                       
                                         ' create buttons from list section comprising first toolbar bitmap (%STD_CUT to %STD_PRINT)
                                         Toolbar Add Button hDlg, %IDC_Toolbar, %STD_FILENEW+1, 200, %TbStyle_Button, "New"
                                         Toolbar Add Button hDlg, %IDC_Toolbar, %STD_FILEOPEN+1, 201, %TbStyle_Button, "Open"
                                       
                                         ' create buttons from list section comprising second toolbar bitmap  (%HIST_BACK to %HIST_VIEWTREE)
                                         Toolbar Add Button hDlg, %IDC_Toolbar, %STD_PRINT+1 + %HIST_BACK+1, 202, %TbStyle_Button, "Back"
                                         Toolbar Add Button hDlg, %IDC_Toolbar, %STD_PRINT+1 + %HIST_FORWARD+1, 203, %TbStyle_Button, "Forward"
                                       
                                         ' create button using individual bitmap added to end of image list
                                         Toolbar Add Button hDlg, %IDC_Toolbar, %STD_PRINT+1 + %HIST_VIEWTREE+1 + 1, 204, %TbStyle_Button, "Your Btn"
                                       
                                         'show the dialog
                                         Dialog Show Modal hDlg Call DlgProc
                                       '  DeleteObject hBmp                                   ' Free bitmap resources
                                        Graphic Attach hBmp, 0                                ' Alt. if loaded with Graphic statement
                                        Graphic Bitmap End                                    ' 
                                      End Function
                                       
                                      CallBack Function DlgProc() As Long
                                         If CB.Msg = %WM_Command AND CB.Ctl = 200 Then MsgBox "New"
                                         If CB.Msg = %WM_Command AND CB.Ctl = 201 Then MsgBox "Open"
                                         If CB.Msg = %WM_Command AND CB.Ctl = 202 Then MsgBox "Back"
                                         If CB.Msg = %WM_Command AND CB.Ctl = 203 Then MsgBox "Forward"
                                         If CB.Msg = %WM_Command AND CB.Ctl = 204 Then MsgBox "Etcetera"
                                      End Function
                                      It is probably worth asking PB though if this approach might cause problems as we seem to be mix 'n matching API created handles
                                      with PB satements with the kind of abandon that will make a few here quite nervous

                                      BTW I suppose most would build their own toolbar (maybe with images cut 'n pasted from Windows standard toolbars).
                                      For that you would should check out Toolbar Paint http://www.snapfiles.com/get/toolbarpaint.html.
                                      Rgds, Dave

                                      Comment


                                      • #20
                                        Dave,

                                        Argggh! Well, I've been using DDT generate handles for dialogs and controls in API all over the place. I guess it was a bad assumption that all PowerBASIC handles are equivalent to API generated handles, or that PowerBASIC generated handles can be used whereever an API handle is needed. What other handles might be involved?

                                        I don't recall seeing anything in Help about this issue.

                                        That certainly doesn't sound like something one would do intentionally. I sent in a question to Support on the topic.

                                        I'll re-send with the results you just showed.

                                        Thanks!
                                        Last edited by Gary Beene; 16 Aug 2009, 10:02 AM.

                                        Comment

                                        Working...
                                        X