handler for toolbar button

in Visual Studion 2003, I added a new toolbar button to the
IDR_MAINFRAME toolbar, and I need to add a handler for it in
the CFormView derived class that handles my view, how do you go about it?



0
RPG1 (8)
1/13/2005 1:32:13 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
404 Views

Similar Articles

[PageSpeed] 15


RPG wrote:
> in Visual Studion 2003, I added a new toolbar button to the
> IDR_MAINFRAME toolbar, and I need to add a handler for it in
> the CFormView derived class that handles my view, how do you go about it?

There is no facility to add a handler from a toolbar button. Toolbar 
buttons should only reflect what is available in a menu, this way you 
don't require your client to reach for the mouse instead of using the 
keyboard.

Add the menu item, then set the ID of the button the same as the menu 
item. The button will be enabled just like the menu item by the 
existence of a handler or an update handler.

If you want a button without a corresponding menu item, you will have to 
put the code in yourself.

Best, Dan.

-- 
http://lakeweb.net
http://ReserveAnalyst.com
No EXTRA stuff for email.
What can you see if you can't see it all...

0
1/13/2005 2:29:16 AM
In header:

void OnTest();
DECLARE_MESSAGE_MAP()

In cpp:
BEGIN_MESSAGE_MAP(CTestView, CView)
ON_COMMAND(ID_MAINFRAME_TEST, OnTest)
END_MESSAGE_MAP()

void CTestView::OnTest()
{
// Do stuff
}
HTH,
Drew

"RPG" <RPG@rpg.com> wrote in message 
news:41e5cf99$0$46328$c30e37c6@lon-reader.news.telstra.net...
> in Visual Studion 2003, I added a new toolbar button to the
> IDR_MAINFRAME toolbar, and I need to add a handler for it in
> the CFormView derived class that handles my view, how do you go about it?
>
>
> 


0
1/13/2005 4:26:31 PM
"Drew Myers" <drew.nospam.myers@esrd.com> wrote in message 
news:OqhUoyY%23EHA.4072@TK2MSFTNGP10.phx.gbl...
> In header:
>
> void OnTest();
> DECLARE_MESSAGE_MAP()
>
> In cpp:
> BEGIN_MESSAGE_MAP(CTestView, CView)
> ON_COMMAND(ID_MAINFRAME_TEST, OnTest)
> END_MESSAGE_MAP()
>
> void CTestView::OnTest()
> {
> // Do stuff
> }
> HTH,
> Drew
>
> "RPG" <RPG@rpg.com> wrote in message 
> news:41e5cf99$0$46328$c30e37c6@lon-reader.news.telstra.net...
>> in Visual Studion 2003, I added a new toolbar button to the
>> IDR_MAINFRAME toolbar, and I need to add a handler for it in
>> the CFormView derived class that handles my view, how do you go about it?
>>
>>
>>
>
>

Thank you for the reply, however, the point that I was trying to make is 
that
in Visual C++ 6, this task could be accomplished quite easy, which is not 
the
same that it can be said about Visual Studio 2003. 


0
RPG1 (8)
1/15/2005 3:23:35 AM
Reply:

Similar Artilces:

