/** * @file XTPSkinManager.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 * */ /** @cond */ #if !defined(__XTPSKINMANAGER_H__) # define __XTPSKINMANAGER_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableAdvancedWarnings.h" # include # include "Common/Base/Diagnostic/XTPEnableAdvancedWarnings.h" # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPSkinManagerSchemaProperty; class CXTPSkinManagerResourceFile; class CXTPSkinManagerColorFilter; class CXTPSkinObjectClassMap; class CXTPSkinManagerApiHookBase; class CXTPSkinManagerModuleListSharedData; class CXTPSkinManagerSchemaCodeManager; class CXTPColorManager; class CXTPDpi; typedef HANDLE HTHEME; /** * @brief * Applied options of the selected skin. * * Example: *
 * XTPSkinManager()->SetApplyOptions(xtpSkinApplyMetrics | xtpSkinApplyFrame | xtpSkinApplyColors);
 * 
* @see * CXTPSkinManager, CXTPSkinManager::SetApplyOptions, * xtpSkinApplyMetrics, xtpSkinApplyFrame, xtpSkinApplyColors */ enum XTPSkinApplyOptions { xtpSkinApplyMetrics = 1, /**< TRUE to use skin provided metrics.*/ xtpSkinApplyFrame = 2, /**< TRUE to apply frame skins.*/ xtpSkinApplyColors = 4, /**< TRUE to use skin provided colors*/ xtpSkinApplyMenus = 8, /**< TRUE to apply skin for pop-up menus.*/ xtpSkinApplyDCs = 0x10, /**< TRUE to apply skin to device context that have no associated window handles. */ xtpSkinApplyCommandBarsFrame = 0x20 /**< TRUE to apply skin frame with CommandBars. */ }; /** * @brief * Available properties for the CXTPSkinManagerSchemaProperty class. * * Example: *
 * XTPSkinManager()->GetProperty(XTP_SKINPROPERTY_BOOL, iPartId, iStateId, TMT_TRANSPARENT);
 * 
* @see * CXTPSkinManagerSchemaProperty */ enum XTPSkinManagerProperty { XTP_SKINPROPERTY_UNKNOWN, /**< Not defined. */ XTP_SKINPROPERTY_STRING, /**< CString property. */ XTP_SKINPROPERTY_INT, /**< int property. */ XTP_SKINPROPERTY_BOOL, /**< BOOL property. */ XTP_SKINPROPERTY_COLOR, /**< COLORREF property. */ XTP_SKINPROPERTY_RECT, /**< CRect property. */ XTP_SKINPROPERTY_FONT, /**< LOGFONT property. */ XTP_SKINPROPERTY_INTLIST, /**< CIntArray property.*/ XTP_SKINPROPERTY_ENUM, /**< enum property. */ XTP_SKINPROPERTY_POSITION, /**< int property. */ XTP_SKINPROPERTY_FILENAME = XTP_SKINPROPERTY_STRING, /**< FileName property. */ XTP_SKINPROPERTY_MARGINS = XTP_SKINPROPERTY_RECT, /**< Margins property. */ XTP_SKINPROPERTY_SIZE = XTP_SKINPROPERTY_INT /**< Size property. */ }; class CXTPSkinManager; class CXTPSkinManagerSchema; class CXTPSkinImages; class CXTPSkinObject; /** * @brief * CXTPSkinManagerClass is a standalone class that represents a * single visual class of the skin manager. */ class _XTP_EXT_CLASS CXTPSkinManagerClass : public CXTPSynchronized { public: /** * @brief * Constructs a CXTPSkinManagerClass object. * @param pSchema Pointer to the parent skin manager class. * @param pszClassList Class name. * @param nClassCode Hash value of the class name. */ CXTPSkinManagerClass(CXTPSkinManagerSchema* pSchema, CString pszClassList, int nClassCode); /** * @brief * Destroys a CXTPSkinManagerClass object, handles cleanup and deallocation. */ virtual ~CXTPSkinManagerClass(); public: /** * @brief * Gets the value of a specified string property. * @param iPartId Part number. * @param iStateId State number of the part. * @param iPropId Property number to get the value of. * @param lpszDefault Default value. * @return * The value of the specified string property. */ CString GetThemeString(int iPartId, int iStateId, int iPropId, LPCTSTR lpszDefault = NULL); /** * @brief * Gets the value of a specified RECT property. * @param iPartId Part number. * @param iStateId State number of the part. * @param iPropId Property number to get the value of. * @param rcDefault Default value. * @return * The value of the specified RECT property. */ CRect GetThemeRect(int iPartId, int iStateId, int iPropId, CRect rcDefault = CRect(0, 0, 0, 0)); /** * @brief * Gets the value of a specified int property. * @param iPartId Part number. * @param iStateId State number of the part. * @param iPropId Property number to get the value of. * @param nDefault Default value. * @return * The value of the specified int property. */ int GetThemeInt(int iPartId, int iStateId, int iPropId, int nDefault = 0); /** * @brief * Gets the value of a specified size property. * @param iPartId Part number. * @param iStateId State number of the part. * @param iPropId Property number to get the value of. * @param szDefault Default value. * @return * The value of the specified size property. */ CSize GetThemeSize(int iPartId, int iStateId, int iPropId, CSize szDefault = CSize(0)); /** * @brief * Gets the value of a specified BOOL property. * @param iPartId Part number. * @param iStateId State number of the part. * @param iPropId Property number to get the value of. * @param bDefault Default value. * @return * The value of the specified BOOL property. */ BOOL GetThemeBool(int iPartId, int iStateId, int iPropId, BOOL bDefault = FALSE); /** * @brief * Gets the value of a specified color property. * @param iPartId Part number. * @param iStateId State number of the part. * @param iPropId Property number to get the value of. * @param clrDefault Default value. * @return * The value of the specified color property. */ COLORREF GetThemeColor(int iPartId, int iStateId, int iPropId, COLORREF clrDefault = (COLORREF)-1); /** * @brief * Gets the value of a specified enum property. * @param iPartId Part number. * @param iStateId State number of the part. * @param iPropId Property number to get the value of. * @param nDefault Default value. * @return * The value of the specified enum property. */ int GetThemeEnumValue(int iPartId, int iStateId, int iPropId, int nDefault = 0); /** * @brief * Gets the size of a specified theme part. * @param iPartId Part number. * @param iStateId State number of the part. * @param pRect Pointer to a RECT for the part drawing destination. * @param eSize Type of size to be retrieved. * @param pSize Pointer to a SIZE that receives the size of the part. * @return * TRUE if successful, otherwise FALSE. */ BOOL GetThemePartSize(int iPartId, int iStateId, RECT* pRect, int eSize, SIZE* pSize); public: /** * @brief * Draws the background image defined by the visual style for a * specified control part. * @param pDC Pointer to a valid device context. * @param iPartId Specifies the part to draw. * @param iStateId Specifies the state of the part to draw. * @param pRect Pointer to a RECT structure that contains the rectangle, * in logical coordinates, in which the background image is to be drawn. * @return * TRUE if successful, otherwise FALSE. */ BOOL DrawThemeBackground(CDC* pDC, int iPartId, int iStateId, const RECT* pRect); /** * @brief * Draws text using the color and font defined by the visual style. * @param pDC Pointer to a valid device context. * @param iPartId Specifies the part that contains the text. * @param iStateId Specifies the state of the part to draw. * @param strText Reference to a string that contains the text to draw. * @param dwFormat One or more values that specify the string's formatting. * @param pRect Pointer to a RECT structure that contains the rectangle, * in logical coordinates, in which the text is to be drawn. * @return * TRUE if successful, otherwise FALSE. */ BOOL DrawThemeText(CDC* pDC, int iPartId, int iStateId, const CString& strText, DWORD dwFormat, const RECT* pRect); /** * @brief * Gets the image collection of the class. * @return * A pointer to the image collection of the class. */ CXTPSkinImages* GetImages() const; /** * @brief * Gets the hash value of the class name. * @return * The hash value of the class name. */ int GetClassCode() const; /** * @brief * Gets the class name. * @return * The class name. */ CString GetClassName() const; public: /** * @brief * Gets the property value of a specified part and state. * @param propType Property type. * @param iPartId Part number. * @param iStateId State number of the part. * @param iPropId Property number to get the value of. * @return * A pointer to the CXTPSkinManagerSchemaPropertyClass containing * the value of the property. * @see * XTPSkinManagerProperty, CXTPSkinManagerSchemaProperty */ CXTPSkinManagerSchemaProperty* GetProperty(XTPSkinManagerProperty propType, int iPartId, int iStateId, int iPropId); /** @cond */ _XTP_DEPRECATED HTHEME GetSystemTheme(); static CXTPSkinManagerClass* FromHandle(HTHEME hTheme); void BindTheme(HTHEME hTheme); void UnbindTheme(HTHEME hTheme); /** @endcond */ private: void UnbindTheme(HTHEME hTheme, BOOL bFinal); void UnbindAllThemes(); protected: CXTPSkinManagerSchema* m_pSchema; /**< Parent CXTPSkinManager object. */ /** @cond */ _XTP_DEPRECATED HTHEME m_hSystemTheme; /** @endcond */ CString m_strClass; /**< Class name. */ UINT m_nClassCode; /**< Hashed value of the class name. */ CXTPSkinImages* m_pImages; /**< Image collection. */ CMap m_mapCachedProperties; /**< Cached collection of class properties. */ private: struct ThemeClassAssoc { ThemeClassAssoc() : nRefs(0) , pClass(NULL) { } LONG nRefs; CXTPSkinManagerClass* pClass; }; static CCriticalSection m_themeClassAccess; static CMap m_themeClasses; }; # define XTP_SKINMETRICS_COLORTABLESIZE 31 /** * @brief * Implement this interface in order to provide custom configured * window filter functionality. The filtered out windows will not be * skinned. If you find yourself frequently filtering out some system * window in order to prevent application crashes, please report to us * its class name and, ideally, the contents of the WNDCLASS structure * filled out by a call to GetWindowClass for this window handle. * Use CXTPSkinManager::SetWindowFilter for setting or disabling a * custom provided window filter implementation. */ struct IXTPSkinManagerWindowFilter { /** * Handles object destruction */ virtual ~IXTPSkinManagerWindowFilter() { } /** * @brief * The implementation must make a decision as to whether a window * class must be filtered out (not skinned) or not, depending on certain * window class characteristics. * @param lpszClassName Window class name. * @return * TRUE if the window class has to be filtered out, otherwise FALSE (default). */ virtual BOOL FilterWindowClass(LPCSTR lpszClassName) = 0; /** * @brief * The implementation must make a decision as to whether a window * class must be filtered out (not skinned) or not, depending on certain * window class characteristics. * @param lpszClassName Window class name. * @return * TRUE if the window class has to be filtered out, otherwise FALSE (default). */ virtual BOOL FilterWindowClass(LPCWSTR lpszClassName) = 0; /** * @brief * The implementation must make a decision as to whether a window * must be filtered out (not skinned) or not depending on certain * window characteristics. * @param hWnd Window handle. * @param lpszClassName Window class name if known, otherwise NULL. * @param lpcs Pointer to the window's CREATESTRUCT structure if known, otherwise NULL. * @return * TRUE if the window has to be filtered out, otherwise FALSE (default). */ virtual BOOL FilterWindow(HWND hWnd, LPCTSTR lpszClassName, LPCREATESTRUCT lpcs) = 0; }; /** * @brief * CXTPSkinManagerMetrics is a standalone class that represents a * collection of metrics of the current skin. */ class _XTP_EXT_CLASS CXTPSkinManagerMetrics : public CXTPSynchronized { public: /** * @brief * Constructs a CXTPSkinManagerMetrics object. * @param pSchema Pointer to the parent skin manager class. */ CXTPSkinManagerMetrics(CXTPSkinManagerSchema* pSchema); /** * @brief * Destroys a CXTPSkinManagerMetrics object, handles cleanup and deallocation. */ virtual ~CXTPSkinManagerMetrics(); public: /** * @brief * Refreshes visual metrics. */ virtual void RefreshMetrics(); /** * @brief * Determines if a specified handle belongs to metrics. * @param hObject Handle to be tested. * @return * TRUE if the specified handle belongs to metrics, otherwise FALSE. */ BOOL IsMetricObject(HGDIOBJ hObject) const; /** @cond */ /** * @brief Determines if handle belongs to any existing metrics. */ _XTP_DEPRECATED_IN_FAVOR(IsMetricObject) static BOOL AFX_CDECL IsKnownMetricObject(HGDIOBJ hObject); /** @endcond */ /** * @brief * Destroys all GDI objects of metrics. */ void DestroyMetrics(); /** * @brief * Retrieves the skinned color of a specified index. * @param nIndex Index of the skinned color to retrieve. * @return * The skinned color of the specified index, otherwise COLORREF_NULL. */ COLORREF GetColor(int nIndex) const; /** * @brief * Retrieves the skinned brush of a specified index. * @param nIndex Index of the skinned brush to retrieve. * @return * The skinned brush of the specified index, otherwise NULL. */ HBRUSH GetBrush(int nIndex) const; /** * @brief * Creates a tab control brush. * @param pBitmap Pointer to the bitmap to be used * as the tab control brush pattern. * @return * TRUE if the tab control brush was successfully created. */ BOOL CreateTabControlBrush(CBitmap* pBitmap); public: mutable CXTPCriticalSection m_csAccess; BOOL m_bAllowHandleDestroy; CXTPFont m_xtpFontCaption; /**< Caption font. */ CXTPFont m_xtpFontMenu; /**< Menu font. */ CXTPFont m_xtpFontSmCaption; /**< Small caption font. */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fntCaption, m_xtpFontCaption, GetCaptionFontHandle); XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fntMenu, m_xtpFontMenu, GetMenuFontHandle); XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fntSmCaption, m_xtpFontSmCaption, GetSmCaptionFontHandle); CXTPSkinManagerSchema* m_pSchema; /**< Parent CXTPSkinManager object. */ CXTPBrush m_xtpBrushDialog; /**< Dialog brush. */ CXTPBrush m_xtpBrushTabControl; /**< Tab control brush. */ CXTPBrush m_xtpBrushWindow; /**< Window brush. */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED_(HBRUSH, HBRUSH, HBRUSH, m_brushDialog, m_xtpBrushDialog, GetDialogBrushHandle); XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED_(HBRUSH, HBRUSH, HBRUSH, m_brushTabControl, m_xtpBrushTabControl, GetTabControlBrushHandle); XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED_(HBRUSH, HBRUSH, HBRUSH, m_brushWindow, m_xtpBrushWindow, GetWindowBrushHandle); COLORREF m_clrEdgeLight; /**< Light edge color. */ COLORREF m_clrEdgeHighLight; /**< HighLight edge color. */ COLORREF m_clrEdgeShadow; /**< Shadow edge color. */ COLORREF m_clrEdgeDkShadow; /**< Dark shadow edge color. */ COLORREF m_clrTheme[XTP_SKINMETRICS_COLORTABLESIZE]; /**< Colors of the theme. */ HBRUSH m_brTheme[XTP_SKINMETRICS_COLORTABLESIZE]; /**< Brushes of the theme. */ int m_nBorderSize; /**< Border size. */ int m_cxBorder; /**< SM_CXBORDER system metric. */ int m_cyBorder; /**< SM_CYBORDER system metric. */ int m_cxEdge; /**< SM_CXEDGE system metric. */ int m_cyEdge; /**< SM_CYEDGE system metric. */ int m_cxHScroll; /**< SM_CXHSCROLL system metric. */ int m_cyHScroll; /**< SM_CYHSCROLL system metric. */ int m_cxVScroll; /**< SM_CXVSCROLL system metric. */ int m_cyVScroll; /**< SM_CYVSCROLL system metric. */ int m_cyCaption; /**< Height of captions. */ int m_cySmallCaption; /**< Height of small captions. */ int m_cyOsCaption; /**< System caption height. */ int m_cyOsSmallCaption; /**< System small caption height. */ int m_cxOsVScroll; /**< System SM_CXVSCROLL metric. */ BOOL m_bRefreshMetrics; /**< TRUE if refresh metrics is currently executed. */ }; /** * @brief * CXTPSkinManager is a standalone class that represents a * global object that manages skins. */ class _XTP_EXT_CLASS CXTPSkinManager : public CXTPSynchronized , IXTPApplicationEvents { friend class CXTPSingleton< CXTPSkinManager, CXTPSingletonDependencies, CXTPSingleton, CXTPSingleton, CXTPSingleton, CXTPSingleton, CXTPSingleton, CXTPSingleton > >; private: DECLARE_HANDLE(HWINEVENTHOOK); typedef void(CALLBACK* WINEVENTPROC)(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD idEventThread, DWORD dwmsEventTime); typedef HWINEVENTHOOK(WINAPI* LPFNSETWINEVENTHOOK)(UINT eventMin, UINT eventMax, HMODULE hmodWinEventProc, WINEVENTPROC lpfnWinEventProc, DWORD idProcess, DWORD idThread, UINT dwflags); typedef BOOL(WINAPI* LPFNUNHOOKWINEVENT)(HWINEVENTHOOK hWinEventHook); typedef HRESULT(WINAPI* LPSETWINDOWTHEME)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList); protected: /** * @brief * Constructs a CXTPSkinManager object. */ CXTPSkinManager(); public: /** * @brief * Destroys a CXTPSkinManager object, handles cleanup and deallocation. */ virtual ~CXTPSkinManager(); /** * @brief * Loads a skin from a cjstyles or msstyles file. * @param lpszResourcePath Path to the skin file. * @param lpszIniFileName .ini file of the skin to load. * @return * TRUE if successful, otherwise FALSE. */ BOOL LoadSkin(LPCTSTR lpszResourcePath, LPCTSTR lpszIniFileName = NULL); /** * @brief * Creates a new schema instance from a provided resource. * @param lpszResourcePath Path to the styles file to load the schema from. * @param lpszIniFileName Optional embedded .ini file name to use from the styles file. * @return * A pointer to the newly created schema, otherwise NULL in the case of an error. */ CXTPSkinManagerSchema* CreateSchema(LPCTSTR lpszResourcePath, LPCTSTR lpszIniFileName = NULL); public: /** * @brief * Determines which parts of the application skin are applied. * @return * One or more XTPSkinApplyOptions values. * @see * XTPSkinApplyOptions, SetApplyOptions, ModifyApplyOptions */ DWORD GetApplyOptions() const; /** * @brief * Determines which parts of the application skin are applied. * @param dwOptions A set of XTPSkinApplyOptions bits to check * @return * TRUE if all options specified by dwOptions are set. * @see * XTPSkinApplyOptions, SetApplyOptions */ BOOL HasApplyOptions(DWORD dwOptions) const; /** * @brief * Specifies which parts of the application skin should be applied. * @param dwOptions A set of XTPSkinApplyOptions bits to set * @see * XTPSkinApplyOptions, GetApplyOptions */ void SetApplyOptions(DWORD dwOptions); /** * @brief * Modifies skinning options defined by the XTPSkinApplyOptions enumeration. * @param dwAdd Skinning options flags to be added to the current flags. * @param dwRemove Skinning options flags to be removed from the current flags. * @see * XTPSkinApplyOptions, GetApplyOptions, SetApplyOptions, HasApplyOptions */ void ModifyApplyOptions(DWORD dwAdd, DWORD dwRemove); /** * @brief * Call this method to manually set the window whose appearance must be skinned. * @param hWnd Handle of the window whose appearance must be skinned. */ void ApplyWindow(HWND hWnd); /** * @brief * Call this method to manually set the window whose appearance must be skinned. * @param hWnd Handle of the window whose appearance must be skinned. * @param bApplyChildren TRUE to skin all child windows of the specified window * recursively, FALSE to only skin the specified window. */ void ApplyWindow(HWND hWnd, BOOL bApplyChildren); /** * @brief * Sets the window theme. * @param hWnd Valid window handle for which a new theme is to be set. * @param pSchema Valid pointer to a schema describing the theme to be set. * @see * CreateSchema */ void SetWindowTheme(HWND hWnd, CXTPSkinManagerSchema* pSchema); /** * @brief * Specifies if new windows should be automatically skinned. * @param bAutoApply TRUE to automatically skin new windows, FALSE otherwise. * @details * The current skin is used if new windows are automatically skinned. */ void SetAutoApplyNewWindows(BOOL bAutoApply); /** * @brief * Determines if new windows are automatically skinned. * @details * The current skin is used if new windows are automatically skinned. * @return * TRUE if new windows are automatically skinned, otherwise FALSE. */ BOOL GetAutoApplyNewWindows() const; /** * @brief * Sets the skin manager. * @param pSkinManager New skin manager to be set. * @param bDelete TRUE to delete the previous skin manager. * @return * If the bDelete parameter is set to TRUE, then a NULL value will be returned. * If the bDelete parameter is set to FALSE, then a pointer to the previous * skin manager will be returned. * * Example: *
CXTPSkinManager::SetSkinManager(new CMySkinManager());
*/ static CXTPSkinManager* AFX_CDECL SetSkinManager(CXTPSkinManager* pSkinManager, BOOL bDelete = TRUE); /** * @brief * Excludes a specified .dll file from API hooking. * @param lpszModule Name of the .dll file to exclude. */ # if defined(XTP_SKINFRAMEWORK_USE_DETOURS_API_HOOK) && !defined(_XTP_ACTIVEX) _XTP_DEPRECATE("The method is disabled for compilation with " "XTP_SKINFRAMEWORK_USE_DETOURS_API_HOOK and " "its empty implementation is added for backward compatibility only. In order to " "you the legacy implementation of API hooking re-compile ToolkitPro with " "XTP_SKINFRAMEWORK_USE_LEGACY_API_HOOK macro defined.") # endif void ExcludeModule(LPCTSTR lpszModule); /** * @brief * Gets a specified skin class by its name. * @param strClassList Name of the skin class. * @param pObject Reference to the skin object to apply the skin. * @return * A pointer to the specified CXTPSkinManagerClass object. */ virtual CXTPSkinManagerClass* GetSkinClass(const CXTPSkinObject* pObject, CString strClassList); /** * @brief * Gets the skin object used to draw a specified window. * @param hWnd Handle of the skinned window. * @return * A pointer to the CXTPSkinObject used to draw the window. */ CXTPSkinObject* Lookup(HWND hWnd); /** * @brief * Gets the skin object used to draw a specified window. * @param hDC Device context of the skinned window. * @return * A pointer to the CXTPSkinObject used to draw the window. */ CXTPSkinObject* Lookup(HDC hDC); /** * @brief * Gets the skin metrics. * @return * A pointer to the CXTPSkinManagerMetrics object containing the skin metrics. */ CXTPSkinManagerMetrics* GetMetrics() const; /** * @brief * Determines if skinning is enabled/disabled. * @return * TRUE if skinning is enabled, FALSE if skinning is disabled. */ BOOL IsEnabled() const; /** * @brief * Suspends skinning for all new created windows and threads. */ void Suspend(); /** * @brief * Resumes skinning for all new created windows and threads. */ void Resume(); /** * @brief * Determines if skinning is suspended for all new windows and threads. * @return * TRUE if skinning is suspended, FALSE otherwise. */ BOOL IsSuspended() const; /** * @brief * Gets the skin schema. * @return * A pointer to the CXTPSkinManagerSchema object used to draw window parts. */ CXTPSkinManagerSchema* GetSchema() const; /** * @brief * Gets the resource file. * @return * A pointer to the CXTPSkinManagerResouceFile used to manage skin resources. * @see * SetResourceFile */ CXTPSkinManagerResourceFile* GetResourceFile() const; /** * @brief * Sets the resource file. * @param pResourceFile Pointer to a CXTPSkinManagerResouceFile object. * @see * GetResourceFile * * Example: *
XTPSkinManager()->SetResourceFile(new CMySkinManagerResourceFile);
*/ void SetResourceFile(CXTPSkinManagerResourceFile* pResourceFile); /** * @brief * Enables/disables dialog background theme. * @param hWnd Window handle of the target dialog. * @param dwFlags One of the following: * ETDT_ENABLE: Enables theme-defined dialog background texturing. * ETDT_DISABLE: Disables background texturing. * ETDT_ENABLETAB: Enables theme-defined background texturing * using the tab texture. * @details * This method can be used to tailor dialog compatibility with child windows * and controls that may or may not coordinate the rendering of their * client area backgrounds with that of their parent dialog in a manner that * supports seamless background texturing. * @return * S_OK if successful. */ HRESULT EnableThemeDialogTexture(HWND hWnd, DWORD dwFlags); /** * @brief * Gets the value of a specified system color. * @param iColorId System color index (defined in winuser.h). * @return * The value of the specified system color. */ COLORREF GetThemeSysColor(int iColorId); /** * @brief * Gets the value of a specified system font. * @param iFontId TMT_XXX font number (first font is TMT_CAPTIONFONT). * @param plf Pointer to a LOGFONT to receive the value of the specified * system font (scaled for the current logical screen dpi). * @return * S_OK if successful. */ HRESULT GetThemeSysFont(int iFontId, LOGFONT* plf); /** * @brief * Gets the size value of a specified system metric. * @param iSizeId TMT_XXX size value. * @return * The size value of the specified system metric * (scaled for the current logical screen dpi). */ int GetThemeSysSize(int iSizeId); /** * @brief * Gets the BOOL value of a specified system metric. * @param iBoolId TMT_XXX BOOL number (first BOOL is TMT_FLATMENUS). * @return * The BOOL value of the specified system metric. */ BOOL GetThemeSysBool(int iBoolId); /** * @brief * Gets the name of the current theme. * @param strThemeFileName Reference to a string to receive the * theme path and file name. * @param strColorBuff Reference to a string to receive the * canonical color scheme name. */ void GetCurrentThemeName(CString& strThemeFileName, CString& strColorBuff); /** * @brief * Gets the CXTPSkinManagerClass class from a specified HTHEME handle. * @param hTheme HTHEME handle. * @return * A pointer to the CXTPSkinManagerClass class. */ CXTPSkinManagerClass* FromHandle(HTHEME hTheme); /** * @brief * Determines if ComCtl32.dll is of version 6.0 or above. * @return * TRUE if ComCtl32.dll is of version 6.0 or above. * @see * IsWin9x */ BOOL IsComCtlV6() const; /** * @brief * Determines if the operating system is of the Windows 9x family * and if it is Windows 95 or a later version. * @return * TRUE if the operating system is of the Windows 9x family * and if it is Windows 95 or a later version, otherwise FALSE. * @see * IsComCtlV6 */ BOOL IsWin9x() const; /** * @brief * Redraws all controls with the current skin. */ void RedrawAllControls(); /** * @brief * Enables skin framework for the current thread. * @details * This method can be called for each thread in a multi-threaded application * to enable skin framework for all threads. */ void EnableCurrentThread(); /** * @brief * Specifies if new threads should be automatically skinned. * @param bAutoApply TRUE to automatically skin new threads, otherwise FALSE. */ void SetAutoApplyNewThreads(BOOL bAutoApply); /** * @brief * Determines if new threads are automatically skinned. * @return * TRUE if new threads are automatically skinned, otherwise FALSE. */ BOOL GetAutoApplyNewThreads() const; /** * @brief * Gets the class map object whose purpose is to map * window classes to skin framework classes. * @return * A pointer to the class map object. */ CXTPSkinObjectClassMap* GetClassMap() const; /** * @brief * Removes the hook from a specified window. * @param hWnd Handle of the window. * @see * RemoveAll */ void Remove(HWND hWnd); /** * @brief * Removes all hooks. * @param bDetach TRUE to detach hooks before they are removed. * @see * Remove */ void RemoveAll(BOOL bDetach = TRUE); /** * @brief * Determines if any color filter is installed. * @return * TRUE if any color filter is installed, otherwise FALSE. */ BOOL IsColorFilterExists() const; /** * @brief * This method is called internally to transform a specified color * using installed color filters. * @param clr Reference to the color to transform. */ void ApplyColorFilter(COLORREF& clr); /** * @brief * Adds a color filter. * @param pFilter Pointer to the color filter to add. */ void AddColorFilter(CXTPSkinManagerColorFilter* pFilter); /** * @brief * Destroys all added color filters. */ void RemoveColorFilters(); /** * @brief * This method is called when the skin is changed. * @param bPrevState TRUE if the previous skin was installed. * @param bNewState TRUE if the current skin is installed. */ virtual void OnSkinChanged(BOOL bPrevState, BOOL bNewState); /** * @brief * Determines if a specified module is persistent. * @param hModule Handle of the module to check. * @details * A module is persistent if it will remain loaded into the process address * space for the entire lifetime of the skin manager and cannot be unloaded. * The current and/or executable modules are always considered persistent. * @return * TRUE if the specified module is persistent, otherwise FALSE. */ BOOL IsPersistentModule(HMODULE hModule); /** * @brief * Sets the window filter implementation. * @param pFilter Pointer to the window filter implementation, or NULL to * disable any previously set window filter implementation. * @see * IXTPSkinManagerWindowFilter */ void SetWindowFilter(IXTPSkinManagerWindowFilter* pFilter); /** @cond */ CXTPSkinManagerApiHookBase* GetApiHook() const; /** @endcond */ //------------------------------------------------------------------------- // Summary: // Causes a window to use a different set of visual style information than its class // normally uses. // Parameters: // pszSubAppName - Pointer to a string that contains the application name to use in place of // the calling application's name. If this parameter is NULL, the calling // application's name is used. // pszSubIdList - Pointer to a string that contains a semicolon-separated list of CLSID // names to use in place of the actual list passed by the window's class. // If this parameter is NULL, the ID list from the calling class is used. //------------------------------------------------------------------------- void SetDefaultWindowTheme(LPCWSTR pszSubAppName, LPCWSTR pszSubIdList); //------------------------------------------------------------------------- // Summary: // Causes a window to use a different set of visual style information than its class // normally uses. // Parameters: // hWnd - Handle to the window whose visual style information is to be changed. // pszSubAppName - Pointer to a string that contains the application name to use in place of // the calling application's name. If this parameter is NULL, the calling // application's name is used. // pszSubIdList - Pointer to a string that contains a semicolon-separated list of CLSID // names to use in place of the actual list passed by the window's class. // If this parameter is NULL, the ID list from the calling class is used. //------------------------------------------------------------------------- void SetWindowTheme(HWND hWnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList); protected: /** * @brief * Parses a visual styles .ini file. * @param lpszResourcePath Path to the resource file. * @param lpszIniFileName .ini file name. * @return * TRUE if successful, otherwise FALSE. * @see * FreeSkinData */ BOOL ReadSkinData(LPCTSTR lpszResourcePath, LPCTSTR lpszIniFileName); /** * @brief * Frees skin resources. * @see * ReadSkinData */ void FreeSkinData(); /** * @brief * Creates a hook class for a specified window. * @param hWnd Handle to the window to hook. * @param lpszClassName Class name of the specified window. * @param lpcs Pointer to a CREATESTRUCT structure containing * information about the CWnd object being created. * @param bAuto TRUE if the window was automatically skinned when it * was created, FALSE if the window was manually skinned. * @return * A pointer to the CXTPSkinObject hooked to the specified window. * @see * CXTPSkinObject */ virtual CXTPSkinObject* SetHook(HWND hWnd, LPCTSTR lpszClassName, LPCREATESTRUCT lpcs, BOOL bAuto); /** * @brief * This method is called by the framework before an application shuts down. * @param pApplication Pointer to the application that will be shut down. */ virtual void OnBeforeApplicationShutdown(CXTPApplication* pApplication); public: /** @cond */ BOOL IsWindowClassFilteredOut(LPCSTR lpszClassName); BOOL IsWindowClassFilteredOut(LPCWSTR lpszClassName); BOOL IsWindowFilteredOut(HWND hWnd, LPCTSTR lpszClassName, LPCREATESTRUCT lpcs, BOOL bRecursive); BOOL IsDCFilteredOut(HDC hDC, BOOL bRecursive); BOOL IsDCSkinned(HDC hDC); /** @endcond */ protected: /** @cond */ static BOOL AFX_CDECL IsClassKnownIgnoredClass(LPCTSTR lpszClassName); static LRESULT CALLBACK HookWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK CbtFilterHook(int code, WPARAM wParam, LPARAM lParam); static void CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hWnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime); static LRESULT CALLBACK DoCallWindowProc(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); static BOOL CALLBACK EnumWindowsProcNetBroadcast(HWND hwnd, LPARAM lParam); static BOOL AFX_CDECL AreAppVisualThemesDisabled(); void Remove(HWND hWnd, BOOL bAuto); /** @endcond */ private: enum LookupDCSatus { LookupDCOk, LookupDCNotAssociated, LookupDCNoWnd }; CXTPSkinObject* Lookup(HDC hDC, LookupDCSatus* pnStatus); static HWND GetDCWindow(HDC hDC); protected: DWORD m_dwComCtrl; /**< Version of ComCtl.dll. */ const BOOL m_bAppVisualThemesDisabled; BOOL m_bWin9x; /**< TRUE if OS is Win9x. */ BOOL m_bEnabled; /**< TRIE if skinning is enabled. */ BOOL m_bAutoApplyWindows; /**< TRUE to auto-skin all new windows. */ BOOL m_bAutoApplyThreads; /**< TRUE to auto-skin all new threads. */ CXTPSkinManagerSchema* m_pSchema; /**< Current schema. */ CXTPSkinManagerResourceFile* m_pResourceFile; /**< Resource file. */ DWORD m_dwApplyOptions; /**< Apply options. */ HWINEVENTHOOK m_hWinEventHook; /**< HWINEVENTHOOK value that identifies event hook instance. */ CMap m_mapObjects; /**< Collection of CXTPSkinObject classes. */ CRITICAL_SECTION m_csObjects; /**< Helper critical section object. */ LPFNSETWINEVENTHOOK m_pSetWinEventHook; /**< Pointer to SetWinEventHook API. */ LPFNUNHOOKWINEVENT m_pUnhookWinEvent; /**< Pointer to UnhookWinEvent API. */ LPSETWINDOWTHEME m_pSetWindowTheme; /**< Pointer to SetWindowTheme API. */ CArray m_arrFilters; /**< Array of filters to apply. */ CXTPSkinObjectClassMap* m_pClassMap; /**< Class map helper. */ IXTPSkinManagerWindowFilter* m_pWindowFilter; /**< Custom provided window filter implementation. */ mutable CXTPSkinManagerApiHookBase* m_pApiHook; // API hook instance. static CXTPSkinManager* s_pInstance; // Instance of SkinManager. CXTPRWCriticalSection m_csPersistentModuleCache; // Synchronization primitive for persistent // module info cache access. struct PERSISTENT_IMPORT_INFO { HMODULE hModule; BOOL bPersistent; }; CArray m_arPersistentModuleCache; /**< Persistent module info cache. */ public: /** @cond */ AFX_MODULE_STATE* m_pModuleState; # ifdef _XTP_ACTIVEX static BOOL s_bUserLegacyApiHook; # endif /** @endcond */ /** @cond */ private: DWORD m_dwRefDisableFrameSkin; DWORD m_dwPrevOptions; union SUSPENDED_STATE { BYTE bits; struct { BYTE bSuspended : 1; BYTE bAutoApplyWindows : 1; BYTE bAutoApplyThreads : 1; BYTE bApplyDCs : 1; } u; }; SUSPENDED_STATE m_SuspendedState; public: BOOL IsSkinApplyCommandBarsFrame(); void DisableSkinFrameOption(); void EnableSkinFrameOption(); /** @endcond */ private: class CDestructor; friend _XTP_EXT_CLASS CXTPSkinManager* AFX_CDECL XTPSkinManager(); friend class CXTPSkinObject; friend class CDestructor; friend class CXTPSkinManagerApiHookBase; }; AFX_INLINE CXTPSkinImages* CXTPSkinManagerClass::GetImages() const { return m_pImages; } AFX_INLINE int CXTPSkinManagerClass::GetClassCode() const { return static_cast(m_nClassCode); } AFX_INLINE CString CXTPSkinManagerClass::GetClassName() const { return m_strClass; } AFX_INLINE BOOL CXTPSkinManager::IsEnabled() const { return m_bEnabled; } AFX_INLINE BOOL CXTPSkinManager::IsSuspended() const { return (TRUE == m_SuspendedState.u.bSuspended); } AFX_INLINE CXTPSkinManagerResourceFile* CXTPSkinManager::GetResourceFile() const { return m_pResourceFile; } AFX_INLINE CXTPSkinManagerSchema* CXTPSkinManager::GetSchema() const { return m_pSchema; } AFX_INLINE DWORD CXTPSkinManager::GetApplyOptions() const { return m_dwApplyOptions; } AFX_INLINE BOOL CXTPSkinManager::HasApplyOptions(DWORD dwOptions) const { return (m_dwApplyOptions & dwOptions) == dwOptions; } AFX_INLINE BOOL CXTPSkinManager::IsComCtlV6() const { return m_dwComCtrl >= MAKELONG(0, 6); } AFX_INLINE BOOL CXTPSkinManager::IsWin9x() const { return m_bWin9x; } AFX_INLINE CXTPSkinObjectClassMap* CXTPSkinManager::GetClassMap() const { return m_pClassMap; } AFX_INLINE BOOL CXTPSkinManager::GetAutoApplyNewWindows() const { return m_bAutoApplyWindows; } AFX_INLINE BOOL CXTPSkinManager::GetAutoApplyNewThreads() const { return m_bAutoApplyThreads; } AFX_INLINE void CXTPSkinManager::SetAutoApplyNewWindows(BOOL bAutoApply) { m_bAutoApplyWindows = bAutoApply; } AFX_INLINE void CXTPSkinManager::SetAutoApplyNewThreads(BOOL bAutoApply) { m_bAutoApplyThreads = bAutoApply; } AFX_INLINE void CXTPSkinManager::SetWindowFilter(IXTPSkinManagerWindowFilter* pFilter) { m_pWindowFilter = pFilter; } # ifndef _XTP_ACTIVEX /** @cond */ AFX_INLINE CXTPSkinManagerApiHookBase* CXTPSkinManager::GetApiHook() const { return m_pApiHook; } /** @endcond */ # endif /** * @brief * Call this function to access CXTPSkinManager members. * Since this class is designed as a single instance object, you can * only access version info through this method. You cannot * directly instantiate an object of type CXTPSkinManager. * * Example: *
 * XTPSkinManager()->SetApplyOptions(xtpSkinApplyMetrics | xtpSkinApplyFrame | xtpSkinApplyColors);
 * 
