I have an MDI app that uses a dialogue in its view. In this dialogue is an ActiveX webbrowser control. Now, I handle all of the messages pertaining from this control in the dialogue class, eg OnBeforeNavigate etc, but there is one message I need to handle in my view class.
This message is OnCommandStateChange; I have toolbar buttons linked to the browser's ability to navigate forwards or backwards that I want to enable/disable accordingly. Now I need to handle this message in the view class because a previous question here informed me that it would be a lot of trouble to route messages to update toolbar buttons to the dialogue class !
Here is what I have so far:
BOOL CContainerDlg::OnCmdMsg (UINT nID, int nCode, void* pExtra,
// Forward ActiveX control events to the dialog's parent.
if (nCode == CN_EVENT)
return GetParent ()->OnCmdMsg (nID, nCode, pExtra, pHandlerInfo);
#endif // !_AFX_NO_OCC_SUPPORT
return CDialog::OnCmdMsg (nID, nCode, pExtra, pHandlerInfo);
So this is forwarding all ActiveX messages to the view class, which is not want I want to do: I want to forward the OnCommandStateChange message only !
I know I could simply test to see if the message was handled in the view class, and if it is not then handle it in the dialogue, but I was hoping there was a way I could test to see if the the message coming into the above function was the one I wanted to save forwarding *all* messages. Is there ?
I figured the parameters to OnCmdMsg would be useful, but I cannot see that they are.
There is more info about CommandStateChanged at http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents2/commandstatechange.asp