Click here to Skip to main content
12,291,499 members (67,152 online)
Click here to Skip to main content

Stats

209K views
2.7K downloads
74 bookmarked
Posted

Win32 dialog helpers

, 18 Apr 2003
Easy support for dialog resizing and ActiveX controls
#include "stdafx.h"
#include "resource.h"
#include "ResizableGrip.h"
#include "WebBrowserAxDialog.h"
#include "Exdispid.h" // platform SDK header


	// IUnknown methods
HRESULT __stdcall DWebBrowserEventsImpl::QueryInterface(REFIID riid, LPVOID* ppv)
{
	*ppv = NULL;

	if (IID_IUnknown == riid || __uuidof(SHDocVw::DWebBrowserEventsPtr) == riid)
	{
		*ppv = (LPUNKNOWN)(SHDocVw::DWebBrowserEventsPtr*)this;
		AddRef();
		return NOERROR;
	}
	else if (IID_IOleClientSite == riid)
	{
		*ppv = (IOleClientSite*)this;
		AddRef();
		return NOERROR;
	}
	else if (IID_IDispatch == riid)
	{
		*ppv = (IDispatch*)this;
		AddRef();
		return NOERROR;
	}
	else
	{
		return E_NOTIMPL;
	}
}

ULONG __stdcall DWebBrowserEventsImpl::AddRef() { return 1;}
ULONG __stdcall DWebBrowserEventsImpl::Release() { return 0;}

// IDispatch methods
HRESULT __stdcall DWebBrowserEventsImpl::GetTypeInfoCount(UINT* pctinfo)
{ 
	return E_NOTIMPL; 
}

HRESULT __stdcall DWebBrowserEventsImpl::GetTypeInfo(UINT iTInfo,
            LCID lcid,
            ITypeInfo** ppTInfo)
{ 
	return E_NOTIMPL; 
}

HRESULT __stdcall DWebBrowserEventsImpl::GetIDsOfNames(REFIID riid,
            LPOLESTR* rgszNames,
            UINT cNames,
            LCID lcid,
            DISPID* rgDispId)
{ 
	return E_NOTIMPL; 
}
        
HRESULT __stdcall DWebBrowserEventsImpl::Invoke(DISPID dispIdMember,
            REFIID riid,
            LCID lcid,
            WORD wFlags,
            DISPPARAMS __RPC_FAR *pDispParams,
            VARIANT __RPC_FAR *pVarResult,
            EXCEPINFO __RPC_FAR *pExcepInfo,
            UINT __RPC_FAR *puArgErr)
{ 
	// proces OnBeforeNavigate
	if (dispIdMember == DISPID_BEFORENAVIGATE)
	{
		BeforeNavigate( _bstr_t( pDispParams->rgvarg[5].bstrVal ),
						0,
						_bstr_t( pDispParams->rgvarg[3].bstrVal ),
						NULL,
						_bstr_t(""),
						NULL);
		
	}
	else if (dispIdMember == DISPID_NAVIGATECOMPLETE)
	{
		NavigateComplete( _bstr_t( pDispParams->rgvarg[0].bstrVal ) );
	}

	return NOERROR;
}


// Methods:
HRESULT DWebBrowserEventsImpl::BeforeNavigate (
        _bstr_t URL,
        long Flags,
        _bstr_t TargetFrameName,
        VARIANT * PostData,
        _bstr_t Headers,
        VARIANT_BOOL * Cancel )
	{
		::MessageBox(NULL,(char*)URL,"BeforeNavigate message box",MB_OK);
		return S_OK;
	}

    HRESULT DWebBrowserEventsImpl::NavigateComplete ( _bstr_t URL ) 
	{ 
/* example code
		SHDocVw::IWebBrowserAppPtr pWebBrowser = NULL;
		HRESULT hr = m_cpParent->GetDlgControl(IDC_EXPLORER1, 
						__uuidof(SHDocVw::IWebBrowserAppPtr), 
						(void**)&pWebBrowser);

		// get the html document
		MSHTML::IHTMLDocument2Ptr doc( pWebBrowser->Document );
		MSHTML::IHTMLElementPtr htmlbody( doc->body );

		BSTR content = NULL;
		htmlbody->get_innerHTML(&content);
		_bstr_t bcontent(content);
*/
		return S_OK; 
	}
    HRESULT DWebBrowserEventsImpl::StatusTextChange ( _bstr_t Text ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::ProgressChange (
        long Progress,
        long ProgressMax )  { return S_OK; }
    HRESULT DWebBrowserEventsImpl::DownloadComplete()  { return S_OK; }
    HRESULT DWebBrowserEventsImpl::CommandStateChange (
        long Command,
        VARIANT_BOOL Enable ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::DownloadBegin () { return S_OK; }
    HRESULT DWebBrowserEventsImpl::NewWindow (
        _bstr_t URL,
        long Flags,
        _bstr_t TargetFrameName,
        VARIANT * PostData,
        _bstr_t Headers,
        VARIANT_BOOL * Processed ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::TitleChange ( _bstr_t Text ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::FrameBeforeNavigate (
        _bstr_t URL,
        long Flags,
        _bstr_t TargetFrameName,
        VARIANT * PostData,
        _bstr_t Headers,
        VARIANT_BOOL * Cancel ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::FrameNavigateComplete (
        _bstr_t URL ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::FrameNewWindow (
        _bstr_t URL,
        long Flags,
        _bstr_t TargetFrameName,
        VARIANT * PostData,
        _bstr_t Headers,
        VARIANT_BOOL * Processed ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::Quit (
        VARIANT_BOOL * Cancel ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::WindowMove ( ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::WindowResize ( ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::WindowActivate ( ) { return S_OK; }
    HRESULT DWebBrowserEventsImpl::PropertyChange (
        _bstr_t Property ) { return S_OK; }

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Addicted to reverse engineering. At work, I am developing business intelligence software in a team of smart people (independent software vendor).

Need a fast Excel generation component? Try xlsgen.


You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160518.1 | Last Updated 19 Apr 2003
Article Copyright 2003 by Stephane Rodriguez.
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid