ColourPicker.h
上传用户:yangzi5763
上传日期:2007-01-02
资源大小:239k
文件大小:4k
源码类别:

ActiveX/DCOM/ATL

开发平台:

Visual C++

  1. #if !defined(AFX_COLOURPICKER_H__D0B75901_9830_11D1_9C0F_00A0243D1382__INCLUDED_)
  2. #define AFX_COLOURPICKER_H__D0B75901_9830_11D1_9C0F_00A0243D1382__INCLUDED_
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif // _MSC_VER >= 1000
  6. // ColourPicker.h : header file
  7. //
  8. // Written by Chris Maunder (Chris.Maunder@cbr.clw.csiro.au)
  9. // Extended by Alexander Bischofberger (bischofb@informatik.tu-muenchen.de)
  10. // Copyright (c) 1998.
  11. //
  12. // This code may be used in compiled form in any way you desire. This
  13. // file may be redistributed unmodified by any means PROVIDING it is 
  14. // not sold for profit without the authors written consent, and 
  15. // providing that this notice and the authors name is included. If 
  16. // the source code in  this file is used in any commercial application 
  17. // then a simple email would be nice.
  18. //
  19. // This file is provided "as is" with no expressed or implied warranty.
  20. // The author accepts no liability if it causes any damage whatsoever.
  21. // It's free - so you get what you pay for.
  22. #include "ColourPopup.h"
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CColourPicker window
  25. void AFXAPI DDX_ColourPicker(CDataExchange *pDX, int nIDC, COLORREF& crColour);
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CColourPicker window
  28. #define CP_MODE_TEXT 1  // edit text colour
  29. #define CP_MODE_BK   2  // edit background colour (default)
  30. class CColourPicker : public CButton
  31. {
  32. friend class CControlsWnd_CColorComboBox;
  33. // Construction
  34. public:
  35.     CColourPicker();
  36.     DECLARE_DYNCREATE(CColourPicker);
  37. // Attributes
  38. public:
  39.     COLORREF GetColour();
  40.     void     SetColour(COLORREF crColour); 
  41.     void     SetDefaultText(LPCTSTR szDefaultText);
  42.     void     SetCustomText(LPCTSTR szCustomText);
  43.     void     SetTrackSelection(BOOL bTracking = TRUE)  { m_bTrackSelection = bTracking; }
  44.     BOOL     GetTrackSelection()                       { return m_bTrackSelection; }
  45.     void     SetSelectionMode(UINT nMode)              { m_nSelectionMode = nMode; }
  46.     UINT     GetSelectionMode()                        { return m_nSelectionMode; };
  47.     void     SetBkColour(COLORREF crColourBk);
  48.     COLORREF GetBkColour()                             { return m_crColourBk; }
  49.     
  50.     void     SetTextColour(COLORREF crColourText);
  51.     COLORREF GetTextColour()                           { return m_crColourText;}
  52. // Operations
  53. public:
  54. // Overrides
  55.     // ClassWizard generated virtual function overrides
  56.     //{{AFX_VIRTUAL(CColourPicker)
  57.     public:
  58.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  59.     protected:
  60.     virtual void PreSubclassWindow();
  61.     //}}AFX_VIRTUAL
  62. // Implementation
  63. public:
  64.     virtual ~CColourPicker();
  65. protected:
  66.     void SetWindowSize();
  67. // protected attributes
  68. protected:
  69.     BOOL     m_bActive,                // Is the dropdown active?
  70.              m_bTrackSelection;        // track colour changes?
  71.     COLORREF m_crColourBk;
  72.     COLORREF m_crColourText;
  73.     UINT     m_nSelectionMode;
  74.     CRect    m_ArrowRect;
  75.     CString  m_strDefaultText;
  76.     CString  m_strCustomText;
  77.     // Generated message map functions
  78. protected:
  79. CColourPopup* m_pWndColor;
  80.     //{{AFX_MSG(CColourPicker)
  81.     afx_msg BOOL OnClicked();
  82.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  83.     //}}AFX_MSG
  84.     afx_msg LONG OnSelEndOK(UINT lParam, LONG wParam);
  85.     afx_msg LONG OnSelEndCancel(UINT lParam, LONG wParam);
  86.     afx_msg LONG OnSelChange(UINT lParam, LONG wParam);
  87.     DECLARE_MESSAGE_MAP()
  88. };
  89. /////////////////////////////////////////////////////////////////////////////
  90. //{{AFX_INSERT_LOCATION}}
  91. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  92. #endif // !defined(AFX_COLOURPICKER_H__D0B75901_9830_11D1_9C0F_00A0243D1382__INCLUDED_)