CXPStyleButtonST is a scalable
If running under Windows XP the application buttons will be skinned using the current selected
theme (if any), while if running under Windows 9x/ME/NT/2000 the buttons will have the standard,
CButtonST flat style. In both cases all
CButtonST features are granted!
CXPStyleButtonST - with a zero-cost implementation - your applications running under XP will have
the new, smooth and elegant style but also will run error-less under old Windows versions.
Integrating CXPStyleButtonST into Your Application
In your project include the following files:
Create a instance of
CThemeHelperST. This class encapsulates all the required APIs to access
the current selected theme (if any) or to run error-less if none is selected or if running under a
old Windows version. You need only one instance for all the buttons, so this can be global to the application
or only to the current dialog.
Creating a CXPStyleButtonST Object Statically
With dialog editor create a standard button called, for example,
IDOK (you don't need to make it owner drawn)
and create a member variable for this button:
Now attach the button to
CXPStyleButtonST. For dialog-based applications, in your
Or in your
DDX_Control(pDX, IDOK, m_btnOk);
CThemeHelperST instance to the button. This is fundamental or your button will not have the
current theme style even if running under XP! In your
Creating a CXPStyleButtonST Object Dynamically
In your application, create a member variable for the button. Please note that this variable is a pointer:
Now create the button. For dialog-based applications, in your
m_pbtnOk = new CXPStyleButtonST;
m_pbtnOk->Create(_T("&Ok"), WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP,
CRect(10, 10, 200, 100), this, IDOK);
CThemeHelperST instance to the button as described in the previous section. Remember to destroy the button or you will get a memory leak. This can be done, for example, in your class destructor:
if (m_pbtnOk) delete m_pbtnOk;
CThemeHelperST instance to the button.
void SetThemeHelper(CThemeHelperST* pTheme)
Sets if the button must be drawn using the flat toolbar-style.
DWORD DrawAsToolbar(BOOL bDrawAsToolbar, BOOL bRepaint = TRUE)
Returns the class version as a short value.
static short GetVersionI()
Returns the class version as a string value.
static LPCTSTR GetVersionC()
CXPStyleButtonST you need the Platform SDK (August 2001 or newer). This is not
mandatory because at compile-time, if not found, it will be emulated. At run-time you don't need any
additional SDK or libraries installed.
- v1.2 (24/January/2003)
Made compatible with CButtonST v3.8
- v1.1 (31/October/2002)
Fixed a visual bug when the button was pressed
- v1.0 (21/January/2002)
CThemeHelperST is based on the
CVisualStylesXP code published
by David Yuheng Zhao (firstname.lastname@example.org). Thanks very much!
THE SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED.
NO REPONSIBILITIES FOR POSSIBLE DAMAGES OR EVEN FUNCTIONALITY CAN BE TAKEN.
THE USER MUST ASSUME THE ENTIRE RISK OF USING THIS SOFTWARE.
THIS SOFTWARE IS FREE FOR PERSONAL USE OR FREEWARE APPLICATIONS.
IF YOU USE THIS SOFTWARE IN COMMERCIAL OR SHAREWARE APPLICATIONS YOU
ARE GENTLY ASKED TO DONATE 5$ (FIVE U.S. DOLLARS) TO THE AUTHOR:
P.O. Box 65
21019 Somma Lombardo (VA)