www.pudn.com > Fax_Polling.rar > FirstDlg.cpp


// FirstDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "atrkfax.h" 
#include "FirstDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
//int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData); 
///////////////////////////////////////////////////////////////////////////// 
// CFirstDlg dialog 
 
 
CFirstDlg::CFirstDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CFirstDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CFirstDlg) 
	m_bHaveStartPage = FALSE; 
	m_strRecFile = _T(""); 
	m_strRecPath = _T(""); 
	m_strSendFile = _T(""); 
	m_strStartPage = _T(""); 
	m_strEndPage = _T(""); 
	//}}AFX_DATA_INIT 
} 
 
 
void CFirstDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CFirstDlg) 
	DDX_Control(pDX, IDC_1DLG_CMB_FAXCH, m_cmbFaxCh); 
	DDX_Check(pDX, IDC_CHECK_START_END, m_bHaveStartPage); 
	DDX_Text(pDX, IDC_EDIT_RECEIVE, m_strRecFile); 
	DDX_Text(pDX, IDC_EDIT_RECPATH, m_strRecPath); 
	DDX_Text(pDX, IDC_EDIT_SEND, m_strSendFile); 
	DDX_Text(pDX, IDC_EDIT_START, m_strStartPage); 
	DDX_Text(pDX, IDC_EDIT_END, m_strEndPage); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CFirstDlg, CDialog) 
	//{{AFX_MSG_MAP(CFirstDlg) 
	ON_BN_CLICKED(IDC_1DLG_SENDFILE_BTN, On1dlgSendfileBtn) 
	ON_BN_CLICKED(IDC_1DLG_RECFILE_BTN, On1dlgRecfileBtn) 
	ON_BN_CLICKED(IDC_1DLG_APPENDFILE_BTN, On1dlgAppendfileBtn) 
	ON_BN_CLICKED(IDC_CHECK_START_END, OnCheckStartEnd) 
	ON_EN_CHANGE(IDC_EDIT_RECEIVE, OnChangeEditReceive) 
	ON_EN_CHANGE(IDC_EDIT_START, OnChangeEditStart) 
	ON_EN_CHANGE(IDC_EDIT_END, OnChangeEditEnd) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CFirstDlg message handlers 
 
void CFirstDlg::On1dlgSendfileBtn()	 
//·¢ËÍÎļþÃû	 
{ 
	CFileDialog cf(1, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Fax File(*.tif)|*.tif|Tif File(*.fax)|*.fax|Tiff File(*.tiff)|*.tiff|All File(*.*)|*.*|",NULL); 
	char path[MAX_PATH]; 
	strcpy(path, szCurrentPath); 
	cf.m_ofn.lpstrInitialDir = path; 
 
	if(cf.DoModal() == IDOK) 
	{ 
		strcpy(m_strSendFile.GetBuffer(MAX_PATH), cf.GetFileName()); 
		strcpy(szSendPathFile, cf.GetPathName()); 
		UpdateData(FALSE); 
		m_strSendFile.ReleaseBuffer(-1); 
	}	 
} 
void CFirstDlg::On1dlgRecfileBtn()	 
//destination file path 
{ 
	char t[] = "please set destination file path"; 
	BROWSEINFO bi; 
 
	LPMALLOC pMalloc; 
	if(SUCCEEDED(SHGetMalloc(&pMalloc)))  
	{ 
		ZeroMemory(&bi,sizeof(bi)); 
		bi.hwndOwner		= NULL; 
		bi.pszDisplayName	= 0; 
		bi.lpszTitle		= t; 
		bi.pidlRoot			= 0; 
		bi.ulFlags			= BIF_RETURNONLYFSDIRS; 
		bi.lpfn				= BrowseCallbackProc; 
 
		LPITEMIDLIST pidl = SHBrowseForFolder(&bi); 
		if(pidl)  
		{ 
			if(SHGetPathFromIDList(pidl, m_strRecPath.GetBuffer(MAX_PATH)) )  
			{ 
				UpdateData(FALSE); 
			} 
			pMalloc->Free(pidl); 
			pMalloc->Release(); 
		} 
	} 
} 
BOOL CFirstDlg::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	bHaveAppend = FALSE; 
	bHaveStartPage = FALSE; 
	strcpy(szSendPathFile,""); 
	strcpy(szRecPathFile,""); 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
BOOL CFirstDlg::GetCurrentPath(LPSTR str) 
{ 
	strcpy(szCurrentPath, str); 
	return TRUE; 
} 
 
 
 
void CFirstDlg::On1dlgAppendfileBtn()  
{ 
 
} 
 
void CFirstDlg::OnCheckStartEnd()  
{ 
	UpdateData(); 
	bHaveStartPage = m_bHaveStartPage; 
	CWnd *p = GetDlgItem(IDC_EDIT_START); 
	p->EnableWindow(bHaveStartPage); 
	p = GetDlgItem(IDC_EDIT_END); 
	p->EnableWindow(bHaveStartPage); 
} 
 
void CFirstDlg::OnChangeEditReceive()  
{ 
	// TODO: If this is a RICHEDIT control, the control will not 
	// send this notification unless you override the CDialog::OnInitDialog() 
	// function and call CRichEditCtrl().SetEventMask() 
	// with the ENM_CHANGE flag ORed into the mask. 
	 
	// TODO: Add your control notification handler code here 
	UpdateData();	 
} 
void CFirstDlg::OnOK()  
{ 
	// TODO: Add extra validation here 
	 
	//CDialog::OnOK(); 
} 
 
void CFirstDlg::OnCancel()  
{ 
	// TODO: Add extra cleanup here 
	 
	//CDialog::OnCancel(); 
} 
 
void CFirstDlg::OnChangeEditStart()  
{ 
	// TODO: If this is a RICHEDIT control, the control will not 
	// send this notification unless you override the CDialog::OnInitDialog() 
	// function and call CRichEditCtrl().SetEventMask() 
	// with the ENM_CHANGE flag ORed into the mask. 
	 
	// TODO: Add your control notification handler code here 
	UpdateData(); 
	if(m_strStartPage.IsEmpty()) 
		nStartPage = 0; 
	else 
		nStartPage = atoi(m_strStartPage); 
} 
 
void CFirstDlg::OnChangeEditEnd()  
{ 
	// TODO: If this is a RICHEDIT control, the control will not 
	// send this notification unless you override the CDialog::OnInitDialog() 
	// function and call CRichEditCtrl().SetEventMask() 
	// with the ENM_CHANGE flag ORed into the mask. 
	 
	// TODO: Add your control notification handler code here 
	UpdateData(); 
	if(m_strEndPage.IsEmpty()) 
		nEndPage = 0; 
	else 
		nEndPage = atoi(m_strEndPage); 
}