windoweventhandler.cpp

来自「一个在IExplorer中运行」· C++ 代码 · 共 134 行

CPP
134
字号
//
// Popup Blocker Version 2.0
// Copyright (c) 2003 Osborn Technologies, Inc.  All rights reserved.
// Web: http://www.osborntech.com
// Email: mailto:info@osborntech.com
//
// This software is being provided to you, the LICENSEE, by 
// Osborn Technologies under the following license.  By obtaining, 
// using and/or copying this software, you agree that you have read, 
// understood, and will comply with these terms and conditions:  
//
// Permission to use, copy, modify and distribute this software and 
// its documentation for any purpose and without fee or royalty is 
// hereby granted, provided that you agree to comply with the 
// following copyright notice and statements, including the 
// disclaimer, and that the same appear on ALL copies of the 
// software and documentation, including modifications that you make 
// for internal use or for distribution.  
//  
// Popup Blocker Version 2.0 Copyright ?2003 by Osborn Technologies.  All rights reserved.  
//  
// THIS SOFTWARE IS PROVIDED "AS IS" AND OSBORN TECHNOLOGIES MAKES 
// NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY OF 
// EXAMPLE, BUT NOT LIMITATION, OSBORN TECHNOLOGIES MAKES NO 
// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR 
// ANY PARTICULAR PURPOSE, OR THAT THE FUNCTIONS CONTAINED IN THIS 
// SOFTWARE WILL MEET YOUR REQUIREMENTS OR EXPECTATIONS, OR THAT THE 
// OPERATION OF THIS SOFTWARE WILL BE ENTIRELY ERROR FREE OR APPEAR 
// PRECISELY AS DESCRIBED IN THE SOFTWARE DOCUMENTATION, OR THAT THE 
// USE OF THE LICENSED SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE 
// ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.  
//  
// The name of Osborn Technologies may not be used in advertising or 
// publicity pertaining to distribution of this software.  Title to 
// copyright in this software and any associated documentation shall 
// at all times remain with Osborn Technologies and LICENSEE agrees 
// to preserve same.  
//

// WindowEventHandler.cpp : Implementation of CWindowEventHandler
// Handles HTMLWindowEvents2

#include "stdafx.h"
#include <mshtmdid.h>
#include "WindowEventHandler.h"


// CWindowEventHandler

//
// IDispatch Methods
//

STDMETHODIMP CWindowEventHandler::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
                                         DISPPARAMS* pDispParams, VARIANT* pvarResult,
                                         EXCEPINFO*  pExcepInfo,  UINT* puArgErr)
{
	if (!pDispParams)
		return E_INVALIDARG;
	
	if (!pvarResult)
		return E_POINTER;

	switch (dispidMember)
	{
		//
		// This is another way to trap script errors:
		//
		// Error during object loading caused by either of:
		// 1) Run-time script error, such as an invalid object reference or security violation. 
		// 2) Error while downloading an object, such as an image. 
		//
		// This is likely to have been caused by a script that expected a
		// popup window to be present.  Of course, the popup isn't there
		// because we suppressed it.  We got here because the script writer
		// didn't include an error handler.  If we did not return TRUE
		// here to indicate we handled the error, IE would display its own
		// error message -- which is probably worse than the original popup.
		// 
	case DISPID_HTMLWINDOWEVENTS2_ONERROR:
		//ATLTRACE(_T("HTMLWindowEvents2::onerror fired\n"));

		// Set the handled flag to tell IE not to display error dialog
		//pvarResult->vt = VT_BOOL;
		//pvarResult->boolVal = VARIANT_TRUE;	
		return DISP_E_MEMBERNOTFOUND;

	case DISPID_HTMLWINDOWEVENTS2_ONLOAD:
		//ATLTRACE(_T("HTMLWindowEvents2::onload fired\n"));
		return DISP_E_MEMBERNOTFOUND;

	case DISPID_HTMLWINDOWEVENTS2_ONUNLOAD:
		//ATLTRACE(_T("HTMLWindowEvents2::onunload fired\n"));
		return DISP_E_MEMBERNOTFOUND;

	case DISPID_HTMLWINDOWEVENTS2_ONHELP:
		//ATLTRACE(_T("HTMLWindowEvents2::onhelp fired\n"));
		return DISP_E_MEMBERNOTFOUND;
		
	case DISPID_HTMLWINDOWEVENTS2_ONFOCUS:
		//ATLTRACE(_T("HTMLWindowEvents2::onfocus fired\n"));
		return DISP_E_MEMBERNOTFOUND;

	case DISPID_HTMLWINDOWEVENTS2_ONBLUR:
		//ATLTRACE(_T("HTMLWindowEvents2::onblur fired\n"));
		return DISP_E_MEMBERNOTFOUND;

	case DISPID_HTMLWINDOWEVENTS2_ONRESIZE:
		//ATLTRACE(_T("HTMLWindowEvents2::onresize fired\n"));
		return DISP_E_MEMBERNOTFOUND;

	case DISPID_HTMLWINDOWEVENTS2_ONSCROLL:
		//ATLTRACE(_T("HTMLWindowEvents2::onscroll fired\n"));
		return DISP_E_MEMBERNOTFOUND;

	case DISPID_HTMLWINDOWEVENTS2_ONBEFOREUNLOAD:
		//ATLTRACE(_T("HTMLWindowEvents2::onbeforeunload fired\n"));
		*m_pbUnloading = TRUE;
		return DISP_E_MEMBERNOTFOUND;

	case DISPID_HTMLWINDOWEVENTS2_ONBEFOREPRINT:
		//ATLTRACE(_T("HTMLWindowEvents2::onbeforeprint fired\n"));
		return DISP_E_MEMBERNOTFOUND;

	case DISPID_HTMLWINDOWEVENTS2_ONAFTERPRINT:
		//ATLTRACE(_T("HTMLWindowEvents2::onafterprint fired\n"));
		return DISP_E_MEMBERNOTFOUND;

	default:
		ATLTRACE(_T("HTMLWindowEvents2 event %ld (0x%x) fired\n"), dispidMember, dispidMember);
		return DISP_E_MEMBERNOTFOUND;
	}
	return S_OK;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?