Solved

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

Posted on 2006-10-30
2
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

622 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