/*
* Copyright (c) 2004, Mathew Hall
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace XPExplorerBar
{
#region UxTheme
/// <summary>
/// Summary description for Theme.
/// </summary>
public class UxTheme
{
/// <summary>
///
/// </summary>
private UxTheme()
{
}
/// <summary>
/// Reports whether the current application's user interface
/// displays using visual styles
/// </summary>
public static bool AppThemed
{
get
{
bool themed = false;
OperatingSystem os = System.Environment.OSVersion;
// check if the OS id XP or higher
// fix: Win2k3 now recognised
// Russkie (codeprj@webcontrol.net.au)
if (os.Platform == PlatformID.Win32NT && ((os.Version.Major == 5 && os.Version.Minor >= 1) || os.Version.Major > 5))
{
themed = IsAppThemed();
}
return themed;
}
}
/// <summary>
/// Retrieves the name of the current visual style
/// </summary>
public static String ThemeName
{
get
{
StringBuilder themeName = new StringBuilder(256);
GetCurrentThemeName(themeName, 256, null, 0, null, 0);
return themeName.ToString();
}
}
/// <summary>
/// Retrieves the color scheme name of the current visual style
/// </summary>
public static String ColorName
{
get
{
StringBuilder themeName = new StringBuilder(256);
StringBuilder colorName = new StringBuilder(256);
GetCurrentThemeName(themeName, 256, colorName, 256, null, 0);
return colorName.ToString();
}
}
#region Win32 Methods
/// <summary>
/// Opens the theme data for a window and its associated class
/// </summary>
/// <param name="hwnd">Handle of the window for which theme data
/// is required</param>
/// <param name="pszClassList">Pointer to a string that contains
/// a semicolon-separated list of classes</param>
/// <returns>OpenThemeData tries to match each class, one at a
/// time, to a class data section in the active theme. If a match
/// is found, an associated HTHEME handle is returned. If no match
/// is found NULL is returned</returns>
[DllImport("UxTheme.dll")]
public static extern IntPtr OpenThemeData(IntPtr hwnd, [MarshalAs(UnmanagedType.LPTStr)] string pszClassList);
/// <summary>
/// Closes the theme data handle
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int CloseThemeData(IntPtr hTheme);
/// <summary>
/// Draws the background image defined by the visual style for the
/// specified control part
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) used for
/// drawing the theme-defined background image</param>
/// <param name="iPartId">Value of type int that specifies the part
/// to draw</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part to draw</param>
/// <param name="pRect">Pointer to a RECT structure that contains the
/// rectangle, in logical coordinates, in which the background image
/// is drawn</param>
/// <param name="pClipRect">Pointer to a RECT structure that contains
/// a clipping rectangle. This parameter may be set to NULL</param>
/// <returns></returns>
[DllImport("UxTheme.dll")]
public static extern int DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, ref RECT pClipRect);
/// <summary>
/// Draws text using the color and font defined by the visual style
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) to use for
/// drawing</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the text</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="pszText">Pointer to a string that contains the text
/// to draw</param>
/// <param name="iCharCount">Value of type int that contains the number
/// of characters to draw. If the parameter is set to -1, all the
/// characters in the string are drawn</param>
/// <param name="dwTextFlags">DWORD that contains one or more values
/// that specify the string's formatting</param>
/// <param name="dwTextFlags2">Draws a grayed-out string. This flag
/// may be set to NULL. The value for this flag is DTT_GRAYED</param>
/// <param name="pRect">Pointer to a RECT structure that contains the
/// rectangle, in logical coordinates, in which the text is to be drawn</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int DrawThemeText(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, [MarshalAs(UnmanagedType.LPTStr)] string pszText, int iCharCount, int dwTextFlags, int dwTextFlags2, ref RECT pRect);
/// <summary>
/// Retrieves the size of the content area for the background
/// defined by the visual style
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) to use when
/// drawing. This parameter may be set to NULL</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the content area</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part that contains the content area</param>
/// <param name="pBoundingRect">Pointer to a RECT structure that
/// contains the total background rectangle, in logical coordinates.
/// This is the area inside the borders or margins</param>
/// <param name="pContentRect">Pointer to a RECT structure that receives
/// the content area background rectangle, in logical coordinates. This
/// rectangle is calculated to fit the content area</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeBackgroundContentRect(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pBoundingRect, ref RECT pContentRect);
/// <summary>
/// Calculates the size and location of the background, defined
/// by the visual style, given the content area
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) to use when
/// drawing. This parameter may be set to NULL</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the content</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part that contains the content</param>
/// <param name="pContentRect">Pointer to a RECT structure that
/// contains the content background rectangle, in logical coordinates.
/// This rectangle is returned from GetThemeBackgroundContentRect</param>
/// <param name="pExtentRect">Pointer to a RECT structure that
/// receives the background rectangle, in logical coordinates. This
/// rectangle is based on the pContentRect</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeBackgroundExtent(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pContentRect, ref RECT pExtentRect);
/// <summary>
/// Calculates the original size of the part defined by a
/// visual style
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme
/// data. Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) to
/// select fonts into</param>
/// <param name="iPartId">Value of type int that specifies
/// the part to calculate the size of</param>
/// <param name="iStateId">Value of type int that specifies
/// the state of the part</param>
/// <param name="prc">Pointer to a RECT structure that
/// contains the rectangle used for the part drawing destination.
/// This parameter may be set to NULL</param>
/// <param name="eSize">Enumerated type that specifies the type
/// of size to retrieve. See THEME_SIZE for a list of type values</param>
/// <param name="psz">Pointer to a SIZE structure that receives
/// the dimensions of the specified part</param>
/// <returns>Returns S_OK if successful, or an error value
/// otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemePartSize(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT prc, THEMESIZE eSize, ref SIZE psz);
/// <summary>
/// Calculates the size and location of the specified text
/// when rendered in the visual style font
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme
/// data. Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) to
/// select the font into</param>
/// <param name="iPartId">Value of type int that specifies
/// the part in which the text will be drawn</param>
/// <param name="iStateId">Value of type int that specifies
/// the state of the part</param>
/// <param name="pszText">Pointer to a string that contains
/// the text to draw</param>
/// <param name="iCharCount">Value of typeint that contains
/// the number of characters to draw. If the parameter is set
/// to -1, all the characters in the string are drawn</param>
/// <param name="dwTextFlags">DWORD that contains one or more
/// values that specify the string's formatting</param>
/// <param name="pBoundingRect">Pointer to a RECT structure
/// that contains the rectangle used to control layout of the
/// text. This parameter may be set to NULL</param>
/// <param name="pExtentRect">Pointer to a RECT structure that
/// contains, in logical coordinates, the rectangle required
/// to fit the rendered text</param>
/// <returns>Returns S_OK if successful, or an error value
/// otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeTextExtent(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, [MarshalAs(UnmanagedType.LPTStr)] string pszText, int iCharCount, int dwTextFlags, ref RECT pBoundingRect, ref RECT pExtentRect);
/// <summary>
/// Retrieves information about the font specified by a visual
/// style for a particular part
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme
/// data. Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) to use
/// for screen context. This parameter may be set to NULL</param>
/// <param name="iPartId">Value of type int that specifies the
/// part to retrieve font information about</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <param name="ptm">Pointer to a TEXTMETRIC structure that
/// receives the font information</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeTextMetrics(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref TEXTMETRIC ptm);
/// <summary>
/// Computes the region for a regular or partially transparent
/// background that is bounded by a specified rectangle
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme
/// data. Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) to draw
/// into. The device context (DC) uses dots per inch (DPI) scaling.
/// This parameter may be set to NULL</param>
/// <param name="iPartId">Value of type int that specifies the
/// part that contains the region</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <param name="pRect">Pointer to a RECT structure that contains,
/// in logical coordinates, the specified rectangle used to
/// compute the region</param>
/// <param name="pRegion">Pointer to the handle to the computed
/// region</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeBackgroundRegion(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, IntPtr pRegion);
/// <summary>
/// Retrieves a hit test code for a point in the background
/// specified by a visual style
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme
/// data. Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) to use
/// when drawing. This parameter may be set to NULL</param>
/// <param name="iPartId">Value of type int that specifies the
/// part</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <param name="dwOptions">DWORD that specifies the hit test
/// options</param>
/// <param name="pRect">Pointer to a RECT structure that contains,
/// in logical coordinates, the rectangle that bounds the background</param>
/// <param name="hrgn">Handle to a region that can be used to
/// specify the bounds of a hit test area. This parameter may be
/// set to NULL</param>
/// <param name="ptTest">POINT structure that contains the coordinates
/// of the point</param>
/// <param name="pwHitTestCode">WORD that receives the hit test
/// code that indicates whether the point in ptTest is in the
/// background area bounded by pRect or hrgn</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int HitTestThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int dwOptions, ref RECT pRect, IntPtr hrgn, POINT ptTest, out int pwHitTestCode);
/// <summary>
/// Draws one or more edges defined by the visual style of a rectangle
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC)</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the rectangle</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="pDestRect">Pointer to a RECT structure that contains,
/// in logical coordinates, the rectangle</param>
/// <param name="uEdge">UINT that specifies the type of inner and outer
/// edges to draw. This parameter must be a combination of one inner-border
/// flag and one outer-border flag, or one of the combination flags</param>
/// <param name="uFlags">UINT that specifies the type of border to draw</param>
/// <param name="pContentRect">Pointer to a RECT structure that contains,
/// in logical coordinates, the rectangle that receives the interior
/// rectangle, if uFlags is set to BF_ADJUST. This parameter may be set
/// to NULL</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int DrawThemeEdge(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pDestRect, int uEdge, int uFlags, ref RECT pContentRect);
/// <summary>
/// Draws an image from an image list with the icon effect defined
/// by the visual style
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC)</param>
/// <param name="iPartId">Value of type int that specifies the part
/// in which the image is drawn</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="pRect">Pointer to a RECT structure that contains, in
/// logical coordinates, the rectangle in which the image is drawn</param>
/// <param name="himl">Handle to an image list that contains the
/// image to draw</param>
/// <param name="iImageIndex">Value of type int that specifies the
/// index of the image to draw</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int DrawThemeIcon(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, IntPtr himl, int iImageIndex);
/// <summary>
/// Retrieves whether a visual style has defined parameters for
/// the specified part and state
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <returns>TRUE if the theme has defined parameters for the s
/// pecified iPartId and iStateId, FALSE otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern bool IsThemePartDefined(IntPtr hTheme, int iPartId, int iStateId);
/// <summary>
/// Retrieves whether the background specified by the visual
/// style has transparent pieces or alpha-blended pieces
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme
/// data. Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the
/// part</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <returns>TRUE if the theme-specified background for a particular
/// iPartId and iStateId has transparent pieces or alpha-blended
/// pieces, FALSE otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern bool IsThemeBackgroundPartiallyTransparent(IntPtr hTheme, int iPartId, int iStateId);
/// <summary>
/// Retrieves the value of a color property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the color property</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <param name="iPropId">Value of type int that specifies the
/// property to retrieve</param>
/// <param name="pColor">Pointer to a COLORREF structure that
/// receives the color value</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeColor(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int pColor);
/// <summary>
/// Retrieves the value of a metric property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme
/// data. Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC). This
/// parameter may be set to NULL</param>
/// <param name="iPartId">Value of type int that specifies the
/// part that contains the metric property</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <param name="iPropId">Value of type int that specifies the
/// property to retrieve</param>
/// <param name="piVal">Pointer to an int that receives the
/// metric property value</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeMetric(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, out int piVal);
/// <summary>
/// Retrieves the value of a string property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part
/// which contains the string property</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <param name="iPropId">Value of type int that specifies the
/// property to retrieve</param>
/// <param name="pszBuff">Pointer to a buffer that receives the
/// string value</param>
/// <param name="cchMaxBuffChars">Value of type int that specifies
/// the maximum number of characters pszBuff can contain</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeString(IntPtr hTheme, int iPartId, int iStateId, int iPropId, [MarshalAs(UnmanagedType.LPTStr)] string pszBuff, int cchMaxBuffChars);
/// <summary>
/// Retrieves the value of a BOOL property from the SysMetrics
/// section of theme data
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part
/// which contains the BOOL property</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <param name="iPropId">Value of type int that specifies the
/// property to retrieve</param>
/// <param name="pfVal">Pointer to a BOOL that receives the retrieved
/// property value</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeBool(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out bool pfVal);
/// <summary>
/// Retrieves the value of an int property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the int property</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part</param>
/// <param name="iPropId">Value of type int that specifies the
/// property to retrieve</param>
/// <param name="piVal">Pointer to an int that receives the
/// retrieved value</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeInt(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int piVal);
/// <summary>
/// Retrieves the value of an enumerated type property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the enumerated type property</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="iPropId">Value of type int that specifies the property
/// to retrieve</param>
/// <param name="piVal">Pointer to an int that receives the enumerated
/// type value</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeEnumValue(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int piVal);
/// <summary>
/// Retrieves the value of a position property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the position property</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="iPropId">Value of type int that specifies the property
/// to retrieve</param>
/// <param name="pPoint">Pointer to a POINT structure that receives
/// the position value</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemePosition(IntPtr hTheme, int iPartId, int iStateId, int iPropId, ref POINT pPoint);
/// <summary>
/// Retrieves the value of a font property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC). This parameter
/// may be set to NULL</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the font property</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="iPropId">Value of type int that specifies the property
/// to retrieve</param>
/// <param name="pFont">Pointer to a LOGFONT structure that receives
/// the font property value</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeFont(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, ref LOGFONT pFont);
/// <summary>
/// Retrieves the value of a RECT property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the RECT property</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="iPropId">Value of type int that specifies the property
/// to retrieve</param>
/// <param name="pRect">Pointer to a RECT structure that receives
/// a rectangle</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeRect(IntPtr hTheme, int iPartId, int iStateId, int iPropId, ref RECT pRect);
/// <summary>
/// Retrieves the value of a MARGINS property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) to select
/// fonts into. This parameter may be set to NULL</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the MARGINS property</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="iPropId">Value of type int that specifies the property
/// to retrieve</param>
/// <param name="prc">Pointer to a RECT structure that contains the
/// rectangle that specifies the area to be drawn into. This parameter
/// may be set to NULL</param>
/// <param name="pMargins">Pointer to a MARGINS structure that receives
/// the retrieved value</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeMargins(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, ref RECT prc, ref MARGINS pMargins);
/// <summary>
/// Retrieves a list of int data from a visual style
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data. Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part that contains the list of data to return</param>
/// <param name="iStateId">Value of type int that specifies the state of the part</param>
/// <param name="iPropId">Value of type int that specifies the property to retrieve</param>
/// <param name="pIntList">Pointer to an INTLIST structure that receives the int data</param>
/// <returns>Returns S_OK if successful, otherwise an error code</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeIntList(IntPtr hTheme, int iPartId, int iStateId, int iPropId, ref INTLIST pIntList);
/// <summary>
/// Retrieves the location of the theme property definition for a property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the theme</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="iPropId">Value of type int that specifies the property
/// to retrieve</param>
/// <param name="pOrigin">Pointer to a PROPERTYORIGIN enumerated type
/// that indicates where the property was or was not found</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemePropertyOrigin(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out PROPERTYORIGIN pOrigin);
/// <summary>
/// Causes a window to use a different set of visual style information
/// than its class normally uses
/// </summary>
/// <param name="hwnd">Handle to the window whose visual style
/// information is to be changed</param>
/// <param name="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</param>
/// <param name="pszSubIdList">Pointer to a string that contains a
/// semicolon-separated list of class identifier (CLSID) names to use
/// in place of the actual list passed by the window's class. If this
/// parameter is NULL, the identifier (ID) list from the calling class
/// is used</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int SetWindowTheme(IntPtr hwnd, [MarshalAs(UnmanagedType.LPTStr)] string pszSubAppName, [MarshalAs(UnmanagedType.LPTStr)] string pszSubIdList);
/// <summary>
/// Retrieves the value of a filename property
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme data.
/// Use OpenThemeData to create an HTHEME</param>
/// <param name="iPartId">Value of type int that specifies the part
/// that contains the filename property</param>
/// <param name="iStateId">Value of type int that specifies the state
/// of the part</param>
/// <param name="iPropId">Value of type int that specifies the property
/// to retrieve</param>
/// <param name="pszThemeFileName">Pointer to a buffer that receives
/// the retrieved file name</param>
/// <param name="cchMaxBuffChars">Value of type int that receives the
/// maximum number of characters in the file name</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeFilename(IntPtr hTheme, int iPartId, int iStateId, int iPropId, [MarshalAs(UnmanagedType.LPTStr)] string pszThemeFileName, int cchMaxBuffChars);
/// <summary>
/// Retrieves the value of a system color
/// </summary>
/// <param name="hTheme">Handle to theme data</param>
/// <param name="iColorId">Value of type int that specifies the color number</param>
/// <returns>The value of the specified system color</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeSysColor(IntPtr hTheme, int iColorId);
/// <summary>
/// Retrieves a system color brush
/// </summary>
/// <param name="hTheme">Handle to theme data</param>
/// <param name="iColorId">Value of type int that specifies the
/// number of the desired system color</param>
/// <returns>Handle to brush data</returns>
[DllImport("UxTheme.dll")]
public static extern IntPtr GetThemeSysColorBrush(IntPtr hTheme, int iColorId);
/// <summary>
/// Retrieves the Boolean value of a system metric such as flat
/// menus, fading tool tips, and so forth
/// </summary>
/// <param name="hTheme">Handle to theme data</param>
/// <param name="iBoolId">Value of type int that specifies the system
/// Boolean metric desired</param>
/// <returns>Value of desired system metric</returns>
[DllImport("UxTheme.dll")]
public static extern bool GetThemeSysBool(IntPtr hTheme, int iBoolId);
/// <summary>
/// Retrieves the value of a system size metric from theme data
/// </summary>
/// <param name="hTheme">Handle to theme data</param>
/// <param name="iSizeId">Value of type int that specifies the system
/// size metric desired</param>
/// <returns>The size in dots per inch (DPI) scaled for the current
/// logical screen</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeSysSize(IntPtr hTheme, int iSizeId);
/// <summary>
/// Retrieves the LOGFONT of a system font
/// </summary>
/// <param name="hTheme">Handle to theme data</param>
/// <param name="iFontId">Value of type int that specifies a system font</param>
/// <param name="plf">Pointer to a LOGFONT structure that receives the
/// font information from this function</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeSysFont(IntPtr hTheme, int iFontId, ref LOGFONT plf);
/// <summary>
/// Retrieves the value of a system string
/// </summary>
/// <param name="hTheme">Handle to theme data</param>
/// <param name="iStringId">Value of type int that specifies a
/// system string</param>
/// <param name="pszStringBuff">Pointer to the buffer that
/// receives the string
/// value from this function</param>
/// <param name="cchMaxStringChars">Value of type int that
/// specifies the maximum
/// number of characters the string buffer can hold</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeSysString(IntPtr hTheme, int iStringId, [MarshalAs(UnmanagedType.LPTStr)] string pszStringBuff, int cchMaxStringChars);
/// <summary>
/// Retrieves the value of a system int
/// </summary>
/// <param name="hTheme">Handle to theme data</param>
/// <param name="iIntId">Value of type int that specifies the
/// desired system int</param>
/// <param name="piValue">Pointer to an int that receives the
/// system integer value</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeSysInt(IntPtr hTheme, int iIntId, out int piValue);
/// <summary>
/// Tests if a visual style for the current application is active
/// </summary>
/// <returns>TRUE if a visual style is enabled, and windows with
/// visual styles applied should call OpenThemeData to start using
/// theme drawing services, FALSE otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern bool IsThemeActive();
/// <summary>
/// Reports whether the current application's user interface
/// displays using visual styles
/// </summary>
/// <returns>TRUE if the application has a visual style applied,
/// FALSE otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern bool IsAppThemed();
/// <summary>
/// Retrieves a theme handle for a window that has visual styles applied
/// </summary>
/// <param name="hwnd">Handle of the window</param>
/// <returns>The most recent theme handle from OpenThemeData</returns>
[DllImport("UxTheme.dll")]
public static extern IntPtr GetWindowTheme(IntPtr hwnd);
/// <summary>
/// Enables or disables the visual style of a dialog window's background
/// </summary>
/// <param name="hwnd">Window handle of the target dialog</param>
/// <param name="dwFlags"></param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int EnableThemeDialogTexture(IntPtr hwnd, int dwFlags);
/// <summary>
/// Retrieves the property flags that control how visual styles
/// are applied in the current application
/// </summary>
/// <returns></returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeAppProperties();
/// <summary>
/// Sets the flags that determine how visual styles are implemented
/// in the calling application
/// </summary>
/// <param name="dwFlags">he flag values to be set</param>
/// <returns></returns>
[DllImport("UxTheme.dll")]
public static extern int SetThemeAppProperties(int dwFlags);
/// <summary>
/// Retrieves the name of the current visual style, and optionally retrieves the
/// color scheme name and size name
/// </summary>
/// <param name="pszThemeFileName">Pointer to a string that receives the theme
/// path and file name</param>
/// <param name="dwMaxNameChars">Value of type int that contains the maximum
/// number of characters allowed in the theme file name</param>
/// <param name="pszColorBuff">Pointer to a string that receives the color scheme
/// name. This parameter may be set to NULL</param>
/// <param name="cchMaxColorChars">Value of type int that contains the maximum
/// number of characters allowed in the color scheme name</param>
/// <param name="pszSizeBuff">Pointer to a string that receives the size name.
/// This parameter may be set to NULL</param>
/// <param name="cchMaxSizeChars">Value of type int that contains the maximum
/// number of characters allowed in the size name</param>
/// <returns>Returns S_OK if successful, otherwise an error code</returns>
[DllImport("UxTheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
protected static extern int GetCurrentThemeName(StringBuilder pszThemeFileName, int dwMaxNameChars, StringBuilder pszColorBuff, int cchMaxColorChars, StringBuilder pszSizeBuff, int cchMaxSizeChars);
/// <summary>
/// Retrieves the value for a theme property from the documentation
/// section of the Themes.ini file
/// </summary>
/// <param name="pszThemeName">Pointer to a string that contains
/// the name of the theme to query</param>
/// <param name="pszPropertyName">Pointer to a string that contains
/// the name of the theme property to query</param>
/// <param name="pszValueBuff">Pointer to a string buffer that
/// receives the property string value</param>
/// <param name="cchMaxValChars">Value of type int that specifies
/// the maximum number of characters that pszValueBuff can contain</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int GetThemeDocumentationProperty([MarshalAs(UnmanagedType.LPTStr)] string pszThemeName, [MarshalAs(UnmanagedType.LPTStr)] string pszPropertyName, [MarshalAs(UnmanagedType.LPTStr)] string pszValueBuff, int cchMaxValChars);
/// <summary>
/// Draws the part of a parent control that is covered by a
/// partially-transparent or alpha-blended child control
/// </summary>
/// <param name="hwnd">Handle of the child control</param>
/// <param name="hdc">Handle to the child control's device context </param>
/// <param name="prc">Pointer to a RECT structure that defines the
/// area to be drawn. The rectangle is in the child window's coordinates.
/// This parameter may be set to NULL</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int DrawThemeParentBackground(IntPtr hwnd, IntPtr hdc, ref RECT prc);
/// <summary>
/// Enables or disables visual styles for the current user in
/// the current and later sessions
/// </summary>
/// <param name="fEnable">Enables or disables visual styles</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int EnableTheming(bool fEnable);
/// <summary>
/// Draws the background image defined by the visual style for
/// the specified control part
/// </summary>
/// <param name="hTheme">Handle to a window's specified theme
/// data. Use OpenThemeData to create an HTHEME</param>
/// <param name="hdc">Handle to a device context (HDC) used for
/// drawing the theme-defined background image</param>
/// <param name="iPartId">Value of type int that specifies the
/// part to draw</param>
/// <param name="iStateId">Value of type int that specifies the
/// state of the part to draw</param>
/// <param name="pRect">Pointer to a RECT structure that contains
/// the rectangle, in logical coordinates, in which the background
/// image is drawn</param>
/// <param name="pOptions">Pointer to a DTBGOPTS structure that
/// contains a clipping rectangle. This parameter may be set to NULL</param>
/// <returns>Returns S_OK if successful, or an error value otherwise</returns>
[DllImport("UxTheme.dll")]
public static extern int DrawThemeBackgroundEx(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, ref DTBGOPTS pOptions);
#endregion
#region WindowClasses
/// <summary>
///
/// </summary>
public class WindowClasses
{
public static readonly string Window = "WINDOW";
public static readonly string Button = "BUTTON";
public static readonly string Rebar = "REBAR";
public static readonly string Toolbar = "TOOLBAR";
public static readonly string Status = "STATUS";
public static readonly string Menu = "MENU";
public static readonly string ListView = "LISTVIEW";
public static readonly string Header = "HEADER";
public static readonly string Progress = "PROGRESS";
public static readonly string Tab = "TAB";
public static readonly string Trackbar = "TRACKBAR";
public static readonly string Tooltip = "TOOLTIP";
public static readonly string TreeView = "TREEVIEW";
public static readonly string Spin = "SPIN";
public static readonly string Page = "PAGE";
public static readonly string Scrollbar = "SCROLLBAR";
public static readonly string Edit = "EDIT";
public static readonly string ComboBox = "COMBOBOX";
}
#endregion
#region Parts
/// <summary>
///
/// </summary>
public class Parts
{
#region Window
public enum Window
{
Caption = 1,
SmallCaption = 2,
MinCaption = 3,
SmallMinCaption = 4,
MaxCaption = 5,
SmallMaxCaption = 6,
FrameLeft = 7,
FrameRight = 8,
FrameBottom = 9,
SmallFrameLeft = 10,
SmallFrameRight = 11,
SmallFrameBottom = 12,
//---- window frame buttons ----
SysButton = 13,
MdiSysButton = 14,
MinButton = 15,
MdiMinButton = 16,
MaxButton = 17,
CloseButton = 18,
SmallCloseButton = 19,
MdiCloseButton = 20,
RestoreButton = 21,
MdiRestoreButton = 22,
WP_HelpButton = 23,
WP_MdiHelpButton = 24,
//---- scrollbars
HorzScroll = 25,
HorzThumb = 26,
VertScroll = 27,
VertThumb = 28,
//---- dialog ----
Dialog = 29,
//---- hit-test templates ---
CaptionSizingTemplate = 30,
SmallCaptionSizingTemplate = 31,
FrameLeftSizingTemplate = 32,
SmallFrameLeftSizingTemplate = 33,
FrameRightSizingTemplate = 34,
SmallFrameRightSizingTemplate = 35,
FrameBottomSizingTemplate = 36,
SmallFrameBottomSizingTemplate = 37
}
#endregion
#region Button
public enum Button
{
PushButton = 1,
RadioButton = 2,
CheckBox = 3,
GroupBox = 4,
UserButton = 5
}
#endregion
#region Rebar
public enum Rebar
{
Gripper = 1,
GripperVert = 2,
Band = 3,
Chevron = 4,
ChevronVert = 5
}
#endregion
#region Toolbar
public enum Toolbar
{
Button = 1,
DropDownButton = 2,
SplitButton = 3,
SplitButtonDropDown = 4,
Separator = 5,
SeparatorVert = 6
}
#endregion
#region Status
public enum Status
{
Pane = 1,
GripperPane = 2,
Gripper = 3
}
#endregion
#region Menu
public enum Menu
{
MenuItem = 1,
MenuDropDown = 2,
MenubarItem = 3,
MenubarDropDown = 4,
Chevron = 5,
Separator = 6
}
#endregion
#region ListView
public enum ListView
{
ListItem = 1,
ListGroup = 2,
ListDetail = 3,
ListSortedDetail = 4,
EmptyText = 5
}
#endregion
#region Header
public enum Header
{
HeaderItem = 1,
HeaderItemLeft = 2,
HeaderItemRight = 3,
HeaderSortArrow = 4
}
#endregion
#region Progress
public enum Progress
{
Bar = 1,
BarVert = 2,
Chunk = 3,
ChunkVert = 4
}
#endregion
#region Tab
public enum Tab
{
TabItem = 1,
TabItemLeftEdge = 2,
TabItemRightEdge = 3,
TabItemBothEdge = 4,
TopTabItem = 5,
TopTabItemLeftEdge = 6,
TopTabItemRightEdge = 7,
TopTabItemBothEdge = 8,
Pane = 9,
Body = 10
}
#endregion
#region Trackbar
public enum Trackbar
{
Track = 1,
TrackVert = 2,
Thumb = 3,
ThumbBottom = 4,
ThumbTop = 5,
ThumbVert = 6,
ThumbLeft = 7,
ThumbRight =8,
Tics = 9,
TicsVert = 10
}
#endregion
#region Tooltip
public enum Tooltip
{
Standard = 1,
StandardTitle = 2,
Balloon = 3,
BalloonTitle = 4,
Close = 5
}
#endregion
#region TreeView
public enum TreeView
{
TreeItem = 1,
Glyph = 2,
Branch = 3
}
#endregion
#region Spin
public enum Spin
{
Up = 1,
Down = 2,
UpHorz = 3,
DownHorz = 4
}
#endregion
#region Page
public enum Page
{
Up = 1,
Down = 2,
UpHorz = 3,
DownHorz = 4
}
#endregion
#region Scrollbar
public enum Scrollbar
{
ArrowBtn = 1,
ThumbBtnHorz = 2,
ThumbBtnVert = 3,
LowerTrackHorz = 4,
UpperTrackHorz = 5,
LowerTrackVert = 6,
UpperTrackVert = 7,
GripperHorz = 8,
GripperVert = 9,
SizeBox = 10
}
#endregion
#region Edit
public enum Edit
{
EditText = 1,
Caret = 2
}
#endregion
#region ComboBox
public enum ComboBox
{
DropDownButton = 1
}
#endregion
}
#endregion
#region PartStates
public class PartStates
{
#region WindowParts
public enum WindowFrame
{
Active = 1,
Inactive = 2
}
public enum WindowCaption
{
Active = 1,
Inactive = 2,
Disabled = 3
}
public enum WindowMaxCaption
{
Active = 1,
Inactive = 2,
Disabled = 3
}
public enum WindowMinCaptionPart
{
Active = 1,
Inactive = 2,
Disabled = 3
}
public enum WindowHorzSrcoll
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
public enum WindowHorzThumb
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
public enum WindowVertSrcoll
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
public enum WindowVertThumb
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
public enum WindowSysButton
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
public enum WindowMinButton
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
public enum WindowMaxButton
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
public enum WindowRestoreButton
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
public enum WindowHelpButton
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
public enum WindowCloseButton
{
Normal = 1,
Hot = 2,
Pushed = 3,
Disabled = 4
}
#endregion
#region ButtonParts
public enum PushButton
{
Normal = 1,
Hot = 2,
Pressed = 3,
Disabled = 4,
Defaulted = 5
}
public enum RadioButton
{
UncheckedNormal = 1,
UncheckedHot = 2,
UncheckedPressed = 3,
UncheckedDisabled = 4,
CheckedNormal = 5,
CheckedHot = 6,
CheckedPressed = 7,
CheckedDisabled = 8
}
public enum CheckBox
{
UncheckedNormal = 1,
UncheckedHot = 2,
UncheckedPressed = 3,
UncheckedDisabled = 4,
CheckedNormal = 5,
CheckedHot = 6,
CheckedPressed = 7,
CheckedDisabled = 8,
MixedNormal = 9,
MixedHot = 10,
MixedPressed = 11,
MixedDisabled = 12
}
public enum GroupBox
{
Normal = 1,
Disabled = 2
}
#endregion
#region RebarParts
public enum Rebar
{
Normal = 1,
Hot = 2,
Pressed = 3
}
#endregion
#region ToolbarParts
public enum Toolbar
{
Normal = 1,
Hot = 2,
Pressed = 3,
Disabled = 4,
Checked = 5,
Unchecked = 6
}
#endregion
#region MenuParts
public enum Menu
{
Normal = 1,
Selected = 2,
Demoted = 3
}
#endregion
#region ListItemParts
public enum ListItem
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
SelectedNotFocused = 5
}
#endregion
#region HeaderParts
public enum HeaderItem
{
Normal = 1,
Hot = 2,
Pressed = 3
}
public enum HeaderItemLeft
{
Normal = 1,
Hot = 2,
Pressed = 3
}
public enum HeaderItemRight
{
Normal = 1,
Hot = 2,
Pressed = 3
}
public enum HeaderSortArrow
{
SortedUp = 1,
SortedDown = 2
}
#endregion
#region TabParts
public enum TabItemPart
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
Focused = 5
}
public enum TabItemLeftEdge
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
Focused = 5
}
public enum TabItemRightEdge
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
Focused = 5
}
public enum TabItemBothEdges
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
Focused = 5
}
public enum TopTabItem
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
Focused = 5
}
public enum TopTabItemLeftEdge
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
Focused = 5
}
public enum TopTabItemRightEdge
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
Focused = 5
}
public enum TopTabItemBothEdges
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
Focused = 5
}
#endregion
#region TrackbarParts
public enum Trackbar
{
Normal = 1
}
public enum Track
{
Normal = 1
}
public enum TrackVert
{
Normal = 1
}
public enum TrackThumb
{
Normal = 1,
Hot = 2,
Pressed = 3,
Focused = 4,
Disabled = 5
}
public enum TrackThumbBottom
{
Normal = 1,
Hot = 2,
Pressed = 3,
Focused = 4,
Disabled = 5
}
public enum TrackThumbVert
{
Normal = 1,
Hot = 2,
Pressed = 3,
Focused = 4,
Disabled = 5
}
public enum TrackThumbLeft
{
Normal = 1,
Hot = 2,
Pressed = 3,
Focused = 4,
Disabled = 5
}
public enum TrackThumbRight
{
Normal = 1,
Hot = 2,
Pressed = 3,
Focused = 4,
Disabled = 5
}
public enum TrackTics
{
Normal = 1
}
public enum TrackTicsVert
{
Normal = 1
}
#endregion
#region TooltipParts
public enum TooltipClose
{
Normal = 1,
Hot = 2,
Pressed = 3
}
public enum TooltipStandard
{
Normal = 1,
Link = 2
}
public enum TooltipBalloon
{
Normal = 1,
Link = 2
}
#endregion
#region TreeViewParts
public enum TreeItem
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
SelectedNotFocus = 5
}
public enum TreeGlyph
{
Closed = 1,
Opened = 2
}
#endregion
#region SpinParts
public enum SpinUp
{
Normal = 1,
Hot = 2,
Pressed = 3,
Disabled = 4
}
public enum SpinDown
{
Normal = 1,
Hot = 2,
Pressed = 3,
Disabled = 4
}
public enum SpinUpHorz
{
Normal = 1,
Hot = 2,
Pressed = 3,
Disabled = 4
}
public enum SpinDownHorz
{
Normal = 1,
Hot = 2,
Pressed = 3,
Disabled = 4
}
#endregion
#region ScrollbarParts
public enum ScrollbarArrowBtn
{
Up = 1,
UpHot = 2,
UpPressed = 3,
UpDisabled = 4,
Down = 5,
DownHot = 6,
DownPressed = 7,
DownDisabled = 8,
Left = 9,
LeftHot = 10,
LeftPressed = 11,
LeftDisabled = 12,
Right = 13,
RightHot = 14,
RightPressed = 15,
RightDisabled = 16
}
public enum Scrollbar
{
Normal = 1,
Hot = 2,
Pressed = 3,
Disabled = 4
}
public enum ScrollbarSizeBox
{
RightAlign = 1,
LeftAlign = 2
}
#endregion
#region EditParts
public enum EditText
{
Normal = 1,
Hot = 2,
Selected = 3,
Disabled = 4,
Focused = 5,
Readonly = 6,
Assist = 7
}
#endregion
#region ComboBoxParts
public enum ComboBox
{
Normal = 1,
Hot = 1,
Pressed = 3,
Disabled = 4
}
#endregion
}
#endregion
}
#endregion
#region Structs
#region RECT
/*/// <summary>
/// The RECT structure defines the coordinates of the
/// upper-left and lower-right corners of a rectangle
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
#region Class Data
/// <summary>
/// Specifies the x-coordinate of the upper-left
/// corner of the rectangle
/// </summary>
public int Left;
/// <summary>
/// Specifies the y-coordinate of the upper-left
/// corner of the rectangle
/// </summary>
public int Top;
/// <summary>
/// Specifies the x-coordinate of the lower-right
/// corner of the rectangle
/// </summary>
public int Right;
/// <summary>
/// Specifies the y-coordinate of the lower-right
/// corner of the rectangle
/// </summary>
public int Bottom;
#endregion
#region Constructor
/// <summary>
///
/// </summary>
/// <param name="left"></param>
/// <param name="top"></param>
/// <param name="right"></param>
/// <param name="bottom"></param>
public RECT(int left, int top, int right, int bottom)
{
this.Left = left;
this.Top = top;
this.Right = right;
this.Bottom = bottom;
}
/// <summary>
///
/// </summary>
/// <param name="rectangle"></param>
public RECT(Rectangle rectangle)
{
this.Left = rectangle.Left;
this.Top = rectangle.Top;
this.Right = rectangle.Right;
this.Bottom = rectangle.Bottom;
}
#endregion
#region Methods
/// <summary>
///
/// </summary>
/// <returns></returns>
public Rectangle ToRectangle()
{
return new Rectangle(this.Left, this.Top, this.Right-this.Left, this.Bottom-this.Top);
}
/// <summary>
///
/// </summary>
/// <param name="rect"></param>
public void FromRectangle(Rectangle rect)
{
this.Left = rect.Left;
this.Top = rect.Top;
this.Right = rect.Right;
this.Bottom = rect.Bottom;
}
/// <summary>
///
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="width"></param>
/// <param name="height"></param>
public void FromXYWH(int x, int y, int width, int height)
{
this.Left = x;
this.Top = y;
this.Right = x + width;
this.Bottom = y + height;
}
#endregion
}*/
#endregion
#region SIZE
/// <summary>
/// The SIZE structure specifies the width and height
/// of a rectangle
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct SIZE
{
#region Class Data
/// <summary>
/// Specifies the rectangle's width. The units depend
/// on which function uses this
/// </summary>
int cx;
/// <summary>
/// Specifies the rectangle's height. The units depend
/// on which function uses this
/// </summary>
int cy;
#endregion
#region Constructor
/// <summary>
///
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public SIZE(int width, int height)
{
this.cx = width;
this.cy = height;
}
/// <summary>
///
/// </summary>
/// <param name="size"></param>
public SIZE(Size size)
{
this.cx = size.Width;
this.cy = size.Height;
}
#endregion
#region Methods
/// <summary>
///
/// </summary>
/// <returns></returns>
public Size ToSize()
{
return new Size(this.cx, this.cy);
}
#endregion
#region Properties
/// <summary>
///
/// </summary>
public int Width
{
get
{
return this.cx;
}
}
/// <summary>
///
/// </summary>
public int Height
{
get
{
return this.cy;
}
}
#endregion
}
#endregion
#region POINT
/*/// <summary>
/// The POINT structure defines the x and y coordinates of a point
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
#region Class Data
/// <summary>
/// Specifies the x-coordinate of the point
/// </summary>
int cx;
/// <summary>
/// Specifies the y-coordinate of the point
/// </summary>
int cy;
#endregion
#region Constructor
/// <summary>
///
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public POINT(int x, int y)
{
this.cx = x;
this.cy = y;
}
/// <summary>
///
/// </summary>
/// <param name="size"></param>
public POINT(Point point)
{
this.cx = point.X;
this.cy = point.Y;
}
#endregion
#region Methods
/// <summary>
///
/// </summary>
/// <returns></returns>
public Point ToPoint()
{
return new Point(this.cx, this.cy);
}
#endregion
#region Properties
/// <summary>
///
/// </summary>
public int X
{
get
{
return this.cx;
}
}
/// <summary>
///
/// </summary>
public int Y
{
get
{
return this.cy;
}
}
#endregion
}*/
#endregion
#region TEXTMETRIC
/// <summary>
/// The TEXTMETRIC structure contains basic information about a
/// physical font. All sizes are specified in logical units; that
/// is, they depend on the current mapping mode of the display
/// context
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct TEXTMETRIC
{
#region Class Data
/// <summary>
/// Specifies the height (ascent + descent) of characters
/// </summary>
int tmHeight;
/// <summary>
/// Specifies the ascent (units above the base line)
/// of characters
/// </summary>
int tmAscent;
/// <summary>
/// Specifies the descent (units below the base line)
/// of characters
/// </summary>
int tmDescent;
/// <summary>
/// Specifies the amount of leading (space) inside the
/// bounds set by the tmHeight member. Accent marks and
/// other diacritical characters may occur in this area.
/// The designer may set this member to zero
/// </summary>
int tmInternalLeading;
/// <summary>
/// Specifies the amount of extra leading (space) that the
/// application adds between rows. Since this area is outside
/// the font, it contains no marks and is not altered by
/// text output calls in either OPAQUE or TRANSPARENT mode.
/// The designer may set this member to zero
/// </summary>
int tmExternalLeading;
/// <summary>
/// Specifies the average width of characters in the font
/// (generally defined as the width of the letter x). This
/// value does not include the overhang required for bold
/// or italic characters
/// </summary>
int tmAveCharWidth;
/// <summary>
/// Specifies the width of the widest character in the font
/// </summary>
int tmMaxCharWidth;
/// <summary>
/// Specifies the weight of the font
/// </summary>
int tmWeight;
/// <summary>
/// Specifies the extra width per string that may be added
/// to some synthesized fonts. When synthesizing some attributes,
/// such as bold or italic, graphics device interface (GDI)
/// or a device may have to add width to a string on both a
/// per-character and per-string basis. For example, GDI makes
/// a string bold by expanding the spacing of each character
/// and overstriking by an offset value; it italicizes a font
/// by shearing the string. In either case, there is an overhang
/// past the basic string. For bold strings, the overhang is
/// the distance by which the overstrike is offset. For italic
/// strings, the overhang is the amount the top of the font is
/// sheared past the bottom of the font.
///
/// The tmOverhang member enables the application to determine
/// how much of the character width returned by a GetTextExtentPoint32
/// function call on a single character is the actual character
/// width and how much is the per-string extra width. The actual
/// width is the extent minus the overhang
/// </summary>
int tmOverhang;
/// <summary>
/// Specifies the horizontal aspect of the device for which the
/// font was designed
/// </summary>
int tmDigitizedAspectX;
/// <summary>
/// Specifies the vertical aspect of the device for which the font
/// was designed. The ratio of the tmDigitizedAspectX and tmDigitizedAspectY
/// members is the aspect ratio of the device for which the font
/// was designed
/// </summary>
int tmDigitizedAspectY;
/// <summary>
/// Specifies the value of the first character defined in the font
/// </summary>
char tmFirstChar;
/// <summary>
/// Specifies the value of the last character defined in the font
/// </summary>
char tmLastChar;
/// <summary>
/// Specifies the value of the character to be substituted for
/// characters not in the font
/// </summary>
char tmDefaultChar;
/// <summary>
/// Specifies the value of the character that will be used to
/// define word breaks for text justification
/// </summary>
char tmBreakChar;
/// <summary>
/// Specifies an italic font if it is nonzero
/// </summary>
byte tmItalic;
/// <summary>
/// Specifies an underlined font if it is nonzero
/// </summary>
byte tmUnderlined;
/// <summary>
/// Specifies a strikeout font if it is nonzero
/// </summary>
byte tmStruckOut;
/// <summary>
/// Specifies information about the pitch, the technology, and
/// the family of a physical font
/// </summary>
byte tmPitchAndFamily;
/// <summary>
/// Specifies the character set of the font
/// </summary>
byte tmCharSet;
#endregion
}
#endregion
#region LOGFONT
/// <summary>
/// The LOGFONT structure defines the attributes of a font
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct LOGFONT
{
#region Class Data
int lfHeight;
int lfWidth;
int lfEscapement;
int lfOrientation;
int lfWeight;
byte lfItalic;
byte lfUnderline;
byte lfStrikeOut;
byte lfCharSet;
byte lfOutPrecision;
byte lfClipPrecision;
byte lfQuality;
byte lfPitchAndFamily;
char[] lfFaceName;
#endregion
#region Constructor
/// <summary>
///
/// </summary>
public LOGFONT(int numChars)
{
lfHeight = 0;
lfWidth = 0;
lfEscapement = 0;
lfOrientation = 0;
lfWeight = 0;
lfItalic = 0;
lfUnderline = 0;
lfStrikeOut = 0;
lfCharSet = 0;
lfOutPrecision = 0;
lfClipPrecision = 0;
lfQuality = 0;
lfPitchAndFamily = 0;
lfFaceName = new char[32];
}
#endregion
}
#endregion
#region MARGINS
/// <summary>
/// Defines the margins of windows that have visual styles applied
/// </summary>
public struct MARGINS
{
/// <summary>
/// width of left border that retains its size
/// </summary>
public int cxLeftWidth;
/// <summary>
/// width of right border that retains its size
/// </summary>
public int cxRightWidth;
/// <summary>
/// height of top border that retains its size
/// </summary>
public int cyTopHeight;
/// <summary>
/// height of bottom border that retains its size
/// </summary>
public int cyBottomHeight;
}
#endregion
#region INTLIST
/// <summary>
/// Contains an array or list of int data items from a visual style
/// </summary>
public struct INTLIST
{
#region Class Data
/// <summary>
/// Number of values in iValues
/// </summary>
int iValueCount;
/// <summary>
/// List of integers
/// </summary>
int[] iValues;
#endregion
#region Constructor
public INTLIST(int maxIintListCount)
{
iValueCount = 0;
iValues = new int[10 /*MAX_INTLIST_COUNT*/];
}
#endregion
}
#endregion
#region DTBGOPTS
/// <summary>
///
/// </summary>
public struct DTBGOPTS
{
/// <summary>
/// Size of the structure
/// </summary>
public int dwSize;
/// <summary>
/// Flags that specify the selected options
/// </summary>
public int dwFlags;
/// <summary>
/// Specifies the rectangle
/// </summary>
public RECT rcClip;
public DTBGOPTS(int dwFlags, RECT rcClip)
{
this.dwSize = Marshal.SizeOf(typeof(DTBGOPTS));
this.dwFlags = dwFlags;
this.rcClip = rcClip;
}
}
#endregion
#endregion
#region Enums
#region THEMESIZE
/// <summary>
/// Identifies the size of the visual style part to retrieve
/// </summary>
/// <remarks>The GetThemePartSize function retrieves the
/// minimum and best-fit sizes of a part and places the
/// information in a THEME_SIZE structure</remarks>
public enum THEMESIZE
{
/// <summary>
/// Receives the minimum size of a visual style part
/// </summary>
Min,
/// <summary>
/// Receives the size of the visual style part that
/// will best fit the available space
/// </summary>
True,
/// <summary>
/// Receives the size that the theme manager uses to
/// draw a part
/// </summary>
Draw
}
#endregion
#region PROPERTYORIGIN
/// <summary>
/// Used to specify where a property was found
/// </summary>
public enum PROPERTYORIGIN
{
/// <summary>
/// property was found in the state section
/// </summary>
State,
/// <summary>
/// property was found in the part section
/// </summary>
Part,
/// <summary>
/// property was found in the class section
/// </summary>
Class,
/// <summary>
/// property was found in [globals] section
/// </summary>
Global,
/// <summary>
/// property was not found
/// </summary>
NotFound
}
#endregion
#region DrawThemeBackgroundOptionFlags
/// <summary>
///
/// </summary>
public enum DrawThemeBackgroundOptionFlags
{
/// <summary>
/// rcClip specifies the rectangle to which drawing is clipped
/// </summary>
ClipRect = 0x00000001,
/// <summary>
/// Draw transparent and alpha images as solid
/// </summary>
DrawSolid = 0x00000002,
/// <summary>
/// Do not draw the border of the part (currently this value
/// is only supported for bgtype=borderfill)
/// </summary>
OmitBorder = 0x00000004,
/// <summary>
/// Do not draw the content area of the part (currently this
/// value is only supported for bgtype=borderfill).
/// </summary>
OmitContent = 0x00000008,
/// <summary>
/// TRUE if calling to compute region
/// </summary>
ComputingRegion = 0x00000010,
/// <summary>
/// Assume the hdc is mirrorred and flip images as appropriate
/// (currently only supported for bgtype=imagefile)
/// </summary>
MirrorDC = 0x00000020,
}
#endregion
#region ThemeAppPropertyFlags
/// <summary>
///
/// </summary>
public enum ThemeAppPropertyFlags
{
/// <summary>
///
/// </summary>
AllowNonClient = (1 << 0),
/// <summary>
///
/// </summary>
AllowControls = (1 << 1),
/// <summary>
///
/// </summary>
AllowWebContent = (1 << 2)
}
#endregion
#region EnableThemeDialogTextureFlags
/// <summary>
///
/// </summary>
public enum EnableThemeDialogTextureFlags
{
/// <summary>
///
/// </summary>
Disable = 0x00000001,
/// <summary>
///
/// </summary>
Enable = 0x00000002,
/// <summary>
///
/// </summary>
UseTabTexture = 0x00000004,
/// <summary>
///
/// </summary>
EnableTab = (Enable | UseTabTexture)
}
#endregion
#region HitTestThemeBackgroundFlags
/// <summary>
///
/// </summary>
public enum HitTestThemeBackgroundFlags
{
/// <summary>
///
/// </summary>
BackgroundSeg = 0x0000,
/// <summary>
///
/// </summary>
FixedBorder = 0x0002,
/// <summary>
///
/// </summary>
Caption = 0x0004,
/// <summary>
///
/// </summary>
ResizingBorder_Left = 0x0010,
/// <summary>
///
/// </summary>
ResizingBorder_Top = 0x0020,
/// <summary>
///
/// </summary>
ResizingBorder_Right = 0x0040,
/// <summary>
///
/// </summary>
ResizingBorder_Bottom = 0x0080,
/// <summary>
///
/// </summary>
ResizingBorder = (ResizingBorder_Left | ResizingBorder_Top |
ResizingBorder_Right | ResizingBorder_Bottom),
/// <summary>
///
/// </summary>
SizingTemplate = 0x0100,
/// <summary>
///
/// </summary>
SystemSizingMarging = 0x0200
}
#endregion
#region DrawThemeTextFlags
/// <summary>
///
/// </summary>
public enum DrawThemeTextFlags
{
/// <summary>
/// Draw a grayed-out string
/// </summary>
Grayed = 1,
/// <summary>
/// Renders the text at the top of the display rectangle
/// </summary>
Top = 0,
/// <summary>
/// Aligns text to the left
/// </summary>
Left = 0,
/// <summary>
/// Centers text horizontally in the display rectangle
/// </summary>
Center = 1,
/// <summary>
/// Aligns text to the right
/// </summary>
Right = 2,
/// <summary>
/// Centers text vertically. This value is used only with
/// the SingleLine value
/// </summary>
VCenter = 4,
/// <summary>
/// Renders the text string at the bottom of the display
/// rectangle. This value is used only with the SingleLine
/// value
/// </summary>
Bottom = 8,
/// <summary>
/// Breaks lines between words if a word would extend past
/// the edge of the display rectangle. A carriage return/line
/// feed (CR/LF) sequence also breaks the line
/// </summary>
WordBreak = 16,
/// <summary>
/// Displays text on a single line. Carriage returns and line
/// feeds do not break the line
/// </summary>
SingleLine = 32,
/// <summary>
/// Expands tab characters. The default number of characters
/// per tab is eight. The WordEllipsis, PathEllipsis, and
/// EndEllipsis values cannot be used with the ExpandTabs value
/// </summary>
ExpandTabs = 64,
/// <summary>
/// Sets tab stops
/// </summary>
TabStop = 128,
/// <summary>
/// Draws the text string without clipping the display rectangle
/// </summary>
NoClip = 256,
/// <summary>
/// Includes the external leading of a font in the line height.
/// Normally, external leading is not included in the height of
/// a line of text
/// </summary>
ExternalLeading = 512,
/// <summary>
/// Determines the width and height of the display rectangle
/// </summary>
CalcRect = 1024,
/// <summary>
/// Turns off processing of prefix characters. Normally,
/// DrawThemeText interprets the prefix character & as a
/// directive to underscore the character that follows, and
/// the prefix characters && as a directive to print a single
/// &. By specifying NoPrefix, this processing is turned off
/// </summary>
NoPrefix = 2048,
/// <summary>
///
/// </summary>
Internal = 4096,
/// <summary>
/// Duplicates the text-displaying characteristics of a multiline
/// edit control. Specifically, the average character width is
/// calculated in the same manner as for an edit control, and
/// the function does not display a partially visible last line
/// </summary>
EditControl = 8192,
/// <summary>
/// Replaces characters in the middle of text with an ellipsis
/// so that the result fits in the display rectangle. If the
/// string contains backslash (\) characters, PathEllipsis preserves
/// as much as possible of the text after the last backslash. The
/// string is not modified unless the ModifyString flag is specified
/// </summary>
PathEllipsis = 16384,
/// <summary>
/// Truncates a text string that is wider than the display rectangle
/// and adds an ellipsis to indicate the truncation. The string
/// is not modified unless the ModifyString flag is specified
/// </summary>
EndEllipsis = 32768,
/// <summary>
/// Modifies a string to match the displayed text. This value has
/// no effect unless EndEllipsis or PathEllipsis is specified
/// </summary>
ModifyString = 65536,
/// <summary>
/// Lays out text in right-to-left order for bidirectional text,
/// for example, text in a Hebrew or Arabic font. The default
/// direction for text is left-to-right
/// </summary>
RTLReading = 131072,
/// <summary>
/// Truncates any word that does not fit in the display rectangle
/// and adds an ellipsis
/// </summary>
WordEllipsis = 262144,
/// <summary>
/// Prevents a line break at a double-byte character set (DBCS),
/// so that the line-breaking rule is equivalent to single-byte
/// character set (SBCS). This can be used, for example, to make
/// icon labels written in Korean text more readable. This value
/// has no effect unless WordBreak is specified
/// </summary>
NoFullWidthCharBreak = 524288,
/// <summary>
/// Ignores the prefix character & in the text. The letter that
/// follows is not underlined, but other prefix characters are
/// still processed
/// </summary>
HidePrefix = 1048576,
/// <summary>
/// Draws only an underline at the position of the character
/// following the prefix character &. Normally DrawThemeText
/// interprets the & as a directive to underline the character
/// that follows and the prefix characters && as a directive to
/// print a single &. By specifying PrefixOnly, no characters
/// are drawn, only an underline. White spaces are placed in
/// the positions where characters would normally appear
/// </summary>
PrefixOnly = 2097152
}
#endregion
#endregion
}