00001
00002
00003
00004 #include "stdafx.h"
00005 #include "MapEditor.h"
00006 #include "ColorButton.h"
00007
00008
00009
00010
00011 IMPLEMENT_DYNAMIC(CColorButton, CButton)
00012 CColorButton::CColorButton()
00013 {
00014 m_Color = RGB( 255, 255, 255 );
00015 }
00016
00017 CColorButton::~CColorButton()
00018 {
00019 }
00020
00021
00022 BEGIN_MESSAGE_MAP(CColorButton, CButton)
00023 ON_WM_PAINT()
00024 ON_CONTROL_REFLECT(BN_CLICKED, OnBnClicked)
00025 END_MESSAGE_MAP()
00026
00027
00028
00029
00030
00031 void CColorButton::OnPaint()
00032 {
00033
00034
00035
00036
00037 CButton::OnPaint();
00038
00039 CDC* pDC = GetDC();
00040 CBrush Brush( m_Color );
00041 RECT Rect;
00042
00043 GetClientRect( &Rect );
00044 Rect.left += 3;
00045 Rect.top += 3;
00046 Rect.right -= 3;
00047 Rect.bottom -= 3;
00048 pDC->FillRect( &Rect, &Brush );
00049
00050 ReleaseDC( pDC );
00051 }
00052
00053 void CColorButton::OnBnClicked()
00054 {
00055 CColorDialog ColorDlg( m_Color, CC_FULLOPEN, this );
00056 ColorDlg.DoModal();
00057 m_Color = ColorDlg.GetColor();
00058
00059 RedrawWindow();
00060 }
00061
00062 BOOL CColorButton::PreCreateWindow(CREATESTRUCT& cs)
00063 {
00064
00065
00066 return CButton::PreCreateWindow(cs);
00067 }