Tutorials |
Menu of tutorials
Tutorial 1: The Simplest
WindowTutorial 2: Using Classes and
Inheritance
Tutorial 3: Using Messages to Create a
Scribble Window
Tutorial 4: Repainting the
Window
Tutorial 5: Wrapping a Frame around
our Scribble Window
Tutorial 6: Customising Window
Creation
Tutorial 7: Customising the
ToolBar
Tutorial 8: Loading and Saving
Files
Tutorial 9: Printing
Tutorial 10: Finishing Touches
Tutorial 7: Customising the ToolBar
Our frame window has both a menu and a toolbar at the top. Customising the menu is relatively straight forward, since we can use a resource editor to perform that task. Customising the toolbar however is another matter. While its true that the resource editor which ships Microsoft's Visual Studio can edit the toolbar resource, this is not standard, and we so need to come up with a standards compliant way of modifying the toolbar.
To set your own toolbar for your applications, you will need to perform the following steps:
- Modify the toolbar bitmap.
- Add the toolbar resource IDs to to the string table.
- Assign resource IDs to the toolbar buttons, as shown below.
void CMainFrame::SetupToolBar() { // Define the resource IDs for the toolbar AddToolBarButton( IDM_FILE_NEW ); AddToolBarButton( IDM_FILE_OPEN ); AddToolBarButton( IDM_FILE_SAVE ); AddToolBarButton( 0 ); // Separator AddToolBarButton( IDM_EDIT_CUT, FALSE ); AddToolBarButton( IDM_EDIT_COPY, FALSE ); AddToolBarButton( IDM_EDIT_PASTE, FALSE ); AddToolBarButton( 0 ); // Separator AddToolBarButton( IDM_FILE_PRINT ); AddToolBarButton( 0 ); // Separator AddToolBarButton( IDM_HELP_ABOUT ); }
The source code for this tutorial is located within the Tutorial folder of the software available from SourceForge at http://sourceforge.net/projects/win32-framework.