From: Nick Schultz on
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


From: Ajay Kalra on
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(a)flir.com> wrote in message
news:eYId4uItIHA.1240(a)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
>

From: Joseph M. Newcomer on
See below...
On Mon, 12 May 2008 16:55:54 -0700, "Nick Schultz" <nick.schultz(a)flir.com> wrote:

>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.
****
Actually, you are creating a correlation where none exists; the two phenomena are
completely unrelated.

The failure to enable would be typically be caused by your message map in your message
routing hiearchy (and your toolbar is not part of that hiearchy) not having an entry for
the button, so by default it is disabled if there is no handler.

The warning is caused by exactly what it says: there is no string IDS_xxxx of numeric
value 32(the control value you have assigned the button). But this has nothing to do with
the failure to enable.
****
>
>
>I'm not sure what I am doing wrong, where should I be capturing this
>message?
****
In the message routing hierarchy. such as in your document, view, mainframe, app, child
MDI frame, document template, etc. you need a handler. Since the toobar is not part of
the MFC message routing scheme, a handler in it is not seen and the button is disabled.
joe
****
>
>Thanks,
>
>Nick
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Nick Schultz on
OOPS, I copied and pasted the wrong line of code for my toolbarbutton
creation. But yes, I have both the Message Map and Button ID using the same
ID ( IDD_TOOLBAR_NEW). Yet my handler function still does not get called.
"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
news:233D9916-CAC0-4C16-94A2-964699E1E3DC(a)microsoft.com...
> 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(a)flir.com> wrote in message
> news:eYId4uItIHA.1240(a)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
>>
>


From: Nick Schultz on

"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:50sh24tt83obvhiscf3jkog0vctst44qp8(a)4ax.com...
> See below...
> On Mon, 12 May 2008 16:55:54 -0700, "Nick Schultz" <nick.schultz(a)flir.com>
> wrote:
>
>>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.
> ****
> Actually, you are creating a correlation where none exists; the two
> phenomena are
> completely unrelated.
>
> The failure to enable would be typically be caused by your message map in
> your message
> routing hiearchy (and your toolbar is not part of that hiearchy) not
> having an entry for
> the button, so by default it is disabled if there is no handler.
>
> The warning is caused by exactly what it says: there is no string IDS_xxxx
> of numeric
> value 32(the control value you have assigned the button). But this has
> nothing to do with
> the failure to enable.
> ****
>>
>>
>>I'm not sure what I am doing wrong, where should I be capturing this
>>message?
> ****
> In the message routing hierarchy. such as in your document, view,
> mainframe, app, child
> MDI frame, document template, etc. you need a handler. Since the toobar
> is not part of
> the MFC message routing scheme, a handler in it is not seen and the button
> is disabled.
> joe
> ****
>>
>>Thanks,
>>
>>Nick
>>
> Joseph M. Newcomer [MVP]
> email: newcomer(a)flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm


I thought giving the button an ID and declaring the ID in the message map
creates the handler for the event? How do I create the handler so that my
function will be called?

Thanks,


Nick