Routing of handlers
What is the best place to write toolbar button handlers ? I mean to say in which class ( CMainFrame or CView - for SDI app only ) should I write handlers of toolbar buttons. Suppose, my app has a CHtmlView class which is also a part of application ( other than CView ), Should I write toolbar button handlers in it if those buttons works for it. How MFC routes these command hanldes from one class to other ?( means from CMainFrame to CView to CDocument to other child windows ) >What is the best place to write toolbar button handlers ? I mean to say >in which class ( CMainFrame or CView - ...

Customized buttons
Hello, Is there a way to have customized buttons appear on the Excel (97) menu when a specific template is used/opened? Thank you. Eric. Eric, You can add to the menu when the workbook opens. Here is a simple example that adds a popup to the Tools menu, and a button within that Private Sub Workbook_Open() Dim oCb As CommandBar Dim oCtl As CommandBarPopup Dim oCtlBtn As CommandBarButton On Error Resume Next Set oCb = Application.CommandBars("Worksheet Menu Bar") oCb.Controls("Tools").Controls("myButton").Delete On Error GoTo 0 Set oCb ...

Update Handler
I have a menu item that displays a non modal dialog. In my update handler, I have : pCmdUI->SetCheck(m_pStat->GetStyle() & WS_VISIBLE ? 1 : 0); I have also tried : pCmdUI->SetCheck(m_pStat->IsWindowVisible() ? 1 : 0); these both cause assertion errors. m_pStat is a pointer to the non modal dialog. Any idea why this isn't working? Actually i figured it out. My dialog hadn't been created yet. "abe froman" <cracker1234@optonline.net> wrote in message news:V0fee.27862$RP1.25050@fe10.lga... >I have a menu item that displays a non modal dialog...

why the toolbar wont be dockable after use SetButtonInfo?
i use the code like the following: m_wndToolBar.SetButtonInfo(0, IDC_WRITEMSG, TBSTYLE_BUTTON, 0); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); ...

How to process a message handler?
Hi to all, I am using Visual C++ 6.0. How can I add a message handler to process the MM_MCINOTIFY notification message? What should I add in the section: BEGIN_MESSAGE_MAP() END_MESSAGE_MAP() As taken from the MSDN Library: "The MM_MCINOTIFY message notifies an application that an MCI device has completed an operation." Thanks in advance. Geo geo wrote: > > Hi to all, > > I am using Visual C++ 6.0. How can I add a message > handler to process the MM_MCINOTIFY notification message? > > What should I add in the section: > BEGIN_MESSAGE_MAP() > END...

Problem Deleting Check Boxes created from Forms Toolbar
I managed to overlay about 200 checkboxes in one cell (long story). I have too much invested in this worksheet to just start over. Deleting the row doesn't help, they just move somewhere else. Other than continuing to delete them one by one, does anyone have a suggestion for clearing this cell? Thanks in advance. Try 'Edit' om the Toolbars, 'Go to' > 'Special' > check 'Objects' . Right click one of the highlighted objects and Cut and it will Cut them all, clear the clipboard and that should be that, Regards, Alan. "Suzan" <Suzan@d...

View Custom Toolbar in Excel 2007
I have an Excel 2003 file that contains a custom toolbar. In Excel 2003 the custom toolbar is displayed and I can just click the buttons on that toolbar to run my macros. When I open the file in Excel 2007 I can find no way to display that custom toolbar. In fact, the only way that I have found to access my macros is to go into View Macros and run them that way, which isn't going to cut it. Is there a way in Excel 2007 to re-create the Excel 2003 functionality, perhaps by building a custom ribbon and putting buttons for my macros on that ribbon? I just need some way to make the...

Customizing ToolBars
When customizing your toolbars in Excel, how do you get your options to save for your next use of Excel?? If you're customizing the builtin toolbars, excel should save them in your *.xlb file when you close excel. If you've attached a toolbar to a workbook, you'll want to read Jan Karel Pieterse's notes: http://google.com/groups?threadm=083701c3559b%246ce75e60%24a301280a%40phx.gbl anonymous@discussions.microsoft.com wrote: > > When customizing your toolbars in Excel, how do you get > your options to save for your next use of Excel?? -- Dave Peterson ec35720@ms...

CRM Toolbar
When I open a Task, the CRM toolbar has a "Regarding..." button that identifies the contact for the Task. Some of our users must manually open the CRM toolbar on the Task dialog. The problem is that the next time they open a Task, the CRM toolbar is gone again and must be manually opened. How can we make the CRM toolbar stay open? Thanks, Craig. ...

