Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. small but high quality(color depth and pixel) toolbar? [modified]

small but high quality(color depth and pixel) toolbar? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++visual-studio
18 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Electronic75

    Hello mark, but I have seen many programs that have high quality small toolbars, I'm sure you have seen them too. they can't be 16x16, for example MS WORD or MS EXCEL,... there should be a way. of course if there are more than one way, I prefer shorter way :).

    L Offline
    L Offline
    led mike
    wrote on last edited by
    #9

    Electronic75 wrote:

    but I have seen many programs that have high quality small toolbars

    Yes people author those images. As Mark points out there is no "magic".

    1 Reply Last reply
    0
    • E Electronic75

      Hello mark, but I have seen many programs that have high quality small toolbars, I'm sure you have seen them too. they can't be 16x16, for example MS WORD or MS EXCEL,... there should be a way. of course if there are more than one way, I prefer shorter way :).

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #10

      Yes, what led mike and Zoltan stated :) It's going to depend on the quality of your resizing. For example, Photoshop will do a good job using interpolation, compared to letting Windows resize them, which may just remove pixels, resulting in poorer quality. Take a look at the resources in the Microsoft apps...they generally have many sizes authored for the same icons. The advantage of having a good art department :) Mark

      "Go that way, really fast. If something gets in your way, turn."

      E 1 Reply Last reply
      0
      • M Mark Salsbery

        Yes, what led mike and Zoltan stated :) It's going to depend on the quality of your resizing. For example, Photoshop will do a good job using interpolation, compared to letting Windows resize them, which may just remove pixels, resulting in poorer quality. Take a look at the resources in the Microsoft apps...they generally have many sizes authored for the same icons. The advantage of having a good art department :) Mark

        "Go that way, really fast. If something gets in your way, turn."

        E Offline
        E Offline
        Electronic75
        wrote on last edited by
        #11

        Mark, led mike and Zoltan, I tried Icon maker and also photoshop(differnt filters) but believe me result was catastrophic! It was much nicer if me who can't draw much nicer than a 5 years old, draw it from scratch! I'm not looking for a magic spell but some programming tricks so I can give 32x32 icons to CToolbar and CToolbar draw them at size of 16x16 toolbars. I still can't believe nice small icons in visual studio and MS office are really 16x16:omg:.

        M 1 Reply Last reply
        0
        • E Electronic75

          Mark, led mike and Zoltan, I tried Icon maker and also photoshop(differnt filters) but believe me result was catastrophic! It was much nicer if me who can't draw much nicer than a 5 years old, draw it from scratch! I'm not looking for a magic spell but some programming tricks so I can give 32x32 icons to CToolbar and CToolbar draw them at size of 16x16 toolbars. I still can't believe nice small icons in visual studio and MS office are really 16x16:omg:.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #12

          16x16 is 256 pixels - there's no way around it :) Some questions(so maybe we can come up with an acceptable solution): What is the format of your source "icons"... Bitmap or Icon? How many bits-per-pixel? Do they contain a transparent color or use alpha values? How are you setting the button bitmaps in the toolbar? Can you provide a code sample? Are you using TB_ADDBITMAP or an imagelist? Mark

          "Go that way, really fast. If something gets in your way, turn."

          E 1 Reply Last reply
          0
          • M Mark Salsbery

            16x16 is 256 pixels - there's no way around it :) Some questions(so maybe we can come up with an acceptable solution): What is the format of your source "icons"... Bitmap or Icon? How many bits-per-pixel? Do they contain a transparent color or use alpha values? How are you setting the button bitmaps in the toolbar? Can you provide a code sample? Are you using TB_ADDBITMAP or an imagelist? Mark

            "Go that way, really fast. If something gets in your way, turn."

            E Offline
            E Offline
            Electronic75
            wrote on last edited by
            #13

            Nice icons all in .ico format and high color for those that are really big (>30KB) and 8bit color(256color) those that are 766 bytes. for the moment lets forget high color, so we are talking about 256 color 32x32 .ico format that most of them do not have transparent colors. The way I use them is pretty much straight forward,in visual studio 2005 in Resource view under toolbar node, I add a toolbar then I copy the icon of button that I've already opened as icon resource and paste it over the button. The toolbar has an ID for example ID_MY_TOOLBAR. then I define a CToolbar member variable in CMainFrame and in OnCreate function I create my toolbar. m_barMyOwnToolBar.CreateEx(this, tbstyle-flat, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); m_barMyOwnToolBar.LoadToolBar(ID_MY_TOOLBAR); now if my original icons in toolbar are large 32x32 then toolbar will be large and if my original icon are 16x16 then my toolbar will be at right size. the problem is I want to load 32x32 but I want 16x16 size. still am I asking too much?:)

            M 1 Reply Last reply
            0
            • E Electronic75

              Nice icons all in .ico format and high color for those that are really big (>30KB) and 8bit color(256color) those that are 766 bytes. for the moment lets forget high color, so we are talking about 256 color 32x32 .ico format that most of them do not have transparent colors. The way I use them is pretty much straight forward,in visual studio 2005 in Resource view under toolbar node, I add a toolbar then I copy the icon of button that I've already opened as icon resource and paste it over the button. The toolbar has an ID for example ID_MY_TOOLBAR. then I define a CToolbar member variable in CMainFrame and in OnCreate function I create my toolbar. m_barMyOwnToolBar.CreateEx(this, tbstyle-flat, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); m_barMyOwnToolBar.LoadToolBar(ID_MY_TOOLBAR); now if my original icons in toolbar are large 32x32 then toolbar will be large and if my original icon are 16x16 then my toolbar will be at right size. the problem is I want to load 32x32 but I want 16x16 size. still am I asking too much?:)

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #14

              I personally have a problem with the LoadToolBar() method of constructing a toolbar - it alters the color table of the bitmap. It works great for 16-color bitmaps and RAD but I like control over my code :). For best results, I prefer to use an image list - it lets you specify a transparent color and supports 24-bit RGB bitmaps nicely. It takes a few extra steps, but the reward is complete control over your button bitmaps...

              // In this example, I'm creating a toolbar with 2 buttons. Each button bitmap is 16x16,
              // 32-bit ARGB 24-bit RGB. The transparent color is bright green...

              // In the parent window's .CPP file
              static TBBUTTON ToolBarButtonDescs[] =
              {
              {0, ID_BUTTON1, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
              {1, ID_BUTTON2, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0}
              };
              ...
              // In the parent window's constructor (m_ToolBarImageList is member variable CImageList m_ToolBarImageList; )
              // IDB_TOOLBARBITMAP is the ID of the bitmap resource to load into an image list
              CBitmap bitmap;
              bitmap.LoadBitmap(IDB_TOOLBARBITMAP);
              m_ToolBarImageList.Create(16, 16, ILC_COLOR24|ILC_MASK, 2, 1);
              m_ToolBarImageList.Add(&bitmap, RGB(0x00,0xFF,0x00));
              ...
              // In the parent window's OnCreate()/OnInitDialog()
              m_barMyOwnToolBar.CreateEx(this, TBSTYLE_FLAT,
              WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_FLYBY |
              CBRS_SIZE_DYNAMIC);
              m_barMyOwnToolBar.GetToolBarCtrl().SetImageList(&m_ToolBarImageList);
              m_barMyOwnToolBar.GetToolBarCtrl().AddButtons(2, ToolBarButtonDescs);

              Note that you need to create the bitmap for the imagelist. It needs to be 16 pixels high by (16 * numberofbitmaps) pixels wide. Create this bitmap with a good bitmap editor as mentioned before - your buttons will look like whatever you make the bitmap look like (unlike when you use LoadToolBar()). Also note that this works for me....I'm not saying it's the best method - it's just one example. I find it very flexible at the expense of a few extra ines of code. You don't have to use a 24-bit RGB bitmap for the imagelist. If you choose to use 256-color, create it something like: //CBitmap bitmap; //bitmap.LoadBitmap(IDB_TOOLBARBITMAP); //m_ToolBarImageList.Create(16, 16, ILC_COLOR24|ILC_MASK, 2, 1); //m_ToolBarImageList.Add(&bitmap, RGB(0x00,0xFF,0x00)); m_ToolBarImageList.Create(IDB_TOOLBARBITMAP, 16, 1, RGB(0x00,0xFF,0x00)); Hope you can extract som

              E 1 Reply Last reply
              0
              • M Mark Salsbery

                I personally have a problem with the LoadToolBar() method of constructing a toolbar - it alters the color table of the bitmap. It works great for 16-color bitmaps and RAD but I like control over my code :). For best results, I prefer to use an image list - it lets you specify a transparent color and supports 24-bit RGB bitmaps nicely. It takes a few extra steps, but the reward is complete control over your button bitmaps...

                // In this example, I'm creating a toolbar with 2 buttons. Each button bitmap is 16x16,
                // 32-bit ARGB 24-bit RGB. The transparent color is bright green...

                // In the parent window's .CPP file
                static TBBUTTON ToolBarButtonDescs[] =
                {
                {0, ID_BUTTON1, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0},
                {1, ID_BUTTON2, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0,0}, 0, 0}
                };
                ...
                // In the parent window's constructor (m_ToolBarImageList is member variable CImageList m_ToolBarImageList; )
                // IDB_TOOLBARBITMAP is the ID of the bitmap resource to load into an image list
                CBitmap bitmap;
                bitmap.LoadBitmap(IDB_TOOLBARBITMAP);
                m_ToolBarImageList.Create(16, 16, ILC_COLOR24|ILC_MASK, 2, 1);
                m_ToolBarImageList.Add(&bitmap, RGB(0x00,0xFF,0x00));
                ...
                // In the parent window's OnCreate()/OnInitDialog()
                m_barMyOwnToolBar.CreateEx(this, TBSTYLE_FLAT,
                WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_FLYBY |
                CBRS_SIZE_DYNAMIC);
                m_barMyOwnToolBar.GetToolBarCtrl().SetImageList(&m_ToolBarImageList);
                m_barMyOwnToolBar.GetToolBarCtrl().AddButtons(2, ToolBarButtonDescs);

                Note that you need to create the bitmap for the imagelist. It needs to be 16 pixels high by (16 * numberofbitmaps) pixels wide. Create this bitmap with a good bitmap editor as mentioned before - your buttons will look like whatever you make the bitmap look like (unlike when you use LoadToolBar()). Also note that this works for me....I'm not saying it's the best method - it's just one example. I find it very flexible at the expense of a few extra ines of code. You don't have to use a 24-bit RGB bitmap for the imagelist. If you choose to use 256-color, create it something like: //CBitmap bitmap; //bitmap.LoadBitmap(IDB_TOOLBARBITMAP); //m_ToolBarImageList.Create(16, 16, ILC_COLOR24|ILC_MASK, 2, 1); //m_ToolBarImageList.Add(&bitmap, RGB(0x00,0xFF,0x00)); m_ToolBarImageList.Create(IDB_TOOLBARBITMAP, 16, 1, RGB(0x00,0xFF,0x00)); Hope you can extract som

                E Offline
                E Offline
                Electronic75
                wrote on last edited by
                #15

                Thanks Mark, Though original problem persists but your way of attaching bitmaps difinately is better than mine, thanks. I have to solve this issue one way or another either programistic way(accomodate 32x32 bit icons in 16x16 place) or artistic way(work on my drawing skills to draw 16x16 icons that look really good).:)

                M 1 Reply Last reply
                0
                • E Electronic75

                  Thanks Mark, Though original problem persists but your way of attaching bitmaps difinately is better than mine, thanks. I have to solve this issue one way or another either programistic way(accomodate 32x32 bit icons in 16x16 place) or artistic way(work on my drawing skills to draw 16x16 icons that look really good).:)

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #16

                  Electronic75 wrote:

                  work on my drawing skills to draw 16x16 icons that look really good)

                  :laugh: Yeah....I'm not good at it....I just steal them right out of microsoft exe/dlls ;) Just kidding Microsoft! ;P

                  "Go that way, really fast. If something gets in your way, turn."

                  E 1 Reply Last reply
                  0
                  • M Mark Salsbery

                    Electronic75 wrote:

                    work on my drawing skills to draw 16x16 icons that look really good)

                    :laugh: Yeah....I'm not good at it....I just steal them right out of microsoft exe/dlls ;) Just kidding Microsoft! ;P

                    "Go that way, really fast. If something gets in your way, turn."

                    E Offline
                    E Offline
                    Electronic75
                    wrote on last edited by
                    #17

                    Mark Salsbery wrote:

                    I just steal them right out of microsoft exe/dlls

                    Don't ever look at the issue this way! every program that you write for MS-Windows platform causes many users of that program are being forced to use MS-Windows, so in fact you are a microsoft employee working for free for them. if something is being stealed it is from the other side!;)

                    M 1 Reply Last reply
                    0
                    • E Electronic75

                      Mark Salsbery wrote:

                      I just steal them right out of microsoft exe/dlls

                      Don't ever look at the issue this way! every program that you write for MS-Windows platform causes many users of that program are being forced to use MS-Windows, so in fact you are a microsoft employee working for free for them. if something is being stealed it is from the other side!;)

                      M Offline
                      M Offline
                      Mark Salsbery
                      wrote on last edited by
                      #18

                      Of course! That was just my public comments about the subject ;) *edit* Oh, and if anybody asks, I was never here...

                      "Go that way, really fast. If something gets in your way, turn."

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups