Solved

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

Posted on 2006-10-30
2
190 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tab names are off by one 5 53
Shell script to login to remote m/c and execute commands 10 78
difference between String.subString() and String.subSequence() 6 180
sum28 challenge 31 107
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now