WM_COMMAND handler
How do I get VC6 to add a WM_COMMAND handler to my MFC window class? WM_COMMAND is not in the "New Message/Events" list. Jan I suspected I have to do it manually. Can you give an example? Thanks. Jan "Ajay Kalra" <ajaykalra@yahoo.com> wrote in message news:#h0MsLVuEHA.348@tk2msftngp13.phx.gbl... > You dont have to use the wizard to do this, simply provide WM_COMMAND for a > particular ID in the message map etc. > > -- > Ajay Kalra [MVP - VC++] > ajaykalra@yahoo.com > > > "Jan" <biteme@nospam.com> wrote in message > ...

event handlers
I've added the following two lines to the message map of an mfc activex control which consists of a dynamically created richedit control. ON_EN_CHANGE(IDR_RICHEDIT, &CSodeXRichTextCtrl::OnEditRichText) ON_NOTIFY(EN_LINK, IDR_RICHEDIT, &CSodeXRichTextCtrl::OnEnLinkRichedit) They work fine for the EN_LINK en CHANGE event. However I would also like to react to a user clicking inside the Richedit Control. I guess I have to react to the WM_COMMAND message. But I can't figure out how. Could someone help please? Nevermind found it, EN_MSGFILTER, one day i'll know them all o...

Where can I find MS Money Import Handler?
I think I need to reassociate the ofx file to this exe but I cannot find it. Thanks In microsoft.public.money, zuhx wrote: >I think I need to reassociate the ofx file to this exe but I cannot find it. Typically in XP the application would be "C:\Program Files\Microsoft Money Plus\MNYCoreFiles\mnyimprt.exe" %1 WITH the quotes, and the %1 after the quote. The path will differ based on your installation. Modify for your setup. MNYCoreFiles is hidden. I don't know how to specify the argument in Vista. Thanks for the response. I could not find the exe mnyimprt.exe. I have MS...

How do I get a list button to be displayed?
I've Created a List but when the cell is not selected the button does not appear therefore it's dificult to remeber where the list is.... color code it? "Phil" wrote: > I've Created a List but when the cell is not selected the button does not > appear therefore it's dificult to remeber where the list is.... > > Yes tried that and of course I can then see where the list is but is there an option where u can select that the buttons remain in view ( a bit like filers...) thanks "Mike" wrote: > color code it? > > "Phil&q...

thread handler
Hi all! First sorry about my poor english. I developping a server application which runs as a windows service. At the beginig I was some problem but they are now solved. Today I make a notice. I am looking through the log file which was created by my server. It shows that if I start a thread it always get the same id. To be more understable. I have a static class member function what we call now mainloop. The declaration is as follow: void mainloop(void* _ptr); This function is created by a class function namely: start(). In start I use _beginthread() to spawn the thread. I call this fun...

Activities don't show up until we hit the refresh button
Hello all, We upgraded from 3 to 4 and it appears that the upgrade did not complete successfuly, but the users used the system. Everything appears to be working well except for a couple of strange things like when we create an activity the activity does not appear until we hit the Refresh button, going to history and coming back does not fix the issue, only the refresh button any quick fix on this one? thanks ...

