// DLG_SelSheet.cpp : implementation file
//

#include "stdafx.h"
#include "corpsms.h"
#include "DLG_SelSheet.h"

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

/////////////////////////////////////////////////////////////////////////////
// DLG_SelSheet dialog


DLG_SelSheet::DLG_SelSheet(CWnd* pParent /*=NULL*/)
	: CDialog(DLG_SelSheet::IDD, pParent)
{
	//{{AFX_DATA_INIT(DLG_SelSheet)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_pSheet = NULL;
}


void DLG_SelSheet::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(DLG_SelSheet)
	DDX_Control(pDX, IDC_SELSHEET_LIST, m_wndList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(DLG_SelSheet, CDialog)
	//{{AFX_MSG_MAP(DLG_SelSheet)
	ON_NOTIFY(NM_DBLCLK, IDC_SELSHEET_LIST, OnDblclkSelsheetList)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// DLG_SelSheet message handlers

void DLG_SelSheet::OnDblclkSelsheetList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	*pResult = 0;
	OnOK();
}

BOOL DLG_SelSheet::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	//����ͼ���б�
	m_Image.Create( 4 , 18 , ILC_COLOR32|ILC_MASK , 5 ,  1);
	CBitmap bmp;
	//bmp.LoadBitmap( IDB_L_DY );
	m_Image.Add( &bmp , RGB(193,193,193) );             //����
	bmp.DeleteObject();
	//����ͼ���б�
	m_wndList.SetImageList(&m_Image,LVSIL_SMALL);
	//m_wndList.SetBkColor( RGB(237,238,188) );
	//m_wndList.SetTextBkColor( RGB(237,238,188) );

	m_wndList.SubClassWindow2();
	m_wndList.SetHeadings(_T("   ����������,200;"));
	m_wndList.SetGridLines(true);

	if ( m_pSheet )
	{
		for ( int i=0 ; i<m_pSheet->GetSize() ; i++ )
		{
			m_wndList.InsertItem(i,m_pSheet->GetAt(i),0);
		}
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void DLG_SelSheet::SetParam(CStringArray *pSheet)
{
	m_pSheet = pSheet;
}

void DLG_SelSheet::OnOK() 
{
	int iItem = m_wndList.GetFirstSelectedItem();
	if ( iItem<0 )
	{
		MessageBox( _T("�������б�ѡ����Ҫ�������ݵĹ�������") , _T("��ʾ") , MB_ICONINFORMATION );
		return ;
	}
	m_strTable = m_wndList.GetItemText(iItem,0);
	
	CDialog::OnOK();
}