ColourPopup.h
上传用户:cn05999
上传日期:2020-06-29
资源大小:84k
文件大小:3k
源码类别:

Static控件

开发平台:

Visual C++

  1. #if !defined(AFX_COLOURPOPUP_H__48E80B39_FD73_4BB8_9E4B_7B5ADCAB8416__INCLUDED_)
  2. #define AFX_COLOURPOPUP_H__48E80B39_FD73_4BB8_9E4B_7B5ADCAB8416__INCLUDED_
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. // ColourPopup.h : header file
  7. //
  8. #define CPN_SELCHANGE WM_USER+1001
  9. #define CPN_SELENDOK  WM_USER+1004
  10. #define CPN_SELENDCANCEL WM_USER+1005
  11. class CColourPicker;
  12. typedef struct {
  13. COLORREF crColour;
  14. TCHAR* szName;
  15. }ColourTableEntry;
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CColourPopup window
  18. class CColourPopup : public CWnd
  19. {
  20. // Construction
  21. public:
  22. CColourPopup();
  23. // Attributes
  24. public:
  25. // Operations
  26. public:
  27. COLORREF GetColour(int row,int col)
  28. {
  29. return m_crColours[row*m_nNumColumns+col].crColour;
  30. }
  31. LPCTSTR GetColourName(int row,int col)
  32. {
  33. return m_crColours[row*m_nNumColumns+col].szName;
  34. }
  35. // Overrides
  36. // ClassWizard generated virtual function overrides
  37. //{{AFX_VIRTUAL(CColourPopup)
  38. public:
  39. virtual BOOL PreTranslateMessage(MSG* pMsg);
  40. //}}AFX_VIRTUAL
  41. // Implementation
  42. public:
  43. CColourPopup(CPoint p,COLORREF crColour,CWnd* pParentWnd,UINT nID,LPCTSTR szCustomText=NULL);
  44. // Generated message map functions
  45. protected:
  46. virtual ~CColourPopup();
  47. void FindCellFromColour(COLORREF crColour);
  48. BOOL Create(CPoint p,COLORREF crColour, CWnd* pParentWnd,UINT nID,LPCTSTR szCustomText);
  49. void CreateToolTips();
  50. void Initialize();
  51. void ChangeSelection(int row,int col);
  52. void EndSelection(int nMessage);
  53. void DrawCell(CDC *pDC,int row,int col);
  54. BOOL GetCellRect(int row,int col,const LPRECT &rect);
  55. void SetWindowSize();
  56. static ColourTableEntry m_crColours[];
  57. int m_nNumColours;
  58. int m_nNumColumns,m_nNumRows;
  59. int m_nBoxSize,m_nMargin;
  60. int m_nCurrentRow,m_nCurrentCol;
  61. int m_nChosenColourRow,m_nChosenColourCol;
  62. BOOL m_bShowCustom;
  63. CString m_strCustomText;
  64. CRect m_TextRect,m_WindowRect;
  65. CFont m_Font;
  66. CPalette m_Palette;
  67. COLORREF m_crInitialColour,m_crColour;
  68. //使用CToolTimCtrl控件
  69. CToolTipCtrl m_ToolTip;
  70. CWnd* m_pParent;
  71. //{{AFX_MSG(CColourPopup)
  72. afx_msg void OnPaint();
  73. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  74. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  75. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  76. afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
  77. afx_msg BOOL OnQueryNewPalette();
  78. afx_msg void OnNcDestroy();
  79. //}}AFX_MSG
  80. DECLARE_MESSAGE_MAP()
  81. };
  82. /////////////////////////////////////////////////////////////////////////////
  83. //{{AFX_INSERT_LOCATION}}
  84. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  85. #endif // !defined(AFX_COLOURPOPUP_H__48E80B39_FD73_4BB8_9E4B_7B5ADCAB8416__INCLUDED_)