📄 seconddlg.cpp
字号:
// SecondDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Fax_Event_VC.h"
#include "SecondDlg.h"
#include "Fax_Event_VCDLG.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSecondDlg dialog
CSecondDlg::CSecondDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSecondDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSecondDlg)
m_nHowFile = 0;
m_strCallNo = _T("");
m_strSendFile = _T("");
m_strEndPage = _T("");
m_strStartPage = _T("");
//}}AFX_DATA_INIT
nSCTNumber = 0;
nStartPage = 1;
nEndPage = -1;
memset(m_szSendPathFile, 0, sizeof(m_szSendPathFile));
memset(m_szSendPath, 0, sizeof(m_szSendPath));
}
void CSecondDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSecondDlg)
DDX_Control(pDX, IDC_LIST_SEND_FILE, m_ListBox);
DDX_Control(pDX, IDC_COMBO_2DLG_TRKCH, m_cmbTrkCh);
DDX_Control(pDX, IDC_COMBO_2DLG_FAXCH, m_cmbFaxCh);
DDX_Radio(pDX, IDC_RADIO_SINGLE_FILE, m_nHowFile);
DDX_Text(pDX, IDC_EDIT_SEND_PHONE_NO, m_strCallNo);
DDX_Text(pDX, IDC_EDIT_SEND_FILE, m_strSendFile);
DDX_Text(pDX, IDC_EDIT_END_PAGE, m_strEndPage);
DDX_Text(pDX, IDC_EDIT_START_PAGE, m_strStartPage);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSecondDlg, CDialog)
//{{AFX_MSG_MAP(CSecondDlg)
ON_BN_CLICKED(IDC_RADIO_SINGLE_FILE, OnRadioSingleFile)
ON_BN_CLICKED(IDC_RADIO_MULTI_FILE, OnRadioMultiFile)
ON_BN_CLICKED(IDC_RADIO_MULTI_FILE_EX, OnRadioMultiFileEx)
ON_BN_CLICKED(IDC_BUTTON_SEND_FILE, OnButtonSendFile)
ON_EN_CHANGE(IDC_EDIT_SEND_PHONE_NO, OnChangeEditSendPhoneNo)
ON_BN_CLICKED(IDC_BUTTON_HAND_IN_TASK, OnButtonHandInTask)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
ON_EN_CHANGE(IDC_EDIT_START_PAGE, OnChangeEditStartPage)
ON_EN_CHANGE(IDC_EDIT_END_PAGE, OnChangeEditEndPage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSecondDlg message handlers
void CSecondDlg::OnRadioSingleFile()
{
// TODO: Add your control notification handler code here
UpdateData();
CWnd * p;
p = GetDlgItem(IDC_STATIC_SEND_FILE);
p->SetWindowText(strLab[6]);
p = GetDlgItem(IDC_EDIT_START_PAGE);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_EDIT_END_PAGE);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_STATIC_START_PAGE);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_STATIC_END_PAGE);
p->ShowWindow(SW_SHOW);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_LIST_SEND_FILE);
p->ShowWindow(SW_HIDE);
p = GetDlgItem(IDC_BUTTON_ADD);
p->ShowWindow(SW_HIDE);
p = GetDlgItem(IDC_BUTTON_DELETE);
p->ShowWindow(SW_HIDE);
p = GetDlgItem(IDC_BUTTON_HAND_IN_TASK);
m_strSendFile = m_szSendPathFile;
UpdateData(FALSE);
}
void CSecondDlg::OnRadioMultiFile()
{
// TODO: Add your control notification handler code here
UpdateData();
int i;
CWnd * p ;
p = GetDlgItem(IDC_STATIC_SEND_FILE);
p->SetWindowText(strLab[8]);
p = GetDlgItem(IDC_EDIT_START_PAGE);
p->ShowWindow(SW_HIDE);
p = GetDlgItem(IDC_EDIT_END_PAGE);
p->ShowWindow(SW_HIDE);
p = GetDlgItem(IDC_STATIC_START_PAGE);
p->ShowWindow(SW_HIDE);
p = GetDlgItem(IDC_STATIC_END_PAGE);
p->ShowWindow(SW_HIDE);
p = GetDlgItem(IDC_BUTTON_ADD);
p->ShowWindow(SW_HIDE);
p = GetDlgItem(IDC_BUTTON_DELETE);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_BUTTON_HAND_IN_TASK);
m_ListBox.ResetContent();
for (i=0; i<m_arrSendFiles.GetSize(); i++)
{
m_ListBox.AddString(m_arrSendFiles[i]);
}
m_ListBox.ShowWindow(SW_SHOW);
m_strSendFile = m_szSendPath;
UpdateData(FALSE);
}
void CSecondDlg::OnRadioMultiFileEx()
{
// TODO: Add your control notification handler code here
UpdateData();
int i;
CWnd * p;
p = GetDlgItem(IDC_STATIC_SEND_FILE);
p->SetWindowText(strLab[6]);
p = GetDlgItem(IDC_EDIT_START_PAGE);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_EDIT_END_PAGE);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_BUTTON_ADD);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_BUTTON_DELETE);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_BUTTON_HAND_IN_TASK);
p = GetDlgItem(IDC_STATIC_START_PAGE);
p->ShowWindow(SW_SHOW);
p = GetDlgItem(IDC_STATIC_END_PAGE);
p->ShowWindow(SW_SHOW);
m_ListBox.ResetContent();
for (i=0; i<nSCTNumber; i++)
{
m_ListBox.AddString(ffSCT[i].szFileName);
}
m_ListBox.ShowWindow(SW_SHOW);
m_strSendFile = m_szSendPathFile;
UpdateData(FALSE);
}
BOOL CSecondDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CSecondDlg::OnRadioSingleFile();
InitLab();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSecondDlg::OnButtonSendFile()
{
// TODO: Add your control notification handler code here
char szPath[MAX_PATH];
GetCurrentDirectory(MAX_PATH, szCurrentPath);
if(m_nHowFile == 0 || m_nHowFile == 2) //single file or multi-file(page number is optional)
{
CFileDialog cf(1, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "Fax File(*.tif)|*.tif|Tif File(*.fax)|*.fax|Tiff File(*.tiff)|*.tiff|All File(*.*)|*.*|",NULL);
strcpy(szPath, szCurrentPath);
cf.m_ofn.lpstrInitialDir = szPath;
if(cf.DoModal() == IDOK)
{
strcpy(m_szSendPathFile, cf.GetPathName());
m_strSendFile = cf.GetFileName();
UpdateData(FALSE);
}
}
else if(m_nHowFile == 1) //multi-file
{
char t[] = "Please choose the route to save fax files";
BROWSEINFO bi;
LPMALLOC pMalloc;
char searchline[MAX_PATH];
int idx;
BOOL bMoreFiles;
CFileFind ff;
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_szSendPath))
{
m_strSendFile = m_szSendPath;
m_ListBox.ResetContent();
wsprintf(searchline, "%s\\*.tif", m_szSendPath);
bMoreFiles = ff.FindFile(searchline);
while(bMoreFiles)
{
bMoreFiles = ff.FindNextFile();
idx = m_ListBox.InsertString(-1, ff.GetFileName());
if (idx>=0)
m_arrSendFiles.SetAtGrow(idx, ff.GetFileName());
}
UpdateData(FALSE);
}
pMalloc->Free(pidl);
pMalloc->Release();
}
}
}
}
void CSecondDlg::OnChangeEditSendPhoneNo()
{
// 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(TRUE);
}
// submit faxing task
void CSecondDlg::OnButtonHandInTask()
{
// TODO: Add your control notification handler code here
CString str1, str2;
m_cmbTrkCh.GetWindowText(str1);
m_cmbFaxCh.GetWindowText(str2);
int nTrkCh, nFaxCh;
if(str1 == "None")
nTrkCh = -1;
else
nTrkCh = atoi(str1);
if(str2 == "None")
nFaxCh = -1;
else
nFaxCh = atoi(str2);
UpdateData(TRUE);
((CFax_Event_VCDlg*)m_pParent)->SendFax(nTrkCh, nFaxCh);
}
void CSecondDlg::OnButtonAdd()
{
// TODO: Add your control notification handler code here
if(m_strSendFile.IsEmpty())
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
{
MessageBox("请先选择一个传真文件");
}
else
{
MessageBox("Please select a fax file first!");
}
return;
}
UpdateData();
int n = m_ListBox.InsertString(-1, m_strSendFile);
strcpy(ffSCT[nSCTNumber].szFileName, m_szSendPathFile);
ffSCT[nSCTNumber].nStartPage = nStartPage;
ffSCT[nSCTNumber].nEndPage = nEndPage;
if(++nSCTNumber > 50)
nSCTNumber = 0;
m_ListBox.SetCurSel(n);
}
void CSecondDlg::OnButtonDelete()
{
// TODO: Add your control notification handler code here
int m = m_ListBox.GetCurSel();
if(m == -1)
return ;
CString str;
m_ListBox.GetText(m, str);
m_ListBox.DeleteString(m);
if (m_nHowFile==1)
{
m_arrSendFiles.RemoveAt(m);
}
else if (m_nHowFile==2)
{
for(int n = 0; n < nSCTNumber; n++)
{
if(strcmp(ffSCT[n].szFileName, str) == 0 && m == n)
{
for(; n < nSCTNumber; n++)
{
memcpy(&ffSCT[n], &ffSCT[n+1], sizeof(FAX_FILE_SCT));
}
nSCTNumber--;
if(m >= nSCTNumber)
m = 0;
m_ListBox.SetCurSel(m);
break;
}
}
}
}
//set start page
void CSecondDlg::OnChangeEditStartPage()
{
// 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 = 1;
else
nStartPage = atoi(m_strStartPage);
}
//set end page
void CSecondDlg::OnChangeEditEndPage()
{
// 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 = -1;
else
nEndPage = atoi(m_strEndPage);
}
void CSecondDlg::InitLab()
{
if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
{
//Chinese
strLab[0].Format("中继通道");
strLab[1].Format("传真通道");
strLab[2].Format("呼出号码");
strLab[3].Format("单文件");
strLab[4].Format("多文件");
strLab[5].Format("多文件(设置页码)");
strLab[6].Format("发送文件");
strLab[7].Format("浏览");
strLab[8].Format("发送路径");
strLab[9].Format("浏览");
strLab[10].Format("起始页");
strLab[11].Format("结束页");
strLab[12].Format("增加");
strLab[13].Format("删除");
strLab[14].Format("递交任务");
}
else
{ //English
strLab[0].Format("TrunkCh ID");
strLab[1].Format("FaxCh ID");
strLab[2].Format("Called party number");
strLab[3].Format("Single file");
strLab[4].Format("Multi-file_I");
strLab[5].Format("Multi-file_II");
strLab[6].Format("File name");
strLab[7].Format("Browse");
strLab[8].Format("Path");
strLab[9].Format("Browse");
strLab[10].Format("Start page");
strLab[11].Format("End page");
strLab[12].Format("Add");
strLab[13].Format("Delete");
strLab[14].Format("Submit task");
}
SetWinTextLab(this, IDC_STATIC_2DLG_TRUNKCH, strLab[0]);
SetWinTextLab(this, IDC_STATIC_2DLG_FAXCH, strLab[1]);
SetWinTextLab(this, IDC_STATIC_PHONE_NUMBER, strLab[2]);
SetWinTextLab(this, IDC_RADIO_SINGLE_FILE, strLab[3]);
SetWinTextLab(this, IDC_RADIO_MULTI_FILE, strLab[4]);
SetWinTextLab(this, IDC_RADIO_MULTI_FILE_EX, strLab[5]);
SetWinTextLab(this, IDC_STATIC_SEND_FILE, strLab[6]);
SetWinTextLab(this, IDC_BUTTON_SEND_FILE, strLab[7]);
SetWinTextLab(this, IDC_STATIC_START_PAGE, strLab[10]);
SetWinTextLab(this, IDC_STATIC_END_PAGE, strLab[11]);
SetWinTextLab(this, IDC_BUTTON_ADD, strLab[12]);
SetWinTextLab(this, IDC_BUTTON_DELETE, strLab[13]);
SetWinTextLab(this, IDC_BUTTON_HAND_IN_TASK, strLab[14]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -