SECBitmapButton Class

class SECBitmapButton: public SECOwnerDrawButton

The SECBitmapButton class implements a button which displays a bitmap and an optional caption on the button face.

Defined in: SECBTNS.h

Comments

The alignment modes are specified in Alignment. The alignment of the bitmap in all modes except SECBitmapButton::Al_Center is always offset from the horizontal and vertical margins. This offset can be set with the SetIndents function. The caption will always be clipped so that it does not overwrite the bitmap.

See the COLOR sample in the \\OT\\SAMPLES\\STANDARD\\CONTROLSCOLRWELL directory for a demonstration of this class.

Example

You can attach SECBitmapButton objects to existing push buttons with

m_bmpButton.AttachButton(IDC_BUTTON1,
                SECBitmapButton::Al_Left,
                IDB_BMP, this);
You can dynamically create an SECBitmapButton button control with

m_bmpButton.Create("Help",
               WS_VISIBLE|WS_TABSTOP|WS_CHILD, SECBitmapButton::Al_Left, IDB_HELP,
               rect, this, IDC_BUTTON1);

enum  Alignment

The alignment modes.

Class Members

Creation/Initialization

 SECBitmapButton()

Creates a bitmap button object.

virtual BOOL  AttachButton(int nCtlID, Alignment alignment, int nIDBmp, CWnd* pParentWnd, int iFlags=0)

Attaches the bitmap button object to an existing button.

virtual BOOL  AttachButton(int nCtlID, Alignment alignment, LPCTSTR lpszBmpName, CWnd* pParentWnd, int iFlags=0)

Attaches the bitmap button object to an existing button.

virtual BOOL  Create(LPCTSTR lpszCaption, DWORD dwStyle, Alignment alignment, LPCTSTR lpszBmpName, const CRect& rect, CWnd* pParentWnd, int nID, int iFlags=0)

Dynamically creates a bitmap button control.

virtual BOOL  Create(LPCTSTR lpszCaption, DWORD dwStyle, Alignment alignment, int nIDBmp, const CRect& rect, CWnd* pParentWnd, int nID, int iFlags=0)

Dynamically creates a bitmap button control.

Attributes

void  SetIndents(CSize sz)

Sets the bitmap margin offsets.

CSize  GetIndents() const

Returns the bitmap margin offsets.

Operations

void  SizeToContent()

Size the button to fit it's contents.

BOOL  SetBitmap(LPCTSTR lpszBmp)

Change the current bitmap

BOOL  SetBitmap(int nIDBmp)

Change the current bitmap

Overridable

virtual void  CalcLayout()

Calculates the position of the bitmap and text.

virtual void  DrawSpecific(CDC* pDC, LPDRAWITEMSTRUCT lpDS, CRect& rect)

Draws the face of the button.

virtual void  DrawFocus(CDC* pDC, CRect& rect)

Draws the focus rectangle.

Protected data members

LPCTSTR  m_lpszBmpName

Resource name for bitmap.

CBitmap  m_bmp

The bitmap for the button.

CSize  m_indents

Indentations of bitmap from edge of button face.

CRect  m_bmpRect

Window rectangle for the bitmap

CRect  m_textRect

Window rectangle for the text

Alignment  m_alignment

The alignment mode.