📄 buttonst.h
字号:
//
// Class: CButtonST
//
// Compiler: Visual C++
// Tested on: Visual C++ 5.0
// Visual C++ 6.0
//
// Version: See GetVersionC() or GetVersionI()
//
// Created: xx/xxxx/1998
// Updated: 12/May/2001
//
// Author: Davide Calabro' davide_calabro@yahoo.com
//
// --------------------------------------------------------------------------
// Description : Port of CButtonST to WTL (http://www.codeproject.com/buttonctrl/cbuttonst.asp)
// Author : Serge Weinstock
//
// You are free to use, distribute or modify this code
// as long as this header is not removed or modified.
// --------------------------------------------------------------------------
// Support for image list
// Support for dynamic creation
#if !defined(__buttonst_h__)
#define __buttonst_h__
#include <atlapp.h>
#include <atlwin.h>
#include <atlctrls.h>
#include <atlgdi.h>
#include <atlcrack.h>
//#include <atlmisc.h>
// Comment this if you don't want that CButtonST hilights itself
// also when the window is inactive (like happens in Internet Explorer)
//#define ST_LIKEIE
// Return values
#ifndef BTNST_OK
#define BTNST_OK 0
#endif
#ifndef BTNST_INVALIDRESOURCE
#define BTNST_INVALIDRESOURCE 1
#endif
#ifndef BTNST_FAILEDMASK
#define BTNST_FAILEDMASK 2
#endif
#ifndef BTNST_INVALIDINDEX
#define BTNST_INVALIDINDEX 3
#endif
namespace WTL
{
// CButton - client side for a Windows BUTTON control
class CButtonST : public CWindowImpl<CButtonST, CButton, CControlWinTraits>
{
public:
typedef CWindowImpl<CButtonST, CButton, CControlWinTraits> inherited;
typedef CButtonST thisClass;
//! Alignment
enum Alignment {ST_ALIGN_HORIZ, ST_ALIGN_VERT, ST_ALIGN_HORIZ_RIGHT};
//! Color types
enum ColorType
{
BTNST_COLOR_BK_IN = 0, //!< Background color when mouse is INside
BTNST_COLOR_FG_IN, //!< Text color when mouse is INside
BTNST_COLOR_BK_OUT, //!< Background color when mouse is OUTside
BTNST_COLOR_FG_OUT, //!< Text color when mouse is OUTside
BTNST_MAX_COLORS
};
//! Constructor
CButtonST();
//! Destructor
~CButtonST();
//! Sets the cursor of the button
bool SetBtnCursor(_U_STRINGorID nCursorId, HMODULE rsrcModule = 0);
//! Sets the icons of the button
DWORD SetIcon(HICON hIconIn, HICON hIconOut);
//! Sets the icons of the button
DWORD SetIcon(_U_STRINGorID nIconInId, _U_STRINGorID nIconOutId = 0U, HMODULE rsrcModule = 0);
//! Set the icons of the buttons form an image list
DWORD SetIcon(HIMAGELIST imagelIst, int idxIn, int idxOut);
//! Sets the bitmaps of the button
DWORD SetBitmaps(HBITMAP hBitmapIn, COLORREF crTransColorIn, HBITMAP hBitmapOut, COLORREF crTransColorOut = 0);
//! Sets the bitmaps of the button
DWORD SetBitmaps(_U_STRINGorID nBitmapIn, COLORREF crTransColorIn, _U_STRINGorID nBitmapOut = 0U, COLORREF crTransColorOut = 0, HMODULE rsrcModule = 0);
//! Sets the button flatness
void SetFlat(bool bState);
//! Gets the button flatness
bool GetFlat();
//! Sets the button alignment
void SetAlign(Alignment nAlign);
//! Gets the button alignment
Alignment GetAlign();
//! Shows or hides the border
void DrawBorder(bool bEnable);
//! Is the button the default button
bool GetDefault();
//! Shows the focus if the style is flat
void SetFlatFocus(bool bDrawFlatFocus, bool bRepaint = true);
//! Set the tooltip text
void SetTooltipText(LPCTSTR lpszText, bool bActivate = true);
//! Set the tooltip text
void SetTooltipText(int nId, bool bActivate = true);
//! Activate/Deactivate the tooltip
void ActivateTooltip(bool bActivate);
//! Set the state of a check box
void SetCheck(bool nCheck, bool bRepaint = true);
//! Set the check box state
bool GetCheck() const;
//! Set the color corresponding to a color type
/*!
\param byColorIndex: index of the color to set. This index is zero-based.
\param crColor : New color.
\param bRepaint: If TRUE the control will be repainted.
\return BTNST_OK if the function executed successfully or BTNST_INVALIDINDEXif it was an invalid color index.
*/
DWORD SetColor(ColorType byColorIndex, COLORREF crColor, bool bRepaint = true);
//! Get the color corresponding to a color type
/*!
\param byColorIndex: index of the color to set. This index is zero-based.
\retval crpColor : New color.
\return BTNST_OK if the function executed successfully or BTNST_INVALIDINDEXif it was an invalid color index.
*/
DWORD GetColor(ColorType byColorIndex, COLORREF* crpColor);
//! Sets the URL
bool SetURL(LPCTSTR lpszURL);
//! Set the qutorepeat parameters
bool SetAutoRepeat(bool bSet, DWORD dwMilliseconds);
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -