Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // MBUTTON.H
  4. //
  5. // Defines CMButton class; helper functions
  6. //
  7. // Copyright (c) Microsoft Corporation 1997
  8. //
  9. // 12/14/97 David Stewart / dstewart
  10. //
  11. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  12. #ifndef _MBUTTON_HEADER_
  13. #define _MBUTTON_HEADER_
  14. #include "windows.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. //extended multimedia button styles
  19. #define MBS_STANDARDLEFT 0x00000000L
  20. #define MBS_TOGGLELEFT 0x00000001L
  21. #define MBS_STANDARDRIGHT 0x00000002L
  22. #define MBS_DROPRIGHT 0x00000004L
  23. #define MBS_TOGGLERIGHT 0x00000008L
  24. #define MBS_SYSTEMTYPE 0x00000010L
  25. #define MBS_NOAUTODELETE 0x00000020L
  26. #define STANDARD_PIXELS_PER_INCH 96
  27. #define IS_DBCS_CHARSET( CharSet ) \
  28. ( ((CharSet) == SHIFTJIS_CHARSET) ? TRUE : \
  29. ((CharSet) == HANGEUL_CHARSET) ? TRUE : \
  30. ((CharSet) == CHINESEBIG5_CHARSET) ? TRUE : \
  31. ((CharSet) == GB2312_CHARSET) ? TRUE : \
  32. ((CharSet) == JOHAB_CHARSET) ? TRUE : FALSE \
  33. )
  34. //forward declaration of class
  35. class CMButton;
  36. //c-style helper functions
  37. BOOL InitMButtons(HINSTANCE hInst, HWND hwnd);
  38. void UninitMButtons();
  39. CMButton* GetMButtonFromID(HWND hwndParent, int nID);
  40. CMButton* GetMButtonFromHWND(HWND hwnd);
  41. class CMButton
  42. {
  43. public:
  44. friend CMButton* CreateMButton(TCHAR* szCaption,
  45. int nIconID,
  46. DWORD dwWindowStyle,
  47. DWORD dwMButtonStyle,
  48. int x,
  49. int y,
  50. int width,
  51. int height,
  52. HWND hwndParentOrSub,
  53. BOOL fSubExisting,
  54. int nID,
  55. int nToolTipID,
  56. HINSTANCE hInst);
  57. CMButton(); //constructor
  58. ~CMButton(); //destructor
  59. HWND GetHWND() {return m_hwnd;}
  60. int GetID() {return m_nID;}
  61. int GetToolTipID() {return m_nToolTipID;}
  62. void SetToolTipID(int nID) {m_nToolTipID = nID;}
  63. void SetText(TCHAR* szCaption);
  64. void SetIcon(int nIconID);
  65. void SetFont(HFONT hFont);
  66. void Draw(LPDRAWITEMSTRUCT lpdis);
  67. void PreDrawUpstate(int width, int height);
  68. BOOL MouseInButton() {return m_fMouseInButton;}
  69. BOOL GetMenuingState() {return m_fMenu;}
  70. void SetMenuingState(BOOL fMenuOn);
  71. private:
  72. //non-static privates
  73. HFONT m_hFont;
  74. int m_nID;
  75. int m_nToolTipID;
  76. HWND m_hwnd;
  77. BOOL m_fMouseInButton;
  78. DWORD m_dwStyle;
  79. WNDPROC m_fnOldButton;
  80. BOOL m_fRedraw;
  81. HINSTANCE m_hInst;
  82. int m_IconID;
  83. BOOL m_fMenu;
  84. BOOL m_fMenuingOff;
  85. int m_LastState;
  86. HANDLE m_hbmpUp;
  87. HANDLE m_hbmpDn;
  88. HANDLE m_hbmpHi;
  89. void DrawButtonBitmap(LPDRAWITEMSTRUCT lpdis, BOOL fDrawToScreen, RECT* pMidRect);
  90. private:
  91. //static stuff for all buttons
  92. static LRESULT CALLBACK ButtonProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
  93. };
  94. #ifdef __cplusplus
  95. };
  96. #endif
  97. #endif //_MBUTTON_HEADER_