描述:
当IE的标准按钮(比如GoBack)被点击时页面中的ActiveX控件可以得到通知消息吗?
如果可以,ActiveX中应当怎样写代码得到通知?谢谢
解决方案1:
1.h中
specify the DECLARE_DISPATCH_ MAP macro in your header file.
2.cpp中
BEGIN_DISPATCH_MAP(CEventSink, CCmdTarget)
DISP_FUNCTION_ID(CIE4Events, "CommandStateChange",
DISPID_COMMANDSTATECHANGE,
OnCommandStateChangeExplorer1,
VT_EMPTY, //你定义的函数返回值类型,和下面一致
VS_NONE) //A space-separated list of one or more VTS_XXX
// constants specifying the function's parameter
// list. These VTS_ XXX constants are defined
// in afxdisp.h.
END_DISPATCH_MAP()
//......
// For an MFC application the CommandStateChange event could be handled
// as follows:
void CXXXXXX::OnCommandStateChangeExplorer1(long Command,
BOOL Enable)
{
switch(Command)
{
case CSC_NAVIGATEFORWARD:
//Enable表示"前进"按钮是否还可用
MessageBox("GoForword is pressed!");
break;
case CSC_NAVIGATEBACK:
//.....
break;
default:
break;
}
}