Click here to Skip to main content
Click here to Skip to main content

Toolbar Editor for Visual Studio

By , 31 Oct 2012
 

Introduction

I usually spend a lot of time to give my projects a nice and user friendly GUI. In my opinion, in all desktop projects, it's "almost" mandatory to give the user something that can speed-up functions that are frequently used. The simpler (and most commonly used) method is to build a toolbar. Visual Studio comes with a toolbar editor but, really, I hate it; it's still limited to 16 colors, it can't load external images, and every time you want to add a new button, it is a pain. For all these reasons, I wrote my own toolbar editor for the Visual Studio IDE.

Installation

Simply run the setup, and follow the on-screen instructions (nothing more than the usual: next, next, yes, yes, next, finish). The setup utility of Toolbar Editor (TE) will also create two subdirectories: temp and imgLib. You can put all icons / images that you frequently use to build your toolbars in the imgLib directory: they will be displayed and previewed in TE so you can easily drop them in the toolbar on which you are currently working on. The default location of the two folder is:
[USERAPPDATA]\tbeditor 
(that in a standard Windows 7 installation is something like: C:\Users\username\AppData\Roaming\tbeditor)
In any case the location of these folders can be easly  customized by the dedicated option in the options dialogbox. 
To manage correctly the toolbar buttons ID, you should also specify where to found the afxres.h file. Toolbar Editor, starting from the 1.6 version, will try to found it by itself but, in the case it fails, you should select it manually. Please see the "Limitation of the toolbar editor" section for more information about this topic. 

How it Works

You can start to edit toolbars in a very few steps:

  • Open the resource file (.rc) of the project that you want to edit (or create a new toolbar)
  • Select the resource ID from the combo box.
  • Click on "Scan" button to get the preview of the currently loaded toolbar.
  • Edit the toolbar 
  • Merge the modification to the resource file using the “SAVE TOOLBAR” button 

 

Now you can add new buttons, move around the existing ones, and so on. Both the toolbar and the listbox used for preview supports drag & drop, so you can easily move buttons using your mouse. On the right side of the dialog window, there is a listbox that you can use as a library; it reads all supported types of images from a folder (remember that,if you want, you can change it in the Options Dialog) so you can take them and drop on the toolbar (you can also drop new images from the Explorer window). If the image loaded is too big (or too small), you can use the Resize function from the main menu.

When your toolbar is ready, you can click on the "SAVE TOOLBAR" button to merge it with your project: all needed IDs will be created and added to the resource.h file. If you don't want to modify your project files, you can disable this feature, and the new files will only be created in the temp folder of the editor. By default, the bitmap generated has a 4 bit color depth (16 colors) to maintain the preview active in the Visual Studio editor also, but it's possible to create grayed, true color, and "hot" bitmaps.


The bitmaps will be created in the ./res folder of the currently open project. By default, their names are the same as the toolbar's bitmap, with the _TC, _HT, and _GR suffix, but you can change both the destination folder and the name. You can add these bitmaps to your project, and then use them with some true color toolbar class like Dany Cantin's CTrueColorToolbar.

Let's say that YOUR_BITMAP_TC, YOUR_BITMAP_HT, and YOUR_BITMAP_GR are the IDs of these bitmaps, then you can use them in your OnCreate like:

m_ToolBar.LoadTrueColorToolBar(
        16,
        YOUR_BITMAP_TC,
        YOUR_BITMAP_HT, 
        YOUR_BITMAP_GR);

You should always create the true color bitmap because when you will open the toolbar again for editing, it will be used to create the imagelist instead of the 16 color version. Note that this will work only if the true color bitmap is saved using the default name bitmap_name_TC.bmp.

Finally, if you need only the imagelist, you can save it using the Save button in the bitmap section. This won't update .rc or resource.h in your project.

Creating New Toolbars

Even if you are creating a new toolbar, you need a resource file to put it in. For this reason, remember to open the right resource file before starting to work on the new toolbar. After you select "New" on the "File" menu (or you click on the "New" button in the main TE toolbar), the Toolbar Editor will ask for essential info about the toolbar: ID, size, and type (Visual C++ 20XX or Visual C++ 6).


The toolbar ID can also be a new one (not previously defined in your resource.h) but be careful: TE won't check if what you typed is a valid ID name, so avoid spaces, special chars, and so on...). After this point, you can work as previously described and, when you are ready, merge the toolbar with the "Generate" button, or copy the toolbar code to the clipboard using the menu entry Tools->Toolbar->Copy to clipboard.

Points of Interest 

Well, first of all, I hope that this tool is really useful for someone else other than me. You can also find a custom implementation of a drag and drop enabled toolbar (it works without the Shift button pressed).

Limitations of the Toolbar Editor

