www.pudn.com > PhoneReaderSrc.rar > OptionDlg.cpp


// OptionDlg.cpp: implementation of the COptionDlg class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "OptionDlg.h" 
#include "List.h" 
#include "SelectColorDlg.h" 
#include  
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
COLORREF COptionDlg::m_crStandardColors[] =  
{	 
	RGB(0,0,0),  //dark 
	RGB(192,192,192),//light grey 
	RGB(128,128,128),//dark grey 
	RGB(255,255,255),//write 
	RGB(255,0,0),//red 
	RGB(255,255,0),//yellow 
	RGB(0,255,0),//green 
	RGB(0,0,255),//blue 
	RGB(255,0,255),//purple 
	RGB(0,255,255),//teal 
	RGB(128,0,0),//dark red 
	RGB(128,128,0),//dark yellow 
	RGB(0,128,0),//dark green 
	RGB(0,0,128),//dark blue 
	RGB(128,0,128),//dark purple 
	RGB(0,128,128),//dark teal	 
}; 
 
COptionDlg::COptionDlg() 
{ 
	m_ListNo = 0; 
} 
 
COptionDlg::~COptionDlg() 
{ 
 
} 
LRESULT COptionDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 
{ 
	g_hWndLast = m_hWnd; 
	LoadSHMenuBar(MAKEINTRESOURCE(IDR_OKMENU)); 
	SendMessage(m_hWndCB,WM_PAINT,0,0); 
	UINT ListID = IDC_CODETYPELIST; 
	UINT SpinID = IDC_CODETYPESPIN; 
	int SettingNum[6]; 
	SettingNum[0] = 1; 
	SettingNum[1] = 3; 
	SettingNum[2] = 4; 
	SettingNum[3] = 16; 
	SettingNum[4] = 16; 
	SettingNum[5] = 3;	 
 
	UINT SettingID = CODETYPE1_TXT; 
	CString SettingStr; 
 
	for (int i = 0; i < 6 ;i ++) 
	{	 
		m_ListBox[i].SubclassWindow(GetDlgItem (ListID)); 
		if (i == 4) 
			SettingID -= 16; 
 
		if ((i == 3 ) || (i == 4)) 
			m_ListBox[i].EnableRGBBorder(TRUE); 
		else 
			m_ListBox[i].EnableRGBBorder(FALSE); 
 
		for (int  j = 0 ; j < SettingNum[i] ; j++) 
		{ 
			SettingStr.LoadString(SettingID); 
			if ((i == 3) || (i == 4)) 
			{				 
				m_ListBox[i].AddItem(SettingStr,m_crStandardColors[j]); 
			} 
			else 
			{				 
				m_ListBox[i].AddItem(SettingStr); 
			} 
			SettingID ++; 
		}			 
		m_ListBox[i].SetCurSel(m_Setting[i]); 
 
		m_Spin[i].Attach(GetDlgItem(SpinID)); 
		DWORD dwStyle = m_Spin[i].GetStyle(); 
        dwStyle |= UDS_EXPANDABLE; 
		m_Spin[i].ModifyStyle(0,dwStyle); 
 
		ListID ++; 
		SpinID ++; 
	} 
 
	m_LastPosCheck.Attach(GetDlgItem(IDC_LASTPOSITION)); 
	m_LastPosCheck.SetCheck(m_Setting[6]); 
 
	m_ListBox[0].SetFocus(); 
	return 0; 
} 
LRESULT COptionDlg::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 
{	 
	g_hWndLast = NULL; 
	EndDialog(IDCANCEL);   
	return 0; 
} 
LRESULT COptionDlg::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 
{ 
	g_hWndLast = NULL; 
	for(int i = 0; i < 6 ; i++) 
	{ 
		m_Setting[i] = m_ListBox[i].GetCurSel(); 
	} 
	m_Setting[6] = m_LastPosCheck.GetCheck(); 
	EndDialog(IDOK);   
 
	return 0; 
} 
 
LRESULT COptionDlg::OnSetListNo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 
{ 
	m_ListNo = wID - IDC_CODETYPELIST; 
	UpdateWindow(); 
	return 0; 
} 
 
LRESULT COptionDlg::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 
{ 
	// TODO : Add Code for message handler. Call DefWindowProc if necessary. 
	CPaintDC dc(m_hWnd); 
	LOGFONT lf; 
	ZeroMemory(&lf,sizeof(lf)); 
	lstrcpy(lf.lfFaceName, _T("Arial")); 
	lf.lfWeight = 600; 
	lf.lfHeight = 15; 
	CFont NewFont; 
	NewFont.CreateFontIndirect(&lf); 
 
	UINT TitleID = IDC_TYPETITLE; 
	CStatic Titles; 
	for (int i = 0; i < 6 ; i++) 
	{ 
		Titles.Attach(GetDlgItem(TitleID + i));	 
		Titles.SetFont(NewFont.m_hFont); 
	} 
	NewFont.DeleteObject(); 
 
	return 0; 
} 
LRESULT COptionDlg::OnExpandItem(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) 
{ 
	// TODO : Add Code for control notification handler. 
	CSelectColorDlg ExpandDlg; 
	ExpandDlg.m_SelectItemNo = m_ListBox[m_ListNo].GetCurSel(); 
	CString ItemStr; 
	for (int i = 0 ; i < m_ListBox[m_ListNo].GetCount() ; i ++) 
	{ 
		m_ListBox[m_ListNo].GetText(i,ItemStr); 
		ExpandDlg.m_ListItem.Add((CString)ItemStr); 
	} 
	if ((m_ListNo == 3) || (m_ListNo == 4)) 
		ExpandDlg.m_ColorfulFlag = TRUE; 
	else 
		ExpandDlg.m_ColorfulFlag = FALSE; 
	TCHAR ExpandTitle[255]; 
	memset(ExpandTitle, 0 , sizeof(ExpandTitle)); 
	::GetWindowText(GetDlgItem(IDC_TYPETITLE + m_ListNo),ExpandTitle,255); 
	ExpandDlg.m_Title = ExpandTitle; 
	ExpandDlg.m_Title = ExpandDlg.m_Title.Left(ExpandDlg.m_Title.GetLength() - 1); 
	if (ExpandDlg.DoModal() == IDOK) 
	{ 
		m_ListBox[m_ListNo].SetCurSel(ExpandDlg.m_SelectItemNo); 
		UpdateWindow(); 
	} 
	return 1; 
}