home *** CD-ROM | disk | FTP | other *** search
/ ftp.funduc.com / 2014.08.ftp.funduc.com.tar / ftp.funduc.com / fshedcode-072212.zip / colorbtn.h < prev    next >
C/C++ Source or Header  |  2010-09-13  |  3KB  |  138 lines

  1.  
  2. /*************************************************************************
  3.  
  4. ColorBtn.h header file
  5.  
  6. CColorBtn: A control panel like color picker
  7.            by The Gremlin
  8.  
  9. Compatibility: Visual C++ 4.0 and up.
  10.  
  11. **************************************************************************/
  12.  
  13. #ifndef _COLORBTN_H_
  14. #define _COLORBTN_H_
  15.  
  16. // In order to ease use, these values have been hard coded in colorbtn.rc
  17. // This avoids the need for another header file.
  18. #include <afxdlgs.h>
  19. #include "resource.h"
  20.  
  21. // Utility class for the dialog
  22.  
  23. class CColorBtnDlg : public CDialog
  24. {
  25. // Construction
  26. public:
  27.     
  28.     static COLORREF colors[20];
  29.     static BYTE used[20];
  30.  
  31.     CButton *parent;
  32.     int colorindex;
  33.  
  34.     CColorBtnDlg(CWnd* pParent = NULL);   // standard constructor
  35.      
  36. // Dialog Data
  37.     //{{AFX_DATA(CColorBtnDlg)
  38.     enum { IDD = IDD_COLORBTN };
  39.         // NOTE: the ClassWizard will add data members here
  40.     //}}AFX_DATA
  41.  
  42. // Overrides
  43.     // ClassWizard generated virtual function overrides
  44.     //{{AFX_VIRTUAL(CColorBtnDlg)
  45.     protected:
  46.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  47.     //}}AFX_VIRTUAL
  48.  
  49. // Implementation
  50. protected:
  51.  
  52.     // Generated message map functions
  53.     //{{AFX_MSG(CColorBtnDlg)
  54.     virtual BOOL OnInitDialog();
  55.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  56.     afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
  57.     afx_msg void OnOther();
  58.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  59.     //}}AFX_MSG
  60.  
  61.     void OnColor(UINT id);    
  62.     void EndDialog( int nResult );
  63.  
  64.     DECLARE_MESSAGE_MAP()
  65.  
  66. };
  67.  
  68.  
  69.  
  70. class CColorBtn : public CButton
  71. {
  72. // Construction
  73. public:
  74.  
  75.     CColorBtn();
  76.  
  77.     // The selected color,set this variable to initialize the 
  78.     // button's color and read to see the results
  79.  
  80.     COLORREF currentcolor;
  81.  
  82.     // Use Serialize to store the color table in a file. Call at the document's Serialize()
  83.     
  84.     //static void Serialize( CArchive& ar );
  85.  
  86.     // If using Serialize, call Reset to reinitialize the color table at OnNewDocument()
  87.  
  88.     static void Reset();
  89.  
  90.     // Use Load and Store to save/restore the color table to/from the registry
  91.  
  92.     static BOOL Load();
  93.     static BOOL Store();
  94.       
  95.  
  96.  
  97. // Overrides
  98.     // ClassWizard generated virtual function overrides
  99.     //{{AFX_VIRTUAL(CColorBtn)
  100.     //}}AFX_VIRTUAL
  101.  
  102. // Implementation
  103. public:
  104.     virtual ~CColorBtn();
  105.  
  106.     // Generated message map functions
  107. protected:
  108.     //{{AFX_MSG(CColorBtn)
  109.     afx_msg void OnClicked();
  110.     //}}AFX_MSG
  111.  
  112.     void DrawItem(LPDRAWITEMSTRUCT);
  113.  
  114.     DECLARE_MESSAGE_MAP()
  115.  
  116. private:
  117.  
  118.     // A number of pens and brushes needed to paint the button
  119.  
  120.     CPen *oldpen;
  121.     CBrush *oldbrush;
  122.     CPen blackpen;
  123.     CPen dkgray;
  124.     CPen whitepen;
  125.     CBrush backbrush;
  126.     CBrush nullbrush;
  127.     CPen nullpen;
  128.     
  129.  
  130.  
  131.    CColorBtnDlg dlg;
  132. };
  133.  
  134.  
  135.  
  136.  
  137. #endif
  138.