// ★コメント未記入
// PlugInGridDlg.cpp : インプリメンテーション ファイル
//

#include "stdafx.h"
#include "shitarabian.h"
#include "PlugInGridDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CPlugInGridDlg ダイアログ


CPlugInGridDlg::CPlugInGridDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPlugInGridDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPlugInGridDlg)
	m_uiWidth = 0;
	m_uiHeight = 0;
	m_bEnable = FALSE;
	//}}AFX_DATA_INIT


	m_colGrid = RGB(0,0,0);
}


void CPlugInGridDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPlugInGridDlg)
	DDX_Control(pDX, IDC_GRID_COLOR, m_ctrlColor);
	DDX_Text(pDX, IDC_XGRID, m_uiWidth);
	DDV_MinMaxUInt(pDX, m_uiWidth, 1, 1000);
	DDX_Text(pDX, IDC_YGRID, m_uiHeight);
	DDV_MinMaxUInt(pDX, m_uiHeight, 1, 1000);
	DDX_Check(pDX, IDC_GRID_ENABLE, m_bEnable);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPlugInGridDlg, CDialog)
	//{{AFX_MSG_MAP(CPlugInGridDlg)
	ON_WM_SHOWWINDOW()
	ON_WM_CTLCOLOR()
	ON_BN_CLICKED(IDC_GRID_COLOR, OnGridColor)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPlugInGridDlg メッセージ ハンドラ

void CPlugInGridDlg::OnOK() 
{
	UpdateData( TRUE );
	CDialog::OnOK();
}

void CPlugInGridDlg::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	UpdateData( FALSE );
}

void CPlugInGridDlg::OnGridColor() 
{
	CColorDialog	dlg;
//	dlg.SetCurrentColor( m_colGrid );
	if ( IDOK == dlg.DoModal() )
	{
		m_colGrid = dlg.GetColor();
	}
	RedrawWindow();
}

HBRUSH CPlugInGridDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	if ( pWnd == &m_ctrlColor )
	{
		static CBrush brush;
		brush.DeleteObject();
		brush.CreateSolidBrush( m_colGrid );
		return (HBRUSH)(brush.m_hObject);
	}
	return hbr;
}


void CPlugInGridDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	OnGridColor();

	CDialog::OnLButtonDown(nFlags, point);
}