toolbars #2
How do I keep custom icons (i.e. 'close' & 'save as' within the toolbar after I close out of Excel? When I reopen Excel, the screen quickly flashes the toolbars with the custom icons then switches to a screen without them. I have to reload each icon everytime I open Excel. (I do not have this problem with Word). ...

Location of Microsoft Access 2003 Custom designed Toolbar file
Where is the Microsoft Access Custom Toolbar (the one I have created icons on) located on the hard drive? What is the actual file name Thanks! There is no particular file. If you create a custom menu/tool bar, then that is contained with the database... The options to complete hide and keep people out of the ms-access interface can easily be done using the tools->start-up options. Using those options allows you to complete hide the ms-access interface (tool bars, database window etc). Also, using these options means you do not have to bother setting up security. Try downloading ...

Adjusting toolbar size, restore toolbar
I use MSN stock quote add-in. This has a toolbar w/ several buttons on it. However, I did something the other day and now I can not view all the buttons. And I can not adjust the width by "dragging". How can I restore the toolbar or adjust the width. I also unistalled and reinstalled the add-in, but it did not help Thank you! Try View > Toolbars > Customize "Josh M" wrote: > I use MSN stock quote add-in. This has a toolbar w/ several buttons on it. > However, I did something the other day and now I can not view all the > buttons. And I can n...

Re: Floating Toolbar #2
Thanks for a quick reply, Bob I'm new to Excel, I've been looking were to put this code I've looked in the sheet, view code etc. Also looked in Help. I'm lost Could you tell me how and where to put this code. Application.Commandbars("myBar1").Visible = True ------------------------------- Hi All Is there a way to have a floating toolbar in say Sheet1 and one in Sheet2 with different names and they only show up in there own sheet. Thanks in Advance Dave ------------------------------- Hide it and make it visible in the worksheet_Activate event Application...

how to lock a docked toolBar ?
Hello !! I have a CFrameWnd with a CToolBar. In the frame's OnCreate I dock the toolbar at the bottom of the frame. In the frame's OnSize, I move the toolbar so that it docks in the bottom-right corner of the frame. Here are the codes : OnCreate : m_vpo_ToolBar = new CToolBar(); m_vpo_ToolBar->Create(this); m_vpo_ToolBar->LoadToolBar(IDR_SIG_TLB); m_vpo_ToolBar->EnableDocking(CBRS_ALIGN_BOTTOM); this->DockControlBar(m_vpo_ToolBar, AFX_IDW_DOCKBAR_BOTTOM); OnSize : CRect tbRect; m_vpo_ToolBar->GetToolBarCtrl().GetWindowRect(&tbRect); if (!tbRect.IsRectEmpty()) { ...

unhide multiple text boxes at a time after pressing a command button
I want to be able to add a text box everything I press the Add Task button. Something like this: ___________ | ADD TASK | then a text box becomes visible ________________________ | | |________________________| and repeat up to six times So far all I have been able to do is to get one text box to show can any one help plz. Mike -- Message posted via http://www.accessmonster.com mjquinon via AccessMonster.com wrote: >I want to be able to add a text box everything I press the Add Task button. > >Something like this: > > ______...

XP buttons
First hy to all, I need my buttons (on WindowsXP) to look like XP buttons. Can I do that in MFC with some include staff or I need to do my on draw buttons ??? Thx. to all. Here: http://www.codeproject.com/buttonctrl/imagebuttonwithstyle.asp ---- Ajay Kalra ajaykalra@yahoo.com Thx. I have studi that article and I have foun a link to another article that help me. This is the link for all that want to have XP style in there projects : http://www.codeproject.com/w2k/xptheme.asp Great. Codeproject and codeguru are very helpful sites for MFC work. ---- Ajay Kalra ajaykalra@yahoo.com ...

change text and icon of a XP grouped taskbar button
Hi I need to change the text and icon of the taskbar button that XP collects simular buttons under, (after choosing "Group simular taskbar buttons" in the taskbar properties) Can anyone give me directions on where to start looking? thanks and regards Anders Sandberg ...

stop macro recording button missing
Hi When I record a macro the stop recording toolbar is not displayed. How do I get it to display? TIA Ray ray, View/Toolbars Select "Stop Recording" John ray wrote: > Hi > When I record a macro the stop recording toolbar is not > displayed. How do I get it to display? > TIA > Ray You might have to do that while recording a macro.. -- Regards, Peo Sjoblom "John Wilson" <jwilson@optonline.net> wrote in message news:3FA7FE82.58F30DFC@optonline.net... > ray, > > View/Toolbars > Select "Stop Recording" > > John > ...

Handler already exists error
When trying to load certain pages the status bar indicates DONE with errors. When I look at the error it states handler already exists. ???? Help??? Kimy wrote: > When trying to load certain pages the status bar indicates DONE > with errors. When I look at the error it states handler already > exists. ???? Help??? Don't go to the 'certain pages'... Or explain in more detail what it is you are doing, what operating system you are using, what service pack said operating system is at, what browser (exact version) you are using and why you think this has somet...