There are some considerations about IDs. My editor reads the toolbar structure from the .rc file, and the IDs defined in your project in the resource.h file: it doesn't know anything about any ID defined in other files. So be careful when you edit IDs in the Toolbar editor: if you use an ID already defined somewhere else than resource.h, it can be a problem during compilation.
As a backup solution consider that TbEditor can read IDs defined in other files just adding them in the file list available in the option dialog box. 


Just a note: The setup package doesn't come with afxres.h because I don't know if that file is copyrighted by Microsoft and/or if it's redistributable. A function to automatically found this file in your system is available and used by TBEditor but please consider that is not 100% accurate.
To put in your .rc file the new toolbars, TE uses as marker, this text: // Toolbar. If TE can't find the marker in your file, the merging of new toolbars will fail (note that this is a problem only for new toolbars).

Guidelines to Compile Toolbar Editor

Toolbar editor need Davide Pizzolato's CxImage class to compile.
This class is used to build, change resolution, color depth, etc. of bitmaps.
The tbeditor solution it's configured to look for CxImage in the same directory where you put the tbeditor folder. In other words, your directory structure should be something similar to:

main folder 
| 
|-- tbeditor source directory 
|-- CxImage 
|-- jpeg 
|-- j2k 
|-- jbig 
|-- jasper 
|-- tiff 
|-- png 
|-- zlib

where j2k, jpeg, jbig, etc. are all folders that came in the same archive of CxImage.
The latest sources version can always be found on the sourceforge repository

Credits 

My work was inspired by Tomkat'ss [^] great tool (Super ImageList and ToolBar generator [^]) that helped me a lot in the imagelist creation before I developed my own tool. I wish to also thank:

History

  • 1.0 - (2005/08/02)
    • First public release
  • 1.1 - (2005/08/03)
    • Fixed some compatibility issues with VC6
  • 1.2 - (2005/08/05)
    • Now it's possible to parse more files with IDs
    • Linked statically to avoid dependency problems
    • Changed true color bitmap generation checkbox to true as default
    • Now, if available, a true color bitmap is used to create the imagelist when a toolbar is opened
    • Disabled "error diffusion" in 16 color bitmap creation
  • 1.3 - (2005/09/12)
    • Added "new" toolbar feature
    • Added hot imagelist creation
    • Added some accelerators
    • Added MRU list
    • Improved drag and drop (now you can use it to move buttons also, and replace only the image by holding the CTRL key)
    • Fixed bug when two buttons have the same ID
  • 1.3b - (2005/10/27)
    • Added check for update routine
    • Fixed bug caused by MRU implementation (crash on startup)
    • Fixed bug with 16 colors bitmap (ugly view in preview)
  • 1.3c - (2005/11/06)
    • Some internal modification on code to prepare the new release
    • Fixed bug on "check for updates routine"
  • 1.3d - (2006/07/04)
    • Some internal modification on code to prepare the new release (again)
    • Better error handling during parsing
    • Minor bug-fix
  • 1.41 - (2008/01/05) **SHIPON**
    • New dialog Layout to handle toolbars up to 48x48px
    • Better icon handling: now before use they are all ported to true color
    • Added support for png images/icons
    • Fixed bug on reopening an existing toolbar without a true color bitmap
    • Fixed bug on first toolbar display: listcontrol without icon preview
    • Minor bug fixes
  • 1.42 - (2009/03/31) **SHIPON**
    • New function to select transparent color
    • Fixed bug that cause wrong background color selection
    • Fixed crash if wrong toolbar id is selected for parsing
  • 1.50 - (2011/07/09) **P.WIP**
    • Program default data directory moved to [USERAPPDATA] windows default folder. This is to avoid administrative user rights requirement in Vista/Windows 7.
    • Added a more detailed manual to the installation package
    • Moved to shared MFC linking to reduce EXE file dimension
    • Fixed bug on the new function to select the background color
    • Fixed bug on first toolbar display: listcontrol without icon preview
    • Minor bug fixes   
  • 1.60 - (2012/10/19). ***** FIREWORKS ****
    • Improvements
    • Imagelist editing
    • Rotate image: now the rotate image function is enabled
    • Resize image now use a better resizing algorithm
    • Export image to library function
    • Some improvements in the option dialog: “autodetect” feature of afxres.h file (works with visual studio 2005 up to 2010)
    • the background color is now prevented to be changed by the optimization of the palette when a bitmap < 24 bit is saved (16 color bitmap for example)
    • Better toolbar layout and document handling
    • Support for UNICODE files
    • Some UI improvements
    • BugFix
    • Fixed a bug during saving of gray scale bitmaps (bitmap file wrongly reported as 4bit depth)
    • Fixed some bad behaviors of menu
    • Minor bug fixes

Additional License Note