* @return A global skin manager object pointer. */ _XTP_EXT_CLASS CXTPSkinManager* AFX_CDECL XTPSkinManager(); /** @cond */ _XTP_EXT_CLASS CXTPRWCriticalSection* AFX_CDECL XTPSkinGlobalAccess(); # ifdef _AFXDLL class _XTP_EXT_CLASS CXTPSkinScopeModuleStateHolder { AFX_MODULE_STATE* m_pPrevState; CXTPSkinScopeModuleStateHolder(const CXTPSkinScopeModuleStateHolder&); CXTPSkinScopeModuleStateHolder& operator=(const CXTPSkinScopeModuleStateHolder&); public: CXTPSkinScopeModuleStateHolder(AFX_MODULE_STATE* pNewState) { m_pPrevState = AfxSetModuleState(pNewState); } ~CXTPSkinScopeModuleStateHolder() { AfxSetModuleState(m_pPrevState); } operator int() { return 0; } }; # endif /*_AFXDLL*/ # define XTP_SKINFRAMEWORK_GLOBALLOCK_SHARED_SCOPE() \ XTP_RWCS_LOCK_SHARED_SCOPE(*XTPSkinGlobalAccess()) # define XTP_SKINFRAMEWORK_GLOBALLOCK_EXCLUSIVE_SCOPE() \ XTP_RWCS_LOCK_EXCLUSIVE_SCOPE(*XTPSkinGlobalAccess()) # define XTP_SKINFRAMEWORK_MANAGE_STATE() \ AFX_MODULE_STATE* $__xtpSkinOrigModuleState = AfxGetModuleState(); \ UNREFERENCED_PARAMETER($__xtpSkinOrigModuleState); \ SAFE_MANAGE_STATE(XTPSkinManager()->m_pModuleState); # ifdef _AFXDLL # define XTP_SKINFRAMEWORK_ORIGINAL_STATE() \ XTP_BLOCKSTATEMENT(CXTPSkinScopeModuleStateHolder, $__xtpSkinScopeModuleStateHolder, \ $__xtpSkinOrigModuleState) # else # define XTP_SKINFRAMEWORK_ORIGINAL_STATE() # endif /*_AFXDLL*/ # define XTP_SKINFRAMEWORK_ASSERT_WINDOW_THREAD(hWnd) \ _ASSERTE(::IsWindow(hWnd) ? GetWindowThreadProcessId(hWnd, NULL) == GetCurrentThreadId() \ : TRUE) /** @endcond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSKINMANAGER_H__) /** @endcond */