00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _BTNST_H
00039 #define _BTNST_H
00040
00041
00042
00043
00044
00045
00046 #define BTNST_USE_SOUND
00047
00048 #if _MSC_VER >= 1000
00049 #pragma once
00050 #endif // _MSC_VER >= 1000
00051
00052
00053 #ifndef BTNST_OK
00054 #define BTNST_OK 0
00055 #endif
00056 #ifndef BTNST_INVALIDRESOURCE
00057 #define BTNST_INVALIDRESOURCE 1
00058 #endif
00059 #ifndef BTNST_FAILEDMASK
00060 #define BTNST_FAILEDMASK 2
00061 #endif
00062 #ifndef BTNST_INVALIDINDEX
00063 #define BTNST_INVALIDINDEX 3
00064 #endif
00065 #ifndef BTNST_INVALIDALIGN
00066 #define BTNST_INVALIDALIGN 4
00067 #endif
00068 #ifndef BTNST_BADPARAM
00069 #define BTNST_BADPARAM 5
00070 #endif
00071 #ifndef BTNST_INVALIDPRESSEDSTYLE
00072 #define BTNST_INVALIDPRESSEDSTYLE 6
00073 #endif
00074
00075
00076 #ifndef BTNST_AUTO_GRAY
00077 #define BTNST_AUTO_GRAY (HICON)(0xffffffff - 1L)
00078 #endif
00079
00080 class CButtonST : public CButton
00081 {
00082 public:
00083 CButtonST();
00084 ~CButtonST();
00085
00086 enum { ST_ALIGN_HORIZ = 0,
00087 ST_ALIGN_VERT,
00088 ST_ALIGN_HORIZ_RIGHT,
00089 ST_ALIGN_OVERLAP
00090 };
00091
00092 enum { BTNST_COLOR_BK_IN = 0,
00093 BTNST_COLOR_FG_IN,
00094 BTNST_COLOR_BK_OUT,
00095 BTNST_COLOR_FG_OUT,
00096 BTNST_COLOR_BK_FOCUS,
00097 BTNST_COLOR_FG_FOCUS,
00098
00099 BTNST_MAX_COLORS
00100 };
00101
00102 enum { BTNST_PRESSED_LEFTRIGHT = 0,
00103 BTNST_PRESSED_TOPBOTTOM
00104 };
00105
00106
00107
00108 public:
00109 virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
00110 virtual BOOL PreTranslateMessage(MSG* pMsg);
00111 protected:
00112 virtual void PreSubclassWindow();
00113
00114
00115 public:
00116 DWORD SetDefaultColors(BOOL bRepaint = TRUE);
00117 DWORD SetColor(BYTE byColorIndex, COLORREF crColor, BOOL bRepaint = TRUE);
00118 DWORD GetColor(BYTE byColorIndex, COLORREF* crpColor);
00119 DWORD OffsetColor(BYTE byColorIndex, short shOffset, BOOL bRepaint = TRUE);
00120
00121 DWORD SetCheck(int nCheck, BOOL bRepaint = TRUE);
00122 int GetCheck();
00123
00124 DWORD SetURL(LPCTSTR lpszURL = NULL);
00125 void DrawTransparent(BOOL bRepaint = FALSE);
00126 DWORD SetBk(CDC* pDC);
00127
00128 BOOL GetDefault();
00129 DWORD SetAlwaysTrack(BOOL bAlwaysTrack = TRUE);
00130
00131 void SetTooltipText(int nText, BOOL bActivate = TRUE);
00132 void SetTooltipText(LPCTSTR lpszText, BOOL bActivate = TRUE);
00133 void ActivateTooltip(BOOL bEnable = TRUE);
00134 DWORD EnableBalloonTooltip();
00135
00136 DWORD SetBtnCursor(int nCursorId = NULL, BOOL bRepaint = TRUE);
00137
00138 DWORD SetFlat(BOOL bFlat = TRUE, BOOL bRepaint = TRUE);
00139 DWORD SetAlign(BYTE byAlign, BOOL bRepaint = TRUE);
00140 DWORD SetPressedStyle(BYTE byStyle, BOOL bRepaint = TRUE);
00141
00142 DWORD DrawBorder(BOOL bDrawBorder = TRUE, BOOL bRepaint = TRUE);
00143 DWORD DrawFlatFocus(BOOL bDrawFlatFocus, BOOL bRepaint = TRUE);
00144
00145 DWORD SetIcon(int nIconIn, int nIconOut = NULL);
00146 DWORD SetIcon(HICON hIconIn, HICON hIconOut = NULL);
00147
00148 DWORD SetBitmaps(int nBitmapIn, COLORREF crTransColorIn, int nBitmapOut = NULL, COLORREF crTransColorOut = 0);
00149 DWORD SetBitmaps(HBITMAP hBitmapIn, COLORREF crTransColorIn, HBITMAP hBitmapOut = NULL, COLORREF crTransColorOut = 0);
00150
00151 void SizeToContent();
00152
00153 #ifdef BTNST_USE_BCMENU
00154 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);
00155 #else
00156 DWORD SetMenu(UINT nMenu, HWND hParentWnd, BOOL bRepaint = TRUE);
00157 #endif
00158 DWORD SetMenuCallback(HWND hWnd, UINT nMessage, LPARAM lParam = 0);
00159
00160 #ifdef BTNST_USE_SOUND
00161 DWORD SetSound(LPCTSTR lpszSound, HMODULE hMod = NULL, BOOL bPlayOnClick = FALSE, BOOL bPlayAsync = TRUE);
00162 #endif
00163
00164 static short GetVersionI() {return 38;}
00165 static LPCTSTR GetVersionC() {return (LPCTSTR)_T("3.8");}
00166
00167 BOOL m_bShowDisabledBitmap;
00168 POINT m_ptImageOrg;
00169 POINT m_ptPressedOffset;
00170
00171 protected:
00172
00173 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
00174 afx_msg void OnKillFocus(CWnd* pNewWnd);
00175 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00176 afx_msg void OnSysColorChange();
00177 afx_msg BOOL OnClicked();
00178 afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
00179 afx_msg void OnEnable(BOOL bEnable);
00180 afx_msg void OnCancelMode();
00181 afx_msg UINT OnGetDlgCode();
00182
00183
00184 #ifdef BTNST_USE_BCMENU
00185 afx_msg LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu);
00186 afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
00187 #endif
00188
00189 afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
00190 HICON CreateGrayscaleIcon(HICON hIcon);
00191 virtual DWORD OnDrawBackground(CDC* pDC, CRect* pRect);
00192 virtual DWORD OnDrawBorder(CDC* pDC, CRect* pRect);
00193
00194 BOOL m_bIsFlat;
00195 BOOL m_bMouseOnButton;
00196 BOOL m_bDrawTransparent;
00197 BOOL m_bIsPressed;
00198 BOOL m_bIsFocused;
00199 BOOL m_bIsDisabled;
00200 BOOL m_bIsDefault;
00201 BOOL m_bIsCheckBox;
00202 BYTE m_byAlign;
00203 BOOL m_bDrawBorder;
00204 BOOL m_bDrawFlatFocus;
00205 COLORREF m_crColors[BTNST_MAX_COLORS];
00206 HWND m_hParentWndMenu;
00207 BOOL m_bMenuDisplayed;
00208
00209 #ifdef BTNST_USE_BCMENU
00210 BCMenu m_menuPopup;
00211 #else
00212 HMENU m_hMenu;
00213 #endif
00214
00215 private:
00216 LRESULT OnSetCheck(WPARAM wParam, LPARAM lParam);
00217 LRESULT OnGetCheck(WPARAM wParam, LPARAM lParam);
00218 LRESULT OnSetStyle(WPARAM wParam, LPARAM lParam);
00219 LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
00220
00221 void CancelHover();
00222 void FreeResources(BOOL bCheckForNULL = TRUE);
00223 void PrepareImageRect(BOOL bHasTitle, RECT* rpItem, CRect* rpTitle, BOOL bIsPressed, DWORD dwWidth, DWORD dwHeight, CRect* rpImage);
00224 HBITMAP CreateBitmapMask(HBITMAP hSourceBitmap, DWORD dwWidth, DWORD dwHeight, COLORREF crTransColor);
00225 virtual void DrawTheIcon(CDC* pDC, BOOL bHasTitle, RECT* rpItem, CRect* rpCaption, BOOL bIsPressed, BOOL bIsDisabled);
00226 virtual void DrawTheBitmap(CDC* pDC, BOOL bHasTitle, RECT* rpItem, CRect* rpCaption, BOOL bIsPressed, BOOL bIsDisabled);
00227 virtual void DrawTheText(CDC* pDC, LPCTSTR lpszText, RECT* rpItem, CRect* rpCaption, BOOL bIsPressed, BOOL bIsDisabled);
00228 void PaintBk(CDC* pDC);
00229
00230 void InitToolTip();
00231
00232 HCURSOR m_hCursor;
00233 CToolTipCtrl m_ToolTip;
00234
00235 CDC m_dcBk;
00236 CBitmap m_bmpBk;
00237 CBitmap* m_pbmpOldBk;
00238
00239 BOOL m_bAlwaysTrack;
00240 int m_nCheck;
00241 UINT m_nTypeStyle;
00242 DWORD m_dwToolTipStyle;
00243
00244 TCHAR m_szURL[_MAX_PATH];
00245
00246 #pragma pack(1)
00247 typedef struct _STRUCT_ICONS
00248 {
00249 HICON hIcon;
00250 DWORD dwWidth;
00251 DWORD dwHeight;
00252 } STRUCT_ICONS;
00253 #pragma pack()
00254
00255 #pragma pack(1)
00256 typedef struct _STRUCT_BITMAPS
00257 {
00258 HBITMAP hBitmap;
00259 DWORD dwWidth;
00260 DWORD dwHeight;
00261 HBITMAP hMask;
00262 COLORREF crTransparent;
00263 } STRUCT_BITMAPS;
00264 #pragma pack()
00265
00266 #pragma pack(1)
00267 typedef struct _STRUCT_CALLBACK
00268 {
00269 HWND hWnd;
00270 UINT nMessage;
00271 WPARAM wParam;
00272 LPARAM lParam;
00273 } STRUCT_CALLBACK;
00274 #pragma pack()
00275
00276 STRUCT_ICONS m_csIcons[2];
00277 STRUCT_BITMAPS m_csBitmaps[2];
00278
00279 STRUCT_CALLBACK m_csCallbacks;
00280
00281 #ifdef BTNST_USE_SOUND
00282 #pragma pack(1)
00283 typedef struct _STRUCT_SOUND
00284 {
00285 TCHAR szSound[_MAX_PATH];
00286 LPCTSTR lpszSound;
00287 HMODULE hMod;
00288 DWORD dwFlags;
00289 } STRUCT_SOUND;
00290 #pragma pack()
00291
00292 STRUCT_SOUND m_csSounds[2];
00293 #endif
00294
00295 DECLARE_MESSAGE_MAP()
00296 };
00297
00298
00299
00300
00301 #endif