CButtonST v2.3
Copyright (C) 1998 by SoftechSoftware
Thank you for use this SoftechSoftware! Thanks very much!


Contact addresses

SoftechSoftware E-Mail:
davide_calabro@yahoo.com
SoftechSoftware homepage:
http://members.tripod.com/~SoftechSoftware/index.html
CButtonST homepage:
http://members.tripod.com/~SoftechSoftware/cbtnst.html


Description

CButtonST is a class derived from MFC CButton class.
With this class your applications can have standard buttons or new and modern buttons with "flat" style!

CButtonST features:

You are encouraged to use this class everywhere you want; there is no fee required for CButtonST. Freely add modifications and/or fix bugs, but please, send any of these to SoftechSoftware!


How to integrate CButtonST in your application

    In your project include the following files:
    
        BtnST.h
        BtnST.cpp
    
    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:
    
        CButtonST m_btnOk;
    
    Now, with resource editor, create an icon called, for example, IDI_OK256
    You can also import it from one that already exists, such as, one included
    in the sample project (i.e. 32x32x256_Ok.ico).

    Remember to use 32x32 pixel icons. Even if there is support for icons wich
    dimension is not 32x32 they can be drawn incorrectly.

    Now attach the button to CButtonST. In your OnInitDialog procedure:
    
        // Call the base method
        CDialog::OnInitDialog();

        // Create the IDOK button
        m_btnOk.SubclassDlgItem(IDOK, this);
        // Assign the icon
        m_btnOk.SetIcon(IDI_OK256);
    
    You may use two icons for the same button. First icon will be displayed when
    the mouse pointer is over the button. Second icon will be displayed when the
    mouse pointer is outside the button. If you design two same icons but one
    with colors and one black & white you can have a great visual effect!
    
        // Assign two icons
        m_btnOk.SetIcon(IDI_OK256, IDI_OK256_BW);
    
    Please note that two icons must have the same size!

    By default the button will have the icon on the left and the text on
    the right. If you want a button with the icon on the top and the text
    on the bottom, you must set the alignment of the button:
    
        // Align icon vertically
        m_btnOk.SetAlign(CButtonST::ST_ALIGN_VERT);
    
    Again, by default, the button will have the new "flat" style. If you want
    a standard button just use the following piece of code:
    
        // Draw the button as a standard button
        m_btnOk.SetFlat(FALSE);
    
    The following applies only with "flat" buttons: by default when the mouse
    pointer passes over the button, this highlights itself. If you don't want
    this just disable it. (In the demo program look what happens at the button
    with the CD-ROM inside it!)
    
        // Don't draw border for this button
        m_btnOk.DrawBorder(FALSE);
    
    Every button's color can be customized.
    Background color is the button's face color while foreground color is the
    text color. Inactive colors are that colors shown when the mouse is off the
    button while active colors are that colors shown when the mouse is over.
    
        // Set some color effect
        COLORREF crStandard = ::GetSysColor(COLOR_BTNFACE);
        m_btnOk.SetInactiveBgColor(crStandard - RGB(20,20,20));
        m_btnOk.SetActiveBgColor(crStandard + RGB(20,20,20));
        m_btnOk.SetInactiveFgColor(RGB(0,255,0));
        m_btnOk.SetActiveFgColor(RGB(255,0,0));
    
    Each button can have its own mouse pointer.
    For example a button that runs an internet browser could change the pointer
    to a hand when the user moves the mouse on it!
    
         // Set a hand cursor
        m_btnOk.SetBtnCursor(IDC_HAND);
    
    Your button is now a CButtonST!

    Look inside the demo program to learn more about CButtonST. This is the best way!



CButtonST members

void SetIcon(int nIconInId, int nIconOutId = NULL, BYTE cx = 32, BYTE cy = 32)
Set icon(s) for the button Example:
m_btnOk.SetIcon(IDI_OK256);
m_btnOk.SetIcon(IDI_OK256, IDI_OK256_BW);
m_btnOk.SetIcon(NULL); // To get a button without icon(s)


void SetAlign(int nAlign)
Set icon position (if one is defined)

Input values: Example:
m_btnOk.SetAlign(CButtonST::ST_ALIGN_VERT);

int GetAlign()
Get current icon position (see SetAlign for possible return values)

Example:
int nRetValue = m_btnOk.GetAlign();

void SetFlat(BOOL bState = TRUE)
Set button style ("flat" or standard)

Input values: Example:
m_btnOk.SetFlat();
m_btnOk.SetFlat(FALSE);


BOOL GetFlat()
Return current button style (see SetFlat for possible return values)

Example:
int nRetValue = m_btnOk.GetFlat();

void DrawBorder(BOOL bEnable = TRUE)
Set highlight ON/OFF (only for "flat" buttons)

