CStaticST v1.2

A nice and interactive static control for your Windows applications

Yes!
This class is included in the latest SoftechSoftware DLL version.

Description

CStaticST is a class derived from MFC CStatic class.

Using this class developers will have the option to drastically improve the look and feel of their Windows applications !

Main CStaticST features are:

How to integrate CStaticST in your application

In your project include the following files:

Create a CStaticST object statically
With dialog editor create a standard static control called, for example, IDC_STCTEST (you don't need to make it owner drawn) and create a member variable for this control:
CStaticST m_stcTest;
Now attach the control to CStaticST. For dialog-based applications, in your OnInitDialog:
// Call the base-class method
CDialog::OnInitDialog();

// Create the IDC_STCTEST control
m_stcTest.SubclassDlgItem(IDC_STCTEST, this);
Or in your DoDataExchange:
// Call the base method
CDialog::DoDataExchange(pDX);

// Create the IDC_STCTEST control
DDX_Control(pDX, IDC_STCTEST, m_stcTest);

Class methods

SetIcon
Assigns icon to the control.
Any previous icon will be removed.

// Parameters:
//     [IN]   nIcon
//            A Windows icon resource ID.
//            Pass NULL to remove any icon from the control.
//     [IN]   bRepaint
//            If TRUE the control will be immediately repainted.
//     [IN]   hInstance
//            Handle of the instance that contains the icon.
//            If NULL the icon will be loaded from the .EXE resources
//
// Return value:
//      STATICST_OK
//          Function executed successfully.
//      STATICST_INVALIDRESOURCE
//          Failed loading the specified resource.
//
DWORD SetIcon(int nIcon, BOOL bRepaint = TRUE, HINSTANCE hInstance = NULL)
SetIcon
Assigns icon to the control.
Any previous icon will be removed.
// Parameters:
//     [IN]   hIcon
//            Handle fo the icon to show on the control.
//            Pass NULL to remove any icon from the control.
//     [IN]   bRepaint
//            If TRUE the control will be immediately repainted.
//
// Return value:
//      STATICST_OK
//          Function executed successfully.
//      STATICST_INVALIDRESOURCE
//          Failed loading the specified resource.
//
DWORD SetIcon(HICON hIcon, BOOL bRepaint = TRUE)
SetColors
Sets foreground and background control's colors.
// Parameters:
//     [IN]   crTextColor
//            A COLORREF value indicating the foreground color.
//     [IN]   crBkColor
//            A COLORREF value indicating the background color.
//     [IN]   bRepaint
//            If TRUE the control will be immediately repainted.
//
void SetColors(COLORREF crTextColor, COLORREF crBkColor, BOOL bRepaint = TRUE)
SetTextColor
Sets foreground control's color.
// Parameters:
//     [IN]   crTextColor
//            A COLORREF value indicating the foreground color.
//     [IN]   bRepaint
//            If TRUE the control will be immediately repainted.
//
void SetTextColor(COLORREF crTextColor, BOOL bRepaint = TRUE)
SetBkColor
Sets background control's color.
// Parameters:
//     [IN]   crBkColor
//            A COLORREF value indicating the background color.
//     [IN]   bRepaint
//            If TRUE the control will be immediately repainted.
//
void SetBkColor(COLORREF crBkColor, BOOL bRepaint = TRUE)
SetMessageClick
Assigns a message that will be sent to a window when the user clicks on the control.
// Parameters:
//     [IN]   byClickType
//            Type of the click for which assign the message.
//            This is a zero-based value and can be one of the following:
//            STATICST_CLICK         A single click on the control
//            STATICST_DBLCLICK      A double click on the control
//     [IN]   hWnd
//            Handle of the window that will be receive the message.
//            Set this value to NULL to disable the message for a particular click.
//     [IN]   nMsg
//            Message to sent.
//
// Return value:
//     STATICST_OK
//            Function executed successfully.
//     STATICST_INVALIDCLICKTYPE
//            Invalid click type.
//
DWORD SetMessageClick(BYTE byClickType, HWND hWnd, UINT nMsg)
SetTextMargins
Sets the number of extra blank pixels around the text.
Extra blank pixels are useful when the text is resulting too close to the control's border.
Extra blank pixels will be paintend using the control's background color (if any).
Extra blank pixels will be reserved on top, bottom, left and right control's margins.
// Parameters:
//     [IN]   nTextMargin
//            Number of extra blank pixels around the text.
//     [IN]   bRepaint
//            If TRUE the control will be immediately repainted.
//
// Return value:
//     STATICST_OK
//            Function executed successfully.
//
DWORD SetTextMargins(int nTextMargin, BOOL bRepaint = TRUE)
SetTooltipText (Using resource)
Sets the text to show in the control's tooltip.
// Parameters:
//     [IN]   nId
//            ID number of the string resource containing the text to show.
//     [IN]   bActivate
//            If TRUE the tooltip will be created active.
//
void SetTooltipText(int nId, BOOL bActivate = TRUE)
SetTooltipText
Sets the text to show in the control's tooltip.
// Parameters:
//     [IN]   lpszText
//            Pointer to a null-terminated string containing the text to show.
//     [IN]   bActivate
//            If TRUE the tooltip will be created active.
//
void SetTooltipText(LPCTSTR lpszText, BOOL bActivate = TRUE)
ActivateTooltip
Enables or disables the control's tooltip.
// Parameters:
//     [IN]   bActivate
//            If TRUE the tooltip will be activated.
//
void ActivateTooltip(BOOL bActivate = TRUE)
DrawTransparent
Enables the transparent mode.
Note: this operation is not reversible.
DrawTransparent should be called just after the control is created.
Do not use trasparent static controls until you really need it (you have a bitmapped background) since each transparent control makes a copy in memory of its background.
This may bring unnecessary memory use and execution overload.
// Parameters:
//     [IN]   bRepaint
//            If TRUE the control will be immediately repainted.
//
// Return value:
//      STATICST_OK
//          Function executed successfully.
//
DWORD DrawTransparent(BOOL bRepaint = FALSE)
OnDrawBackground
This function is called every time the control's background needs to be painted.
If the control is in transparent mode this function will NOT be called.
This is a virtual function that can be rewritten in CStaticST-derived classes to produce a whole range of buttons not available by default.
// Parameters:
//     [IN]   pDC
//            Pointer to a CDC object that indicates the device context.
//     [IN]   pRect
//            Pointer to a CRect object that indicates the bounds of the
//            area to be painted.
//
// Return value:
//     STATICST_OK
//        Function executed successfully.
//
virtual DWORD OnDrawBackground(CDC* pDC, CRect* pRect)
OnDrawBorder
This function is called every time the control's border needs to be painted.
This is a virtual function that can be rewritten in CStaticST-derived classes to produce a whole range of controls not available by default.
// Parameters:
//     [IN]   pDC
//            Pointer to a CDC object that indicates the device context.
//     [IN]   pRect
//            Pointer to a CRect object that indicates the bounds of the
//            area to be painted.
//
// Return value:
//     STATICST_OK
//        Function executed successfully.
//
virtual DWORD OnDrawBorder(CDC* pDC, CRect* pRect)
GetVersionI
Returns the class version as a short value.
// Return value:
//     Class version. Divide by 10 to get actual version.
//
static short GetVersionI()
GetVersionC
Returns the class version as a string value.
// Return value:
//     Pointer to a null-terminated string containig the class version.
//
static LPCTSTR GetVersionC()

History

Disclaimer and usage terms

The software and the accompanying files are distributed "AS IS" and without any warranties whether expressed or implied. No responsibilities for possible damages or even functionality can be taken. The user must assume the entire risk of using this software.
The sample application and the source codes (where available) are for demostration purposes only. You are not allowed to use the demo source codes, libraries and DLLs in any of your application. If you like this software you must buy the full version.
Downloading anything from this site means you accept the above terms.