Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

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

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
Nikhilesh_K
Asked:
Nikhilesh_K
2 Solutions
 
AlexFMCommented:
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
 
AndyAinscowCommented:
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now