Input values: Example:
m_btnOk.DrawBorder();
m_btnOk.DrawBorder(FALSE);


static const short GetVersionI()
static const char* GetVersionC()

Return CButtonST version

Example:
int nVer = CButtonST::GetVersionI(); // Divide by 10 to get actual version
char szVer[20];
strcpy(szVer, CButtonST::GetVersionC());


void SetShowText(BOOL bShow = TRUE)
Add or remove text (caption) from button at runtime

Input values: Example:
m_btnOk.SetShowText();
m_btnOk.SetShowText(FALSE);


BOOL GetShowText()
Return current text status (displayed or not)

Example:
int nRetValue = m_btnOk.GetShowText();

void SetDefaultActiveFgColor()
Sets to the system default the text's color (when the mouse is over the button)
This is automatically called when a button is created.

Example:
m_btnOk.SetDefaultActiveFgColor();

void SetDefaultActiveBgColor()
Sets to the system default the button's color (when the mouse is over it)
This is automatically called when a button is created.

Example:
m_btnOk.SetDefaultActiveBgColor();

void SetDefaultInactiveFgColor()
Sets to the system default the text's color (when the mouse is outside the button)
This is automatically called when a button is created.

Example:
m_btnOk.SetDefaultInactiveFgColor();

void SetDefaultInactiveBgColor()
Sets to the system default the button's color (when the mouse is outside it)
This is automatically called when a button is created.

Example:
m_btnOk.SetDefaultInactiveBgColor();

void SetActiveFgColor(COLORREF crNew, BOOL bRepaint = FALSE)
Sets the text's color (when the mouse is over the button)

Input values: Example:
m_btnOk.SetActiveFgColor(RGB(255, 255, 0));

void SetActiveBgColor(COLORREF crNew, BOOL bRepaint = FALSE)
Sets the button's color (when the mouse is over it)

Input values: Example:
m_btnOk.SetActiveBgColor(RGB(128, 128, 128));
m_btnOk.SetActiveBgColor(::GetSysColor(COLOR_BTNFACE), TRUE);


void SetInactiveFgColor(COLORREF crNew, BOOL bRepaint = FALSE)
Sets the text's color (when the mouse is outside the button)

Input values: Example:
m_btnOk.SetInactiveFgColor(RGB(255, 255, 255));

void SetInactiveBgColor(COLORREF crNew, BOOL bRepaint = FALSE)
Sets the button's color (when the mouse is outside it)

Input values: Example:
m_btnOk.SetInactiveBgColor(RGB(128, 128, 128));

const COLORREF GetActiveFgColor()
Returns the current text's color (when the mouse is over the button)

Example:
COLORREF crCurrent = m_btnOk.GetActiveFgColor();

const COLORREF GetActiveBgColor()
Returns the current button's color (when the mouse is over it)

Example:
COLORREF crCurrent = m_btnOk.GetActiveBgColor();

const COLORREF GetInactiveFgColor()
Returns the current text's color (when the mouse is outside the button)

Example:
COLORREF crCurrent = m_btnOk.GetInactiveFgColor();

const COLORREF GetInactiveBgColor()
Returns the current button's color (when the mouse is outside it)

Example:
COLORREF crCurrent = m_btnOk.GetInactiveBgColor();

void SetFlatFocus(BOOL bDrawFlatFocus, BOOL bRepaint = FALSE)
Enable/Disable the drawing of the focus rectangle
This is valid ONLY for "flat" buttons; standard buttons always have the focus rectangle.

Input values: Example:
m_btnOk.SetFlatFocus(TRUE);
m_btnOk.SetFlatFocus(FALSE, TRUE);


BOOL GetFlatFocus()
Returns the state of the focus rectangle
This is valid ONLY for "flat" buttons; standard buttons always have the focus rectangle.

Return value: Example:
BOOL bDrawFlatFocus = m_btnOk.GetFlatFocus();

BOOL SetBtnCursor(int nCursorId = -1)
Assign a cursor to the button
The mouse pointer will change when over the button.

Input values: Output value: Example:
BOOL bRetValue = m_btnOk.SetBtnCursor(IDC_HAND);
m_btnOk.SetBtnCursor(); // To remove the assigned cursor



History


Things to do


Special thanks

CButtonST is now receiving many suggestions from the users.
This section want to be the right place to say a THANK! to all of them for their precious help.

Armin Mendle
Chris Maunder (CHyperLink class)
Jeremy Davis (Suggestions about focus rectangles)
Keith Rule (CMemDC class)
Michael Santoro (For the ideas his CSXButton class given me!)
Mike Turner
Milan Gardian (Suggestions about color customization)
Ralph Varjabedian (For his many bug fixes!)


Copyright © 1998 by SoftechSoftware.
davide_calabro@yahoo.com