call window.close from the activex see How To Retrieve the Top-Level IWebBrowser2 Interface from an ActiveX Control http://support.microsoft.com/kb/257717 INFO: Accessing the Object Model from Within an ActiveX Control http://support.microsoft.com/kb/172763
void CXXXXCtrl::OnIECommand(int IECommand)
{
HWND hwndParent = 0, hFParent = 0;
m_pInPlaceSite->GetWindow(&hwndParent);
while (hwndParent)
{
hFParent = hwndParent;
hwndParent = ::GetParent(hwndParent);
} if (hFParent)
{
UINT Command = 0;
switch (IECommand)
{
case 0: //关闭IE
Command = SC_CLOSE;
break;
case 1: //最小化IE
Command = SC_MINIMIZE;
break;
//还需要操作IE的其它方面,比如打印,一并写到这里即可
} if (Command)
::PostMessage(hFParent, WM_SYSCOMMAND, Command, 0);
}
}
see
How To Retrieve the Top-Level IWebBrowser2 Interface from an ActiveX Control
http://support.microsoft.com/kb/257717
INFO: Accessing the Object Model from Within an ActiveX Control
http://support.microsoft.com/kb/172763
jiangsheng(蒋晟.Net[MVP])的方法是可以的,谢谢!