/** * @file XTPShellExplorerProvider.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #if !defined(__XTPSHELLEXPLORERPROVIDER_H__) /** @cond */ # define __XTPSHELLEXPLORERPROVIDER_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" # pragma warning(push) // C4616: #pragma warning : warning number '5204' out of range, must be between '4001' and '4999' // C5204: '...': class has virtual functions, but its trivial destructor is not virtual; instances // of objects derived from this class may not be destructed correctly # pragma warning(disable : 4616 5204) /** @cond */ struct IXTPWebBrowserHost; class CXTPShellBrowserSite; /** @endcond */ /** * @brief * Implements ShellExplorer WebBrowser provider and gives access to ShellExplorer specific * functionality. */ class _XTP_EXT_CLASS CXTPShellExplorerProvider : public CXTPWebBrowserProvider { /** @cond */ DECLARE_DYNAMIC(CXTPShellExplorerProvider) /** @endcond */ friend class CXTPShellBrowserSite; public: /** * @brief * Defines ShellExplorer scrollbar styles */ enum ScrollBarStyle { xtpScrollBarStandard, /**< Normal scrollbars */ xtpScrollBarFlat, /**< Flat scrollbars */ xtpScrollBarNone /**< Scrollbars are turned off */ }; /** * @brief * Constructs provider object. * @param host The host control interface. */ CXTPShellExplorerProvider(IXTPWebBrowserHost& host); /** * @brief * Handles provider destruction. */ ~CXTPShellExplorerProvider(); /** * @brief * Gets a flag value that enables registration of the WebBrowser control as drop * target. * @return * The current flag value. */ BOOL GetRegisterAsDropTarget() const; /** * @brief * Sets a flag value that enables registration of the WebBrowser control as drop * target. * @param bRegisterAsDropTarget The new flag value. */ void SetRegisterAsDropTarget(BOOL bRegisterAsDropTarget = TRUE); /** * @brief * Gets a flag value that enables WebBrowser control context menu. * @return * The current flag value. */ BOOL GetContextMenuEnabled() const; /** * @brief * Sets a flag value that enables WebBrowser control context menu. * @param bContextMenuEnabled The new flag value. */ void SetContextMenuEnabled(BOOL bContextMenuEnabled = TRUE); /** * @brief * Gets WebBrowser control scrollbar style. * @return * The current scrollbar style. */ ScrollBarStyle GetScrollBarStyle() const; /** * @brief * Sets WebBrowser control scrollbar style. * @param nScrollBarStyle The new scrollbar style. */ void SetScrollBarStyle(ScrollBarStyle nScrollBarStyle); /** * @brief * Gets a flag that suppresses script errors on a loaded web page. * @return * The current flag value. */ BOOL GetScriptErrorsSuppressed() const; /** * @brief * Sets a flag that suppresses script errors on a loaded web page. * @param bScriptErrorsSuppressed The new flag value. */ void SetScriptErrorsSuppressed(BOOL bScriptErrorsSuppressed = TRUE); /** * @brief * Gets a flag that enables selection of the text in the form. * @return * The current flag value. */ BOOL GetStaticText() const; /** * @brief * Sets a flag that enables selection of the text in the form. * @param bStaticText The new flag value. */ void SetStaticText(BOOL bStaticText = TRUE); /** * @brief * Navigates to the specified URL and provides additional parameters for the browser to use * and customize navigation. * @param pvtURL A pointer to a VARIANT that evaluates to the URL of the resource to display, * the full path to the file location, or a PIDL that represents a folder in the * Shell namespace. * @param pvtFlags A pointer to a VARIANT of type VT_I4 or VT_I2 that specifies a combination of * the values defined by the BrowserNavConstants enumeration from the Windows * SDK. * @param pvtTargetFrameName A pointer to a case-sensitive string that contains the name of the * frame in which to display the resource ("_blank", "_parent", * "_self", "_top" or a named HTML frame). * @param pvtPostData A pointer to a VARIANT of type VT_ARRAY|VT_UI1 that is sent to the server * as part of a HTTP POST transaction. A POST transaction typically is used to * send data collected by an HTML form. If this parameter does not specify any * POST data, this method issues an HTTP GET transaction. This parameter is * ignored if URL is not an HTTP (or HTTPS) URL. * @param pvtHeaders A pointer to a VARIANT of type VT_BSTR that contains additional HTTP * headers to send to the server. These headers are added to the default Windows Internet * Explorer headers. For example, headers can specify the action required of the server, the * type of data being passed to the server, or a status code. This parameter is ignored if the * URL is not an HTTP (or HTTPS) URL. * @return * S_OK if navigation is successul or an error code otherwise. */ HRESULT Navigate2(VARIANT* pvtURL, VARIANT* pvtFlags = NULL, VARIANT* pvtTargetFrameName = NULL, VARIANT* pvtPostData = NULL, VARIANT* pvtHeaders = NULL); /** * @brief * Executes a JavaScript code. * @param pText Script code text. * @param pvtResult The optional pointer to the variant object that is supposed to receive the * result of the executed script. * @return * S_OK if script execution or its attempt are successful or an error code otherwise. */ virtual HRESULT ExecuteScript(LPCWSTR pText, CComVariant* pvtResult = NULL); private: /** @cond */ virtual HRESULT Initialize(); virtual HRESULT Navigate(LPCTSTR pUrl); virtual HRESULT LoadHtml(LPCTSTR pHtml); virtual HRESULT WaitUntilReady(); virtual void ReleaseBrowser(); virtual BOOL OnHostWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult); virtual void OnCreateBrowser(IUnknown* pObject); virtual CXTPWebBrowserControlSite* CreateControlSite(COleControlContainer* pCtrlContainer); virtual BOOL PreTranslateMessage(MSG* pMsg); BOOL OnSize(UINT nType, int cx, int cy); BOOL OnDestroy(); BOOL OnSetFocus(CWnd* pOldWnd); int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message); afx_msg void OnStatusTextChange(LPCTSTR lpszText); afx_msg void OnProgressChange(long nProgress, long nProgressMax); afx_msg void OnCommandStateChange(long nCommand, BOOL bEnable); afx_msg void OnDownloadBegin(); afx_msg void OnDownloadComplete(); afx_msg void OnTitleChange(LPCTSTR lpszText); afx_msg void OnPropertyChange(LPCTSTR lpszProperty); afx_msg void OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel); afx_msg void OnQuit(); afx_msg void OnVisible(BOOL bVisible); afx_msg void OnToolBar(BOOL bToolBar); afx_msg void OnMenuBar(BOOL bMenuBar); afx_msg void OnStatusBar(BOOL bStatusBar); afx_msg void OnFullScreen(BOOL bFullScreen); afx_msg void OnTheaterMode(BOOL bTheaterMode); afx_msg void OnNavigateComplete2(LPDISPATCH pDisp, VARIANT* URL); afx_msg void OnBeforeNavigate2(LPDISPATCH pDisp, VARIANT* URL, VARIANT* Flags, VARIANT* TargetFrameName, VARIANT* PostData, VARIANT* Headers, BOOL* Cancel); afx_msg void OnDocumentComplete(LPDISPATCH pDisp, VARIANT* URL); afx_msg void OnNavigateError(LPDISPATCH pDisp, VARIANT* URL, VARIANT* TargetFrameName, VARIANT* StatusCode, BOOL* Cancel); afx_msg void OnWindowSetResizable(BOOL Resizable); afx_msg void OnWindowSetLeft(long Left); afx_msg void OnWindowSetTop(long Top); afx_msg void OnWindowSetWidth(long Width); afx_msg void OnWindowSetHeight(long Height); afx_msg void OnWindowClosing(BOOL IsChildWindow, BOOL FAR* Cancel); afx_msg void OnSetSecureLockIcon(long SecureLockIcon); DECLARE_INTERFACE_MAP(); private: BEGIN_INTERFACE_PART(WebBrowserEvents2, DWebBrowserEvents2) virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount( /* [out] */ UINT* pctinfo); virtual HRESULT STDMETHODCALLTYPE GetTypeInfo( /* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo** ppTInfo); virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames( /* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR* rgszNames, /* [range][in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID* rgDispId); virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke( /* [annotation][in] */ DISPID dispIdMember, /* [annotation][in] */ REFIID riid, /* [annotation][in] */ LCID lcid, /* [annotation][in] */ WORD wFlags, /* [annotation][out][in] */ DISPPARAMS* pDispParams, /* [annotation][out] */ VARIANT* pVarResult, /* [annotation][out] */ EXCEPINFO* pExcepInfo, /* [annotation][out] */ UINT* puArgErr); END_INTERFACE_PART(WebBrowserEvents2) private: CXTPShellExplorerProvider(const CXTPShellExplorerProvider&); CXTPShellExplorerProvider& operator=(const CXTPShellExplorerProvider&); CWnd* m_pBrowser; IWebBrowser2* m_pBrowserApp; CXTPShellBrowserSite* m_pSite; COccManager* m_pOccManager; IConnectionPoint* m_pCpEvents; DWORD m_dwCpEventsCookie; BOOL m_bRegisterAsDropTarget; BOOL m_bContextMenuEnabled; ScrollBarStyle m_nScrollBarStyle; BOOL m_bScriptErrorsSuppressed; BOOL m_bStaticText; /** @endcond */ }; /** @cond */ AFX_INLINE BOOL CXTPShellExplorerProvider::GetRegisterAsDropTarget() const { return m_bRegisterAsDropTarget; } AFX_INLINE void CXTPShellExplorerProvider::SetContextMenuEnabled(BOOL bContextMenuEnabled /*= TRUE*/) { m_bContextMenuEnabled = bContextMenuEnabled; } AFX_INLINE BOOL CXTPShellExplorerProvider::GetContextMenuEnabled() const { return m_bContextMenuEnabled; } AFX_INLINE void CXTPShellExplorerProvider::SetScrollBarStyle(ScrollBarStyle nScrollBarStyle) { m_nScrollBarStyle = nScrollBarStyle; } AFX_INLINE CXTPShellExplorerProvider::ScrollBarStyle CXTPShellExplorerProvider::GetScrollBarStyle() const { return m_nScrollBarStyle; } AFX_INLINE void CXTPShellExplorerProvider::SetScriptErrorsSuppressed(BOOL bScriptErrorsSuppressed /*= TRUE*/) { m_bScriptErrorsSuppressed = bScriptErrorsSuppressed; } AFX_INLINE BOOL CXTPShellExplorerProvider::GetScriptErrorsSuppressed() const { return m_bScriptErrorsSuppressed; } AFX_INLINE void CXTPShellExplorerProvider::SetStaticText(BOOL bStaticText /*= TRUE*/) { m_bStaticText = bStaticText; } AFX_INLINE BOOL CXTPShellExplorerProvider::GetStaticText() const { return m_bStaticText; } # pragma warning(pop) # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif /** @endcond */