www.pudn.com > News Search3.01.rar > BackSetDlg.cpp


// BackSetDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "NewSearch.h" 
#include "BackSetDlg.h" 
 
#include "MainFrm.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CBackSetDlg dialog 
 
 
CBackSetDlg::CBackSetDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CBackSetDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CBackSetDlg) 
	//}}AFX_DATA_INIT 
} 
 
 
void CBackSetDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CBackSetDlg) 
	DDX_Control(pDX, IDC_CHECK_REBAR, m_cRebar); 
	DDX_Control(pDX, IDC_EDIT_REBAR, m_eRebar); 
	DDX_Control(pDX, IDC_BUTTON_REBAR, m_bRebar); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CBackSetDlg, CDialog) 
	//{{AFX_MSG_MAP(CBackSetDlg) 
	ON_BN_CLICKED(IDC_CHECK_REBAR, OnCheckRebar) 
	ON_BN_CLICKED(IDC_BUTTON_REBAR, OnButtonRebar) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CBackSetDlg message handlers 
 
void CBackSetDlg::OnCheckRebar()  
{ 
	// TODO: Add your control notification handler code here 
	BOOL m_Enable = m_cRebar.GetCheck() == 1 ? TRUE : FALSE; 
	m_eRebar.EnableWindow(m_Enable); 
	m_bRebar.EnableWindow(m_Enable); 
} 
 
void CBackSetDlg::OnButtonRebar()  
{ 
	// TODO: Add your control notification handler code here 
	CString strName; 
	strName = GetSelectedBmp(); 
	if(!strName.IsEmpty()) 
		m_eRebar.SetWindowText(strName); 
} 
 
CString CBackSetDlg::GetSelectedBmp() 
{ 
	CString strPathName,strFilter; 
	strFilter.LoadString(IDS_FILE_TYPE); 
	CFileDialog fdlg(TRUE,_T("bmp"),NULL, 
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter); 
	fdlg.m_ofn.lpstrInitialDir = BACK_IMAGE_PATH; 
	if(fdlg.DoModal() == IDOK) 
		strPathName = fdlg.GetPathName(); 
 
	return strPathName; 
} 
 
BOOL CBackSetDlg::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	SetInitStatus(); 
 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CBackSetDlg::SetInitStatus() 
{ 
	CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd(); 
	ASSERT(pFrame != NULL); 
 
	m_strRebarName = pFrame->m_strRebarImg; 
	m_chkRebar = pFrame->m_bRebarImg; 
 
	if(!m_strRebarName.IsEmpty()) m_eRebar.SetWindowText(m_strRebarName); 
	m_cRebar.SetCheck(m_chkRebar); 
	 
	BOOL m_Enable = m_chkRebar == 1 ? TRUE : FALSE; 
	m_eRebar.EnableWindow(m_Enable); 
	m_bRebar.EnableWindow(m_Enable); 
} 
 
void CBackSetDlg::OnOK()  
{ 
	// TODO: Add extra validation here 
	CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd(); 
	ASSERT(pFrame != NULL); 
 
	m_chkRebar = m_cRebar.GetCheck(); 
	if(m_chkRebar) m_eRebar.GetWindowText(m_strRebarName); 
 
	pFrame->m_strRebarImg = m_strRebarName; 
	pFrame->m_bRebarImg = m_chkRebar; 
	 
	CDialog::OnOK(); 
}