Solved

how to make a new button on a toobar and add class to it?

Posted on 2006-10-30
2
206 Views
Last Modified: 2013-11-20
hi
 i wish to create a toolbar button , something similar to the open file  or a new file. how can i do that? where do i have to define stuff i.e. in which *.h or *.cpp file? how can i assign function to that button.

nikhil.
0
Comment
Question by:Nikhilesh_K
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 150 total points
ID: 17840433
Open toolbar resource in the Resource View, and add new button to it. To do this it is enough to click last button on the toolbar (new button placeholder), fill icon, select properties and fill button ID (like ID_MYCOMMAND). Resource designer adds all required lines to .h and .rc files. New button can be dragged to required place in the toolbar.
Having new button on the toolbar, you can add handler to it to different classes in the project, like CMainFrame, view class etc.
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 100 total points
ID: 17840698
An extension to the comment by Alex.
With VC version 6 and earlier you could do that and let the wizard provide event handlers for you.  The later (.net) versions have changed the behaviour of the wizard and don't seem to recognise toolbar buttons unless there is a menu to provide the same action.  So you can provide a dummy menu (you don't need to actually display it) and as long as the button has the same resource ID as the menu then the wizard will generate event handlers for you.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
lucky13 challenge 11 154
haveThree challenge 22 121
Window placement 17 86
Not needed 13 119
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question