123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- #ifndef _BTNST_H
- #define _BTNST_H
- #define BTNST_USE_BCMENU
- #include "BCMenu.h"
- #define BTNST_USE_SOUND
- #if _MSC_VER >= 1000
- #pragma once
- #endif
- #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
- #ifndef BTNST_INVALIDALIGN
- #define BTNST_INVALIDALIGN 4
- #endif
- #ifndef BTNST_BADPARAM
- #define BTNST_BADPARAM 5
- #endif
- #ifndef BTNST_INVALIDPRESSEDSTYLE
- #define BTNST_INVALIDPRESSEDSTYLE 6
- #endif
- #ifndef BTNST_AUTO_GRAY
- #define BTNST_AUTO_GRAY (HICON)(0xffffffff - 1L)
- #endif
- #ifndef BTNST_AUTO_DARKER
- #define BTNST_AUTO_DARKER (HICON)(0xffffffff - 2L)
- #endif
- class CButtonST : public CButton
- {
- public:
- CButtonST();
- ~CButtonST();
- enum { ST_ALIGN_HORIZ = 0,
- ST_ALIGN_VERT,
- ST_ALIGN_HORIZ_RIGHT,
- ST_ALIGN_OVERLAP
- };
- enum { BTNST_COLOR_BK_IN = 0,
- BTNST_COLOR_FG_IN,
- BTNST_COLOR_BK_OUT,
- BTNST_COLOR_FG_OUT,
- BTNST_COLOR_BK_FOCUS,
- BTNST_COLOR_FG_FOCUS,
- BTNST_MAX_COLORS
- };
- enum { BTNST_PRESSED_LEFTRIGHT = 0,
- BTNST_PRESSED_TOPBOTTOM
- };
-
-
- public:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- protected:
- virtual void PreSubclassWindow();
-
- public:
- DWORD SetDefaultColors(BOOL bRepaint = TRUE);
- DWORD SetColor(BYTE byColorIndex, COLORREF crColor, BOOL bRepaint = TRUE);
- DWORD GetColor(BYTE byColorIndex, COLORREF* crpColor);
- DWORD OffsetColor(BYTE byColorIndex, short shOffset, BOOL bRepaint = TRUE);
- DWORD SetCheck(int nCheck, BOOL bRepaint = TRUE);
- int GetCheck();
- DWORD SetURL(LPCTSTR lpszURL = NULL);
- void DrawTransparent(BOOL bRepaint = FALSE);
- DWORD SetBk(CDC* pDC);
- BOOL GetDefault();
- DWORD SetAlwaysTrack(BOOL bAlwaysTrack = TRUE);
- void SetTooltipText(int nText, BOOL bActivate = TRUE);
- void SetTooltipText(LPCTSTR lpszText, BOOL bActivate = TRUE);
- void ActivateTooltip(BOOL bEnable = TRUE);
- DWORD EnableBalloonTooltip();
- DWORD SetBtnCursor(int nCursorId = NULL, BOOL bRepaint = TRUE);
- DWORD SetFlat(BOOL bFlat = TRUE, BOOL bRepaint = TRUE);
- DWORD SetAlign(BYTE byAlign, BOOL bRepaint = TRUE);
- DWORD SetPressedStyle(BYTE byStyle, BOOL bRepaint = TRUE);
- DWORD DrawBorder(BOOL bDrawBorder = TRUE, BOOL bRepaint = TRUE);
- DWORD DrawFlatFocus(BOOL bDrawFlatFocus, BOOL bRepaint = TRUE);
- DWORD SetIcon(int nIconIn, int nCxDesiredIn, int nCyDesiredIn, int nIconOut = NULL, int nCxDesiredOut = 0, int nCyDesiredOut = 0);
- DWORD SetIcon(int nIconIn, int nIconOut = NULL);
- DWORD SetIcon(HICON hIconIn, HICON hIconOut = NULL);
- DWORD SetBitmaps(int nBitmapIn, COLORREF crTransColorIn, int nBitmapOut = NULL, COLORREF crTransColorOut = 0);
- DWORD SetBitmaps(HBITMAP hBitmapIn, COLORREF crTransColorIn, HBITMAP hBitmapOut = NULL, COLORREF crTransColorOut = 0);
- void SizeToContent();
- #ifdef BTNST_USE_BCMENU
- DWORD SetMenu(UINT nMenu, HWND hParentWnd, BOOL bWinXPStyle = TRUE, UINT nToolbarID = NULL, CSize sizeToolbarIcon = CSize(16, 16), COLORREF crToolbarBk = RGB(255, 0, 255), BOOL bRepaint = TRUE);
- #else
- DWORD SetMenu(UINT nMenu, HWND hParentWnd, BOOL bRepaint = TRUE);
- #endif
- DWORD SetMenuCallback(HWND hWnd, UINT nMessage, LPARAM lParam = 0);
- #ifdef BTNST_USE_SOUND
- DWORD SetSound(LPCTSTR lpszSound, HMODULE hMod = NULL, BOOL bPlayOnClick = FALSE, BOOL bPlayAsync = TRUE);
- #endif
- static short GetVersionI() {return 39;}
- static LPCTSTR GetVersionC() {return (LPCTSTR)_T("3.9");}
- BOOL m_bShowDisabledBitmap;
- POINT m_ptImageOrg;
- POINT m_ptPressedOffset;
- protected:
-
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg void OnKillFocus(CWnd* pNewWnd);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnSysColorChange();
- afx_msg BOOL OnClicked();
- afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
- afx_msg void OnEnable(BOOL bEnable);
- afx_msg void OnCancelMode();
- afx_msg UINT OnGetDlgCode();
-
- #ifdef BTNST_USE_BCMENU
- afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
- afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
- #endif
- afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
- HICON CreateGrayscaleIcon(HICON hIcon);
- HICON CreateDarkerIcon(HICON hIcon);
- HBITMAP CreateGrayscaleBitmap(HBITMAP hBitmap, DWORD dwWidth, DWORD dwHeight, COLORREF crTrans);
- HBITMAP CreateDarkerBitmap(HBITMAP hBitmap, DWORD dwWidth, DWORD dwHeight, COLORREF crTrans);
- COLORREF DarkenColor(COLORREF crColor, double dFactor);
- virtual DWORD OnDrawBackground(CDC* pDC, CRect* pRect);
- virtual DWORD OnDrawBorder(CDC* pDC, CRect* pRect);
- BOOL m_bIsFlat;
- BOOL m_bMouseOnButton;
- BOOL m_bDrawTransparent;
- BOOL m_bIsPressed;
- BOOL m_bIsFocused;
- BOOL m_bIsDisabled;
- BOOL m_bIsDefault;
- BOOL m_bIsCheckBox;
- BYTE m_byAlign;
- BOOL m_bDrawBorder;
- BOOL m_bDrawFlatFocus;
- COLORREF m_crColors[BTNST_MAX_COLORS];
- HWND m_hParentWndMenu;
- BOOL m_bMenuDisplayed;
- #ifdef BTNST_USE_BCMENU
- BCMenu m_menuPopup;
- #else
- HMENU m_hMenu;
- #endif
- private:
- LRESULT OnSetCheck(WPARAM wParam, LPARAM lParam);
- LRESULT OnGetCheck(WPARAM wParam, LPARAM lParam);
- LRESULT OnSetStyle(WPARAM wParam, LPARAM lParam);
- LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
- void CancelHover();
- void FreeResources(BOOL bCheckForNULL = TRUE);
- void PrepareImageRect(BOOL bHasTitle, RECT* rpItem, CRect* rpTitle, BOOL bIsPressed, DWORD dwWidth, DWORD dwHeight, CRect* rpImage);
- HBITMAP CreateBitmapMask(HBITMAP hSourceBitmap, DWORD dwWidth, DWORD dwHeight, COLORREF crTransColor);
- virtual void DrawTheIcon(CDC* pDC, BOOL bHasTitle, RECT* rpItem, CRect* rpCaption, BOOL bIsPressed, BOOL bIsDisabled);
- virtual void DrawTheBitmap(CDC* pDC, BOOL bHasTitle, RECT* rpItem, CRect* rpCaption, BOOL bIsPressed, BOOL bIsDisabled);
- virtual void DrawTheText(CDC* pDC, LPCTSTR lpszText, RECT* rpItem, CRect* rpCaption, BOOL bIsPressed, BOOL bIsDisabled);
- void PaintBk(CDC* pDC);
- void InitToolTip();
- HCURSOR m_hCursor;
- CToolTipCtrl m_ToolTip;
- CDC m_dcBk;
- CBitmap m_bmpBk;
- CBitmap* m_pbmpOldBk;
- BOOL m_bAlwaysTrack;
- int m_nCheck;
- UINT m_nTypeStyle;
- DWORD m_dwToolTipStyle;
- TCHAR m_szURL[_MAX_PATH];
- #pragma pack(1)
- typedef struct _STRUCT_ICONS
- {
- HICON hIcon;
- DWORD dwWidth;
- DWORD dwHeight;
- } STRUCT_ICONS;
- #pragma pack()
- #pragma pack(1)
- typedef struct _STRUCT_BITMAPS
- {
- HBITMAP hBitmap;
- DWORD dwWidth;
- DWORD dwHeight;
- HBITMAP hMask;
- COLORREF crTransparent;
- } STRUCT_BITMAPS;
- #pragma pack()
- #pragma pack(1)
- typedef struct _STRUCT_CALLBACK
- {
- HWND hWnd;
- UINT nMessage;
- WPARAM wParam;
- LPARAM lParam;
- } STRUCT_CALLBACK;
- #pragma pack()
- STRUCT_ICONS m_csIcons[2];
- STRUCT_BITMAPS m_csBitmaps[2];
- STRUCT_CALLBACK m_csCallbacks;
- #ifdef BTNST_USE_SOUND
- #pragma pack(1)
- typedef struct _STRUCT_SOUND
- {
- TCHAR szSound[_MAX_PATH];
- LPCTSTR lpszSound;
- HMODULE hMod;
- DWORD dwFlags;
- } STRUCT_SOUND;
- #pragma pack()
- STRUCT_SOUND m_csSounds[2];
- #endif
- DECLARE_MESSAGE_MAP()
- };
- #endif
|