This program is free and provided "as is" without any expressed or implied warranty. Use at your own risk!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Francesco Aruta
Engineer
Italy Italy
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionI can not download file TBar_gifs16.zipmemberipadilla25 Oct '12 - 1:29 
Hi,
I can not download file TBar_gifs16.zip. Can you review the link please?
Thank you for sharing this nice utility.
AnswerRe: I can not download file TBar_gifs16.zipmemberFrancesco Aruta30 Oct '12 - 23:57 
I just updated the article (once approved should be fixed)
Thank you for reporting the issue.
 
Francesco
TBEditor: a pandapowered app!


AnswerRe: I can not download file TBar_gifs16.zipmemberSteve Mayfield31 Oct '12 - 6:34 
for now you can use the direct link:
http://www.codeproject.com/KB/applications/ToolbarEditor/TBar_gifs16.zip[^]
Steve
_________________
I C(++) therefore I am

GeneralMy vote of 5memberMarco Bertschi22 Oct '12 - 6:28 
Well, a very nice article, but it would be very nice if you could explain some code snippets as well as you explained the use of the program.
GeneralRe: My vote of 5memberFrancesco Aruta22 Oct '12 - 6:57 
First of all: thank you! Smile | :)
Secondly: I don't think that in the code there is something really interesting to highlight but I will review it and if I found something interesting I will review the article to include it Wink | ;)
TBEditor: a pandapowered app!


BugVer 1.5 not reading any IDmemberPierre Filion1 Oct '12 - 12:49 
Hi
 
the tb editor reads the .rc file with no error but nothing appears in the combo box. And when I scan a error message appears "Can't scan resource file.
GeneralRe: Ver 1.5 not reading any IDmemberFrancesco Aruta2 Oct '12 - 6:11 
could you send me your rc to check what's appening?
 
Regards
Francesco
TBEditor: a pandapowered app!


GeneralRe: Ver 1.5 not reading any IDmemberPierre Filion2 Oct '12 - 9:12 
this must seem stupid but how do you want me to send it? There is no way to attach file here.
GeneralRe: Ver 1.5 not reading any IDmemberFrancesco Aruta5 Oct '12 - 22:53 
I sent you an email with my email address Smile | :)
 
Ciao
Francesco
TBEditor: a pandapowered app!


GeneralRe: Ver 1.5 not reading any IDmemberFrancesco Aruta10 Oct '12 - 22:14 
Dear Pierre,
I found the problem: your .rc file is UNICODE encoded while my program use CStdioFile class to read the text files.
I will fix this with the next release. In the mean time the only solution is to save (if possible) your file as standard Multibyte encoding.
 
Ciao
Francesco
TBEditor: a pandapowered app!


GeneralRe: Ver 1.5 not reading any IDmemberPierre Filion17 Oct '12 - 3:46 
Ok Thanks very much I will do that
 
Ciao
Pierre
GeneralVersion 1.60 released!memberFrancesco Aruta19 Oct '12 - 5:45 
This bug forced me to release the 1.6 version.
There are several small changes comparing from version 1.5... I was waiting to have the new library finished to publish directly the 2.0 version but more than one year is passed from 1.5 release ..
I'm updating the codeproject article. In the meantime you can download it from sourceforge:
https://sourceforge.net/projects/tbeditor/[^]
TBEditor: a pandapowered app!


GeneralMy vote of 5membermaplewang16 Jul '12 - 22:01 
Thanks it is a good tool.
QuestionExcellentmember=[ Abin ]=20 Oct '11 - 20:52 
Oh my god, been looking for this for years, thanks alot!
QuestionNot working for 32x32 imagemembersally899818 Aug '11 - 14:38 
I had triwd with 32x32 size but it failed.
AnswerRe: Not working for 32x32 imagememberFrancesco Aruta30 Aug '11 - 2:12 
Hi Sally,
could you explain me better which kind of error/problem you had?
I'm currently using the software with 24x24 images and it works as expected...
 
Regards
Francesco
TBEditor: a pandapowered app!


QuestionToolbar Editor 1.42memberK. H. Renders14 Dec '10 - 21:31 
Good morning Signore Aruta,
 
a short user test was made with your very easy and impressive Toolbar Editor Version 1.42. It is really nice and - up to now - I didn't find any serious problem while using.
 
I personally only got a little problem with reading the text lines and watching the images, because I am probably not as young as you, I am 74 years old in meantime and that is the reason of my problems. Is that a problem for you, to design the fonts - not for the menus, they are large enough - as well as the shown images some points larger? This really would help! With this small design you are together with a lot of other young developers. You nearly can read the age of an developer off the design size of his windows.
 
Klaus H. Renders
Germany
GeneralProblems with 4.1memberHugh S. Myers5 Jul '08 - 7:19 
Won't scan simple .rc file, error message "Cannot scan resource file."
Refresh error message "Cannot create preview toolbar control. Aborting"
Refresh library button is sunken, does not look like button, confuses user...
Buttons 1 and 6 on your toolbar have no tip text.
Generate fails with same error as refresh.
 
Running w2k on a machine with 1 gig of memory running at 1.8 megahertz.
 
Your error messages are not useful to the user--- are they useful to you?
 
Help file could stand to have a worked example at a minimum.
 
--hsm
Question"New version available"memberT800G29 Nov '07 - 14:35 
"To download files from repository you have first to login to p-network."WTF | :WTF:
GeneralRe: "New version available"memberFrancesco Aruta6 Dec '07 - 6:57 
if you don't want to login you can dowload from sourceforge:
http://sourceforge.net/projects/tbeditor/
 

TBEditor: a pandapowered app!

NewsNew version availablememberFrancesco Aruta10 Jan '07 - 2:12 
Toolbar editor 1.4 :->

 
Get it Cool | :cool:
 
TBEditor: a pandapowered app!

GeneralWon't always generate 24 bit bitmaps &amp; other issuesmemberroel_14 Nov '06 - 1:27 
First, thanks for you work. It looks promising.
 
However, I encountered some issues. First, generating 24 bit bitmaps only works when you use the 'save' button, not when using the 'generate' button. Secondly, a lot of controls look like they are editable but they're not apparently, like the rx and ry parameters. I tried to fix some of the problems but the download didn't contain everything that is needed to compile - I understand it's because of licensing issues.
 
Have you considered putting this on sourceforge so that there is version control etc.? I would fix some of the issues but the way it is now, it's too hard to collaborate - I'd have to send you the whole project, I wouldn't remember what I changed etc. So if you'd like to put this in a more formal project, let me know and I'll give you a hand. (if you have no interest in maintaining this software, please let me know also - if you'd agree, I'd put it up on sourceforge myself).
 
Thanks again for your work.

GeneralRe: Won't always generate 24 bit bitmaps &amp; other issuesmemberFrancesco Aruta14 Nov '06 - 9:46 

roel_ wrote:
First, thanks for you work. It looks promising.

 
You are welcome. I'm glad that you like it Smile | :)
 

roel_ wrote:
First, generating 24 bit bitmaps only works when you use the 'save' button, not when using the 'generate' button.

 
That is correct. The bitmap itself is created it that way. The generate button is used to merge the toolbar with the current open project. By the way the 24 bit, Hot and Gray bitmap are created in the /res subfolder of your project when you use the generate button (but you have to check the three checkbuttons near the generate one)
 

roel_ wrote:
Secondly, a lot of controls look like they are editable but they're not apparently, like the rx and ry parameters.

 
Yes I know. I'm still working on this project but only on my free time (that in the last period isn't too much Frown | :( and in the code there are some controls disabled in release version like the new icon preview listbox..
 
roel_ wrote:
I tried to fix some of the problems but the download didn't contain everything that is needed to compile - I understand it's because of licensing issues.

 
You need the CxImage library to compile toolbar editor. But you are right: the project can be surely improved...
 

roel_ wrote:
Have you considered putting this on sourceforge so that there is version control etc.? I would fix some of the issues but the way it is now, it's too hard to collaborate - I'd have to send you the whole project, I wouldn't remember what I changed etc. So if you'd like to put this in a more formal project, let me know and I'll give you a hand. (if you have no interest in maintaining this software, please let me know also - if you'd agree, I'd put it up on sourceforge myself).

 
No, actually I never considered it but if you are interested in developing Toolbar Editor it's a nice idea for sure. I will arrange a new project on sourceforge in the next days.
 
Bye,
Francesco
 
TBEditor: a pandapowered app!

GeneralRe: Won't always generate 24 bit bitmaps &amp; other issuesmemberroel_14 Nov '06 - 22:49 
Maybe I don't understand the 'generate' then, but don't worry I'll have a look at the code and that'll help. I'll keep an eye on this article, please post a message here when you have the project up and running.
GeneralRe: Won't always generate 24 bit bitmaps &amp; other issuesmemberFrancesco Aruta18 Nov '06 - 1:34 
roel_ wrote:
I'll keep an eye on this article, please post a message here when you have the project up and running.

 
I finished to setup the repository on sourceforge. I choose to use svn instead of cvs because of in the last project I tryed it and it seems really good...
The name of the project is tbeditor.. and the URL is http://sourceforge.net/projects/tbeditor. At this moment there isn't anything but the repository and the 1.3d version (I should learn a little bit more about sourceforge site because this is my first project hosted on it...)
 
Bye,
Francesco
 

 

 
TBEditor: a pandapowered app!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 31 Oct 2012
Article Copyright 2005 by Francesco Aruta
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid