/* IProtectFocus * Author: MH * Contact: mehr13@hotmail.com * Homepage: http://vbmhwb.sourceforge.net/ * http://sourceforge.net/projects/vbmhwb/ * * Last Modified: Sep 20 2006 * Current version: 1.2.1.6 * * Changes from 1.2.1.5: * ===================== * 1)New Interface * IHTMLOMWindowServices - IE6 XP sp2 * Allows applications hosting the WebBrowser Control to intercept the window object * calls moveTo, moveBy, resizeTo, and resizeBy for manipulating the host's window * coordinates from Dynamic HTML (DHTML) script. No events have been implemeted yet. * * 2)New Functionality * Added CAutoCompleter to wrap both shell and custom autocomplete * Custom autocomplete uses a client supplied string list and IEnumString iface * Use SetupCustomAutoComplete, CustomAutoCompleteAddString, and CustomAutoCompleteEnable * methods to setup, add strings, and enable/disable custom autocomplete. * Added ability to install 11 different kinds of windows hooks * both global and application instance specific: * WHT_CALLWNDPROC * WHT_CBT * WHT_GETMESSAGE * WHT_KEYBOARD * WHT_MOUSE * WHT_MSGFILTER * WHT_KEYBOARD_LL * WHT_MOUSE_LL * WHT_FOREGROUNDIDLE * WHT_CALLWNDPROCRET * WHT_SYSMSGFILTER * The notifications for hooks are send via SendMessageTimeout function. * Windows message ids passed from SetupWindowsHook method to calling * client for each hook notifications are registered using * RegisterWindowMessage method. The result param from SendMessageTimeout is * used to determine if a hook call has been cancelled. * * 3)New Events: * OnWBKeyDown * Replacement for OnAcceletorKeys * OnWBKeyUp * Replacement for OnAcceletorKeys * Replaced ShowMessage with DocHostShowMessage, * New event passes all the params from DocHostShowUI::ShowMessage method * FindAnyTextMatchCallback - fired in response to a call to FindAnyTextMatch * Searching for a match continues till stop is set to true or no more matches * Frames are searched as well. * OnShowScriptError * This event replaces ScriptErrorAction property. It passes; * ErrorLine, ErrorCharacter, ErrorCode, ErrorMsg, ErrorURL, * and a boolean parameter to indicate whether to * stop or continue running scripts bStopRunningScript (default TRUE) * * 4)New Methods * SetupWindowsHook, allows client to install windows hooks and receive notifications. * I am using registered windows messages for each hook procedure notification * to insure uniqueness of the message id which is passed to SendMessageTimeout. * The window message id is passed to lUWMHookMsgID variable during a call to * this method so the client can look for notification for a specific hook. * HookProcNCode, allows a client to retreive the nCode param from three hook callback * functions. For the rest of the windows hooks, the nCode param is meanningless. * WHT_CBT, WHT_MSGFILTER, and WHT_SYSMSGFILTER. * FindAndHighlightAllTextFrames, Unlike FindAndHighlightAllText which searches * and highlights matches in the active document, the new method searches and * highlights matches in all frames. Also returns number of found matches. * SetupCustomAutoComplete * Uses IEnumString interface to enable custom autocomplete for a combo or edit control * CustomAutoCompleteAddString * Adds a new string to the list of values to be used * CustomAutoCompleteEnable * Enables or disables custom autocomplete for a specific control * QueryIERegistryOption * Queries HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main for one of * DISABLE_SCRIPT_DEBUGGER * ERROR_DLG_DISPLAYED_ON_EVERY_ERROR * PLAY_ANIMATIONS * PLAY_BACKGROUND_SOUNDS * DISPLAY_INLINE_VIDEOS * DISPLAY_INLINE_IMAGES * FORMSUGGEST_PW_ASK * USE_FORMSUGGEST * USE_SEARCH_ASST * SetIERegistryOption * Uses HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main to set * IE registry options mentioned in QueryIERegistryOption * DecodeMime * Replaces MIME encoded strings * "%20" --> " " * "%FC" --> "" * "%25" --> "%" etc... * DeleteIEFiles * DELETE_IE_CACHE * DELETE_IE_COOKIES * DELETE_IE_HISTORY * * 5)Bug fixs: * DocHostUIHandler::TranslateAccelerator. * Last param of FindAndHighlightAllText method now returns number of matches found * rather than returning a boolean value indicating success or failure * Added a boolean optional parameter to AddBrowser method to * allow the client to open WBs in the background. By default, Browsers are * opened in the background. * Incorporated IDownloadManager interface within idl. No need for downloadmgr.h * LoadHTMLFromString * Fixed a bug that caused the base URL to be set to about:blank * Added a new parameter (sBaseUrl) to enable client to set base URL * Note: * If length of HTML content is greater than 256 characters, * to display the entire content, client must add a tag * to the beginning of the HTML content * * 6)Removed: * ShowMessage event * Replaced with DocHostShowMessage event * OnAcceletorKeys event * Replaced with OnWBKeyDown and OnWBKeyUp events * WB_SCRIPT_ERROR_ACTION enum * WB_ACCELETOR_KEYS_ACTION enum * AcceletorKeysAction property * Replaced with OnWBKeyDown and OnWBKeyUp events * ScriptErrorAction property * Replaced with OnShowScriptError event * Terminate method * * * Changes from 1.2.1.4: * ===================== * 1)New Events: * WBEvaluateNewWindow, Winxp sp2 and up * * Changes from 1.2.1.3: * ===================== * 1)Bug fixs * IWB::GetIEServerHwnd * IWB::GetShellDocObjHwnd * IWB::GetShellEmbedding * WBDocHostUIHandler::TranslateAccelerator * OnAcceletorKeys was firing for both keydown+up * disable Ctrl+O, has to be handled by client. No default action exists. * 2)Added VBDemoEx to download page * Received a lot of requests for this demo. * * * Changes from 1.2.1.2: * ===================== * 1)New methods * OrganizeFavorites. (Thank you dosuryu) * ViewIEOptions. * 3)Bug fixs * Replaced SecurityManagerProcessUrlAction event with WBProcessUrlAction * New event has two extra parameters PUAF_Flag (one of PUAF enum) and bHandled. * By default, bHandled is false, if setting lpUrlPolicy parameter, you also need * to set the bHandled to true. * lpUrlPolicy parameter is declared as long variable that can be set by client * one of URL Policy Flags. (Thank you ZackJ) * * WBEventDispatch::WBHTMLDocAsStream method. (Thank you dosuryu) * Find method. * SaveAs method. * * Moved all string literals to res file. * * Changes from 1.2.1.1: * ===================== * 1)New Properties * SourceOnDocComplete (Fires DocumentCompleteWBEx instead of DocumentComplete passing document text.) * 2)New events * DocumentCompleteWBEx (Set SourceOnDocComplete property to true, to have this event fire instead of DocumentComplete passing doc text) * 3)Bug fixs * Disabeled Terminate method. Calling this method has no effect. * Fixed WBDocHostShowUI::ShowMessage to use MSHTML provided title. * Modified LoadHtmlFromString to be able to load buffers larger than 500 KB. * Added an optional parameter (bUseIEDefault) to RegisterAsDropTarget property. * (bUseIEDefault default value is False) * (Set bUseIEDefault to true to use default IE drag drop behaviour) * Added a parameter (lWBDropFormat) to WBDrop event. The value can be one of * WB_CFHTML = 0 (includes HTML tags) * WB_CFTEXT = 1 * WB_CFSINGLEFILE = 2 * WB_CFRTF = 3 (Includes RTF tags) * WB_CFERROR = 4 * * Changes from 1.1.1.1: * ===================== * 1)New Properties * WBPageTextSize (ZOOM level - 0 to 4) * * 2)New methods * SaveAsBitmap (Entire page, no scrllbars, no borderstyle) * DrawWBThumbnailOnWnd (stretchblt a thumb img of WB viewing area) * LoadHtmlFromString (Loads an HTML string using PersistStreamInit of document) * DisplayCertificateDialog (If one is available) * SubclassWnd (Subclass a win, for future implementation of mouse gestures) * UnSubclassWnd (Unsubclass previously subclassed win) * AddMessage (Add subclass msg, WM_xxx) * SetupShellAutoComplete (Sets up an EDIT or COMBO for Shell autocomplete) * WBPostData: * (POST Style) * sURL = http://www.site.com * szData = _lang=EN&hm___tg= //Not including ? char * * (GET Style) * sURL = http://www.site.com?_lang=EN&hm___tg= * * 3)New events * OnGetOptionKeyPath (WebBrowser Control instance will ignore any user settings for Internet Explorer) * OnGetOverrideKeyPath (WebBrowser Control instance will incorporate any user settings font settings) * OnWBDragEnter * OnWBDragOver * OnWBDrop (Single file/Link drop - Multi format HDROP,... - Explorer, WB, ...) * OnWBDrop2 (Multiple file drops - Multi format HDROP,... - Explorere,...) * OnWBDragLeave * OnPostDataAvailable * OnPostOnProgress * OnPostError * OnPostEnd * OnPostResponse * OnWMMessage (Fires for any WM_xxx msgs registered via AddMessage method for a subclassed window) * * 4)New interfaces * IDropTarget (DragDrop) * IDocHostUIHandler2 (GetOverrideKeyPath) * IStream (For futher implementation of upload with progress) * * 5)Bug fixs * Changed default value of m_StartupURL to L"" (Thank you dosuryu) * Changed the failed return value of WBHttpSecurity::OnSecurityProblem * method from RPC_E_RETRY to S_FALSE (Thank you folklayer) * Added _T to allow UNICODE build (Thank you Robert). * Modified Terminate and RemoveBrowser methods so as not to display * any messages in regard to ref count and not to generate any COM * errors if ref count of IWB instance is greater than one. * Overrode IOleControlImpl::GetControlInfo and added default handling * of accelerator keys to ProcessWBAccelKeys method based on KB article 187644. * Removed optional keyword from vbMHWB.idl file. * Handled WM_SETFOCUS message to pass the focus from the control to the * first WB while tabbing through controls on a dialog/form. * * * Changes from 1.0.1.1: * ===================== * 1)Added a number of new events: * OnAuthentication * OnHTTPSecurityProblem * ProtocolHandlerOnBeginTransaction * ProtocolHandlerOnResponse * NewWindow3 (WinXP sp2 specific) * 2)Fixed a bug with IOleCommandTarget::Exec method causing certain pages to crash. * 3)Corrected a problem with the internal download control. * Downloading attachements from Hotmail, Yahoo, ... was not being intercepted * due to the use of Content_Disposition header. * 4)Added dosuryu solution to CvbWB::ProcessWBAccelKeys method to process * // /////////////////////////////////////////////////// class WBStream : public IStream { public: WBStream(); ~WBStream(); void InitWBStreamData(short iID, CvbWB *pHost,WBBSCBUpload *lpParent, BSTR URL, void *pvBuffer, ULONG uSize); void InitWBStreamFileName(short iID, CvbWB *pHost,WBBSCBUpload *lpParent, BSTR URL, HANDLE hFile, ULONG uFileSize); // IUnknown STDMETHODIMP QueryInterface(REFIID iid, void ** ppvObject); ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE Release(); // ISequentialStream HRESULT STDMETHODCALLTYPE Read( /* [length_is][size_is][out] */ void *pv, /* [in] */ ULONG cb, /* [out] */ ULONG *pcbRead); HRESULT STDMETHODCALLTYPE Write( /* [size_is][in] */ const void *pv, /* [in] */ ULONG cb, /* [out] */ ULONG *pcbWritten) { // Not needed. return E_NOTIMPL; } // IStream HRESULT STDMETHODCALLTYPE Seek( /* [in] */ LARGE_INTEGER dlibMove, /* [in] */ DWORD dwOrigin, /* [out] */ ULARGE_INTEGER *plibNewPosition) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE SetSize( /* [in] */ ULARGE_INTEGER libNewSize) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CopyTo( /* [unique][in] */ IStream *pstm, /* [in] */ ULARGE_INTEGER cb, /* [out] */ ULARGE_INTEGER *pcbRead, /* [out] */ ULARGE_INTEGER *pcbWritten) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE Commit( /* [in] */ DWORD grfCommitFlags) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE Revert( void) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE LockRegion( /* [in] */ ULARGE_INTEGER libOffset, /* [in] */ ULARGE_INTEGER cb, /* [in] */ DWORD dwLockType) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE UnlockRegion( /* [in] */ ULARGE_INTEGER libOffset, /* [in] */ ULARGE_INTEGER cb, /* [in] */ DWORD dwLockType) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE Stat( /* [out] */ STATSTG *pstatstg, /* [in] */ DWORD grfStatFlag) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE Clone( /* [out] */ IStream **ppstm) { return E_NOTIMPL; } private: //UID of this instance short m_Uid; CComBSTR fUrl; CvbWB *m_Events; HWND m_hwndEvents; ULONG m_cRef; HANDLE m_hFile; char* m_pcBuffer; //ptr to upload buffer ULONG m_uBufferSize; //upload buffer size ULONG m_uFilePos; //last read pos WBBSCBUpload *m_lpParent; }; /////////////////////////////////////////////////////////////////////// // //WBBSCBPost // /* One possible sequence of events: IBindStatusCallback.GetBindInfo IBindStatusCallback.OnStartBinding IHttpNegotiate.BeginningTransaction IBindStatusCallback.OnProgress: Unknown status IBindStatusCallback.OnProgress: Finding resource IBindStatusCallback.OnProgress: Connecting IBindStatusCallback.OnProgress: Sending request IHttpNegotiate.OnResponse: 200 OK IBindStatusCallback.OnProgress: MIME type available IBindStatusCallback.OnProgress: Beginning to download data IBindStatusCallback.OnProgress: Ending data download IBindStatusCallback.OnDataAvailable: the ASP script's reply shows POST data is received IBindStatusCallback.OnStopBinding Class gets Release()d */ //////////////////////////////////////////////////////////////////////// class WBBSCBPost : public IBindStatusCallback, public IHttpNegotiate { public: WBBSCBPost(); ~WBBSCBPost(); // IUnknown ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE Release(); STDMETHODIMP QueryInterface(REFIID iid, void ** ppvObject); //IBindStatusCallback STDMETHODIMP OnStartBinding(DWORD dwReserved, IBinding * pib); STDMETHODIMP GetPriority(LONG * pnPriority); STDMETHODIMP OnLowResource(DWORD reserved); STDMETHODIMP OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText); STDMETHODIMP OnStopBinding(HRESULT hresult,LPCWSTR szError); STDMETHODIMP GetBindInfo(DWORD *grfBINDF, BINDINFO * pbindinfo); STDMETHODIMP OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed); STDMETHODIMP OnObjectAvailable(REFIID riid,IUnknown* punk); // IHttpNegotiate methods STDMETHODIMP BeginningTransaction( LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders); STDMETHODIMP OnResponse( DWORD dwResponseCode, LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders); HRESULT InitPost(short iID, CvbWB *pHost, BSTR URL, LPCTSTR szData); void CancelPost(); private: //UID of this instance short m_Uid; ULONG m_cRef; HGLOBAL m_hDataToPost; // data that we're going to post DWORD m_cbDataToPost; BINDVERB m_dwAction; BOOL m_fRedirect; // need to be informed when we're being redirected by the server IBinding *m_pBinding; //used when a post turns into a get //due to a redirect and data starts //to arrive LPSTREAM m_pstm; DWORD m_cbOld; //URL CComBSTR fUrl; CvbWB *m_Events; HWND m_hwndEvents; VARIANT_BOOL m_vboolCancel; long m_lprogress; long m_lprogressmax; long m_lstatuscode; CComBSTR m_stattext; }; //////////////////////////////////////////////////////////////////////// class WBBSCBUpload : public IBindStatusCallback, public IHttpNegotiate { public: WBBSCBUpload(); ~WBBSCBUpload(); // IUnknown ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE Release(); STDMETHODIMP QueryInterface(REFIID iid, void ** ppvObject); //IBindStatusCallback STDMETHODIMP OnStartBinding(DWORD dwReserved, IBinding * pib); STDMETHODIMP GetPriority(LONG * pnPriority); STDMETHODIMP OnLowResource(DWORD reserved); STDMETHODIMP OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText); STDMETHODIMP OnStopBinding(HRESULT hresult,LPCWSTR szError); STDMETHODIMP GetBindInfo(DWORD *grfBINDF, BINDINFO * pbindinfo); STDMETHODIMP OnDataAvailable(DWORD grfBSCF, DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed); STDMETHODIMP OnObjectAvailable(REFIID riid,IUnknown* punk); // IHttpNegotiate methods STDMETHODIMP BeginningTransaction( LPCWSTR szURL, LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders); STDMETHODIMP OnResponse( DWORD dwResponseCode, LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders); HRESULT InitUpload(short iID, CvbWB *pHost, BSTR URL, void *pvBuffer, ULONG uSize); HRESULT InitUploadFile(short iID, CvbWB *pHost, BSTR URL, LPCTSTR sFileName); void CancelUpload(); private: //UID of this instance short m_Uid; ULONG m_cRef; DWORD m_ulDataSize; BINDVERB m_dwAction; BOOL m_fRedirect; // need to be informed when we're being redirected by the server IBinding *m_pBinding; //used when a post turns into a get //due to a redirect and data starts //to arrive LPSTREAM m_pstm; WBStream *m_stPostData; DWORD m_cbOld; //URL CComBSTR fUrl; CvbWB *m_Events; HWND m_hwndEvents; VARIANT_BOOL m_vboolCancel; long m_lprogress; long m_lprogressmax; long m_lstatuscode; CComBSTR m_stattext; HANDLE m_hFile; void *m_lpBuffer; }; ////////////////////////////////////////////////////////////////////////////////////////////// class WBIHTMLOMWindowServices : IHTMLOMWindowServices { public: WBIHTMLOMWindowServices(IWB* pFrameSite); ~WBIHTMLOMWindowServices(); // IUnknown // *** IUnknown *** STDMETHODIMP QueryInterface(REFIID iid, void ** ppvObject); ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE Release(); //IHTMLOMWindowServices STDMETHODIMP moveTo( LONG x, LONG y); STDMETHODIMP moveBy( LONG x, LONG y); STDMETHODIMP resizeTo( LONG x, LONG y); STDMETHODIMP resizeBy( LONG x, LONG y); private: IWB *m_pHost; }; ////////////////////////////////////////////////////////////////////////////////////////////// // /* Problem: Loading HTML content from stream using IPersistStreamInit causes the base URL to always be "about:blank" Solution: Another way is to write a custom implementation of IMoniker interface. You only need a non-trivial implementation of two methods: BindToStorage should return the IStream with your HTML content, and GetDisplayName should return the base URL you want to use to resolve relative links. You then use IPersistMoniker to feed the content into MSHTML using this custom implementation, instead of IPersistStreamInit. Igor */ //Except for BindToStorage and GetDisplayName methods //All other methods return E_NOTIMPL ////////////////////////////////////////////////////////////////////////////////////////////// class CLoadHTMLMoniker : public IMoniker { public: CLoadHTMLMoniker() { m_cRef = 1; } //We delete this ourselves ~CLoadHTMLMoniker() { } // IUnknown ULONG STDMETHODCALLTYPE AddRef() { return ++m_cRef; } ULONG STDMETHODCALLTYPE Release() { if(--m_cRef == 0) { delete this; return 0; } return m_cRef; } STDMETHODIMP QueryInterface(REFIID iid, void ** ppvObject) { if(ppvObject == NULL) return E_INVALIDARG; *ppvObject = NULL; if( iid==IID_IMoniker ) { *ppvObject = (IMoniker*)this; } if (NULL != *ppvObject) { AddRef(); return S_OK; } return E_NOINTERFACE; } STDMETHODIMP BindToObject( /* [unique][in] */ IBindCtx *pbc, /* [unique][in] */ IMoniker *pmkToLeft, /* [in] */ REFIID riidResult, /* [iid_is][out] */ void **ppvResult) { return E_NOTIMPL; } STDMETHODIMP BindToStorage( /* [unique][in] */ IBindCtx *pbc, /* [unique][in] */ IMoniker *pmkToLeft, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObj) { // NB: only IID_IStream seems to be used return m_spStream->QueryInterface(riid, ppvObj); } STDMETHODIMP Reduce( /* [unique][in] */ IBindCtx *pbc, /* [in] */ DWORD dwReduceHowFar, /* [unique][out][in] */ IMoniker **ppmkToLeft, /* [out] */ IMoniker **ppmkReduced) { return E_NOTIMPL; } STDMETHODIMP ComposeWith( /* [unique][in] */ IMoniker *pmkRight, /* [in] */ BOOL fOnlyIfNotGeneric, /* [out] */ IMoniker **ppmkComposite) { return E_NOTIMPL; } STDMETHODIMP Enum( /* [in] */ BOOL fForward, /* [out] */ IEnumMoniker **ppenumMoniker) { return E_NOTIMPL; } STDMETHODIMP IsEqual( /* [unique][in] */ IMoniker *pmkOtherMoniker) { return E_NOTIMPL; } STDMETHODIMP Hash( /* [out] */ DWORD *pdwHash) { return E_NOTIMPL; } STDMETHODIMP IsRunning( /* [unique][in] */ IBindCtx *pbc, /* [unique][in] */ IMoniker *pmkToLeft, /* [unique][in] */ IMoniker *pmkNewlyRunning) { return E_NOTIMPL; } STDMETHODIMP GetTimeOfLastChange( /* [unique][in] */ IBindCtx *pbc, /* [unique][in] */ IMoniker *pmkToLeft, /* [out] */ FILETIME *pFileTime) { return E_NOTIMPL; } STDMETHODIMP Inverse( /* [out] */ IMoniker **ppmk) { return E_NOTIMPL; } STDMETHODIMP CommonPrefixWith( /* [unique][in] */ IMoniker *pmkOther, /* [out] */ IMoniker **ppmkPrefix) { return E_NOTIMPL; } STDMETHODIMP RelativePathTo( /* [unique][in] */ IMoniker *pmkOther, /* [out] */ IMoniker **ppmkRelPath) { return E_NOTIMPL; } STDMETHODIMP GetDisplayName( /* [unique][in] */ IBindCtx *pbc, /* [unique][in] */ IMoniker *pmkToLeft, /* [out] */ LPOLESTR *ppszDisplayName) { if (!ppszDisplayName) return E_INVALIDARG; CComPtr spMalloc; CoGetMalloc(1, &spMalloc); if (m_strBaseURL.Length()) { UINT cchCommandText = sizeof(OLECHAR) * (m_strBaseURL.Length() + 1); *ppszDisplayName = (OLECHAR*) spMalloc->Alloc( cchCommandText ); if(*ppszDisplayName != NULL) { memcpy(*ppszDisplayName, m_strBaseURL, cchCommandText); *(*ppszDisplayName + m_strBaseURL.Length()) = (OLECHAR)NULL; return S_OK; } } *ppszDisplayName = NULL; return E_NOTIMPL; } STDMETHODIMP ParseDisplayName( /* [unique][in] */ IBindCtx *pbc, /* [unique][in] */ IMoniker *pmkToLeft, /* [in] */ LPOLESTR pszDisplayName, /* [out] */ ULONG *pchEaten, /* [out] */ IMoniker **ppmkOut) { return E_NOTIMPL; } STDMETHODIMP IsSystemMoniker( /* [out] */ DWORD *pdwMksys) { return E_NOTIMPL; } //IPersistStream STDMETHODIMP IsDirty( void) { return E_NOTIMPL; } STDMETHODIMP Load( /* [unique][in] */ IStream *pStm) { return E_NOTIMPL; } STDMETHODIMP Save( /* [unique][in] */ IStream *pStm, /* [in] */ BOOL fClearDirty) { return E_NOTIMPL; } STDMETHODIMP GetSizeMax( /* [out] */ ULARGE_INTEGER *pcbSize) { return E_NOTIMPL; } //IPersist STDMETHODIMP GetClassID( /* [out] */ CLSID *pClassID) { return E_NOTIMPL; } /////////////////////////////////////////////// // init the moniker object HRESULT SetHTML(BSTR pszHTML, BSTR pszBaseURL) { m_strBaseURL = pszBaseURL; m_spStream.Release(); UINT len = ::SysStringLen(pszHTML); //Allocate global memory to copy the HTML content to //GPTR HGLOBAL hHTMLContent = ::GlobalAlloc(GMEM_ZEROINIT , ( len + 1 ) * sizeof(OLECHAR) ); if (!hHTMLContent) return E_FAIL; memcpy(hHTMLContent, (void*)pszHTML, len * sizeof(OLECHAR)); // mark this string as UNICODE //((wchar_t*) hHTMLContent)[0] = 0xfeff; //::wcscpy( ((wchar_t*) hHTMLContent)+1, pszHTML ); CComPtr spStream; return ::CreateStreamOnHGlobal( hHTMLContent, TRUE, &m_spStream ); } private: ULONG m_cRef; CComBSTR m_strBaseURL; CComPtr m_spStream; }; ////////////////////////////////////////////////////////////////////////////////////////////// //WBPassthruSink //To allow implementation of temp protocols, http, https,... //Posted by Igor Tandetnik "itandetnik@mvps.org" //Can be found using a search for PassthroughApp in google groups ////////////////////////////////////////////////////////////////////////////////////////////// class WBPassthruSink : public PassthroughAPP::CInternetProtocolSinkWithSP, public IHttpNegotiate { typedef PassthroughAPP::CInternetProtocolSinkWithSP BaseClass; public: BEGIN_COM_MAP(WBPassthruSink) COM_INTERFACE_ENTRY(IHttpNegotiate) COM_INTERFACE_ENTRY_CHAIN(BaseClass) END_COM_MAP() BEGIN_SERVICE_MAP(WBPassthruSink) SERVICE_ENTRY(IID_IHttpNegotiate) END_SERVICE_MAP() STDMETHODIMP BeginningTransaction( /* [in] */ LPCWSTR szURL, /* [in] */ LPCWSTR szHeaders, /* [in] */ DWORD dwReserved, /* [out] */ LPWSTR *pszAdditionalHeaders); STDMETHODIMP OnResponse( /* [in] */ DWORD dwResponseCode, /* [in] */ LPCWSTR szResponseHeaders, /* [in] */ LPCWSTR szRequestHeaders, /* [out] */ LPWSTR *pszAdditionalRequestHeaders); HRESULT OnStart(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, DWORD dwReserved, IInternetProtocol* pTargetProtocol); STDMETHODIMP ReportProgress( /* [in] */ ULONG ulStatusCode, /* [in] */ LPCWSTR szStatusText); STDMETHODIMP Switch( /* [in] */ PROTOCOLDATA *pProtocolData); //private: CvbWB *m_pEvents; IWB *m_pHost; // CComPtr spBSCB; short m_Hostid; CComBSTR m_strUrl; CComBSTR m_strRedirUrl; CComBSTR m_strRedirHeaders; }; typedef PassthroughAPP::CustomSinkStartPolicy TestStartPolicy; class WBPassthru : public PassthroughAPP::CInternetProtocol { /* public: STDMETHODIMP Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD grfPI, DWORD dwReserved) { ::MessageBox(GetDesktopWindow(), _T("Start"),_T("PassthroughAPP::CInternetProtocol"),MB_OK); ATLASSERT(m_spInternetProtocol != 0); if (!m_spInternetProtocol) { return E_UNEXPECTED; } return TestStartPolicy::OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInternetProtocol); } */ }; #endif //__VBWB_H_