BitmapMenu.h
上传用户:jbj_wl
上传日期:2007-01-02
资源大小:6k
文件大小:2k
源码类别:

菜单

开发平台:

Visual C++

  1. #ifndef __BITMAP_MENU_H__
  2. #define __BITMAP_MENU_H__
  3. class BMenuData
  4. {
  5. public:
  6. BMenuData();
  7. char menuText[32];
  8. int menuIconNormal;
  9. int menuIconSelected;
  10. int menuIconDisabled;
  11. UINT nID;
  12. };
  13. typedef enum {Normal,TextOnly} HIGHLIGHTSTYLE;
  14. class CBitmapMenu : public CMenu // Derived from CMenu
  15. {
  16. public:
  17. CBitmapMenu(CImageList* pList = NULL); 
  18. virtual ~CBitmapMenu();
  19. protected:
  20. CTypedPtrArray<CPtrArray, BMenuData*> m_MenuList; // Stores list of menu items 
  21. // When loading an owner-drawn menu using a Resource, CBitmapMenu must keep track of
  22. // the popup menu's that it creates. Warning, this list *MUST* be destroyed
  23. // last item first :)
  24. CTypedPtrArray<CPtrArray, CBitmapMenu*> m_SubMenus; // Stores list of sub-menus 
  25. public:
  26. virtual void DrawItem(LPDRAWITEMSTRUCT); // Draw an item
  27. virtual void MeasureItem(LPMEASUREITEMSTRUCT); // Measure an item
  28. void SetTextColor (COLORREF ); // Set the text color
  29. void SetBackColor (COLORREF); // Set background color
  30. void SetHighlightColor (COLORREF); // Set highlight Color
  31. void SetHighlightStyle (HIGHLIGHTSTYLE ); // Set Highlight style
  32. void SetHighlightTextColor (COLORREF); // Set Highlight text color
  33. void SetImageList(CImageList* pList);
  34. BOOL AppendMenu(UINT nFlags, UINT nID = 0,
  35. LPCTSTR lpstrText = NULL, 
  36. int nIconNormal = -1,
  37. int nIconSelected = -1,
  38. int nIconDisabled = -1); // Owner-Drawn Append 
  39. BOOL ModifyODMenu(LPCTSTR lpstrText,
  40. UINT nID = 0,
  41. int nIconNormal = -1,
  42. int nIconSelected = -1,
  43. int nIconDisabled = -1); // Owner-Drawn Modify 
  44. virtual BOOL LoadMenu(LPCTSTR lpszResourceName); // Load a menu
  45. virtual BOOL LoadMenu(int nResource); // ... 
  46. virtual BOOL DestroyMenu();
  47. protected:
  48. COLORREF m_clrBack;
  49. COLORREF m_clrText;
  50. COLORREF m_clrHilight;
  51. COLORREF m_clrHilightText;
  52. LOGFONT m_lf;
  53. CFont m_fontMenu;
  54. UINT m_iMenuHeight;
  55. BOOL m_bLBtnDown;
  56. CImageList* m_pList;
  57. UINT m_nIconX;
  58. UINT m_nIconY;
  59. CBrush m_brBackground,m_brSelect;
  60. CPen m_penBack;
  61. HIGHLIGHTSTYLE m_hilightStyle; 
  62. };
  63. #endif //__BITMAP_MENU_H__