Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

14 Experts available now in Live!

Get 1:1 Help Now