Re: How to capture toolbar button command
Your message map should have the entry for the appropriate ID of the button.
Why are you not adding the button in resource editor?
---
Ajay
"Nick Schultz" <nick.schultz@flir.com> wrote in message
news:eYId4uItIHA.1240@TK2MSFTNGP02.phx.gbl...
Hi there,
I am trying to capture the message that is sent when one of my toolbar
buttons are pressed.
I extended the CMFCToolBar class to :
class CGraphToolBar : public CMFCToolBar
I have message map set accordingly:
BEGIN_MESSAGE_MAP(CGraphToolBar, CMFCToolBar)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_COMMAND(IDD_TOOLBAR_NEW, OnNewElementBtn)
END_MESSAGE_MAP()
in the constructor, i create all my buttons (using one as an example):
m_saveBtn = new CMFCToolBarButton(IDD_TOOLBAR_SAVE,3);
I add the button in the OnCreate function:
InsertButton(*m_saveBtn);
And i have a simple handler function:
void CGraphToolBar::OnNewElementBtn(){
TRACE0("CLICKED\n");
}
When I run the program and click the button (the button is greyed out by
the way), I get this message instead:
Warning: no message line prompt for ID 0x0032.
I'm not sure what I am doing wrong, where should I be capturing this
message?
Thanks,
Nick