home *** CD-ROM | disk | FTP | other *** search
/ ftp.funduc.com / 2014.08.ftp.funduc.com.tar / ftp.funduc.com / fshedcode102502.zip / colorbtn.h < prev    next >
C/C++ Source or Header  |  1999-06-27  |  3KB  |  141 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.     
  29.     static COLORREF colors[20];
  30.     static BYTE used[20];
  31.  
  32.     CButton *parent;
  33.     int colorindex;
  34.  
  35.     CColorBtnDlg(CWnd* pParent = NULL);   // standard constructor
  36.  
  37.      
  38. // Dialog Data
  39.     //{{AFX_DATA(CColorBtnDlg)
  40.     enum { IDD = IDD_COLORBTN };
  41.         // NOTE: the ClassWizard will add data members here
  42.     //}}AFX_DATA
  43.  
  44.  
  45. // Overrides
  46.     // ClassWizard generated virtual function overrides
  47.     //{{AFX_VIRTUAL(CColorBtnDlg)
  48.     protected:
  49.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  50.     //}}AFX_VIRTUAL
  51.  
  52. // Implementation
  53. protected:
  54.  
  55.     // Generated message map functions
  56.     //{{AFX_MSG(CColorBtnDlg)
  57.     virtual BOOL OnInitDialog();
  58.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  59.     afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
  60.     afx_msg void OnOther();
  61.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  62.     //}}AFX_MSG
  63.  
  64.     void OnColor(UINT id);    
  65.     void EndDialog( int nResult );
  66.  
  67.     DECLARE_MESSAGE_MAP()
  68.  
  69. };
  70.  
  71.  
  72.  
  73. class CColorBtn : public CButton
  74. {
  75. // Construction
  76. public:
  77.  
  78.     CColorBtn();
  79.  
  80.     // The selected color,set this variable to initialize the 
  81.     // button's color and read to see the results
  82.  
  83.     COLORREF currentcolor;
  84.  
  85.     // Use Serialize to store the color table in a file. Call at the document's Serialize()
  86.     
  87.     static void Serialize( CArchive& ar );
  88.  
  89.     // If using Serialize, call Reset to reinitialize the color table at OnNewDocument()
  90.  
  91.     static void Reset();
  92.  
  93.     // Use Load and Store to save/restore the color table to/from the registry
  94.  
  95.     static BOOL Load();
  96.     static BOOL Store();
  97.       
  98.  
  99.  
  100. // Overrides
  101.     // ClassWizard generated virtual function overrides
  102.     //{{AFX_VIRTUAL(CColorBtn)
  103.     //}}AFX_VIRTUAL
  104.  
  105. // Implementation
  106. public:
  107.     virtual ~CColorBtn();
  108.  
  109.     // Generated message map functions
  110. protected:
  111.     //{{AFX_MSG(CColorBtn)
  112.     afx_msg void OnClicked();
  113.     //}}AFX_MSG
  114.  
  115.     void DrawItem(LPDRAWITEMSTRUCT);
  116.  
  117.     DECLARE_MESSAGE_MAP()
  118.  
  119. private:
  120.  
  121.     // A number of pens and brushes needed to paint the button
  122.  
  123.     CPen *oldpen;
  124.     CBrush *oldbrush;
  125.     CPen blackpen;
  126.     CPen dkgray;
  127.     CPen whitepen;
  128.     CBrush backbrush;
  129.     CBrush nullbrush;
  130.     CPen nullpen;
  131.     
  132.  
  133.  
  134.    CColorBtnDlg dlg;
  135. };
  136.  
  137.  
  138.  
  139.  
  140. #endif
  141.