📄 seconddlg.cpp
字号:
// SecondDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Fax_Polling_VC.h"
#include "SecondDlg.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_strSendPath = _T("");
m_strEndPage = _T("");
m_strStartPage = _T("");
//}}AFX_DATA_INIT
nSCTNumber = 0;
nStartPage = 1;
nEndPage = -1;
}
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_SEND_PATH, m_strSendPath);
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_BN_CLICKED(IDC_BUTTON_SEND_PATH, OnButtonSendPath)
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 = GetDlgItem(IDC_EDIT_SEND_PATH);
p->ShowWindow(0);
p = GetDlgItem(IDC_BUTTON_SEND_PATH);
p->ShowWindow(0);
p = GetDlgItem(IDC_STATIC_SEND_PATH);
p->ShowWindow(0);
p = GetDlgItem(IDC_EDIT_START_PAGE);
p->ShowWindow(1);
p->MoveWindow(90, 115, 40, 22, 1);
p = GetDlgItem(IDC_EDIT_END_PAGE);
p->ShowWindow(1);
p->MoveWindow(220, 115, 40, 22, 1);
p = GetDlgItem(IDC_STATIC_START_PAGE);
p->ShowWindow(1);
p->MoveWindow(20, 120, 100, 20, 1);
p = GetDlgItem(IDC_STATIC_END_PAGE);
p->ShowWindow(1);
p->MoveWindow(155, 120, 100, 20, 1);
p->ShowWindow(1);
p = GetDlgItem(IDC_LIST_SEND_FILE);
p->ShowWindow(0);
p = GetDlgItem(IDC_BUTTON_ADD);
p->ShowWindow(0);
p = GetDlgItem(IDC_BUTTON_DELETE);
p->ShowWindow(0);
p = GetDlgItem(IDC_BUTTON_HAND_IN_TASK);
p->MoveWindow(115, 155, 100, 24, 1);
}
void CSecondDlg::OnRadioMultiFile()
{
// TODO: Add your control notification handler code here
UpdateData();
CWnd * p = GetDlgItem(IDC_EDIT_SEND_PATH);
p->ShowWindow(1);
p = GetDlgItem(IDC_BUTTON_SEND_PATH);
p->ShowWindow(1);
p = GetDlgItem(IDC_EDIT_START_PAGE);
p->ShowWindow(0);
p = GetDlgItem(IDC_EDIT_END_PAGE);
p->ShowWindow(0);
p = GetDlgItem(IDC_STATIC_START_PAGE);
p->ShowWindow(0);
p = GetDlgItem(IDC_STATIC_END_PAGE);
p->ShowWindow(0);
p = GetDlgItem(IDC_STATIC_SEND_PATH);
p->ShowWindow(1);
p->MoveWindow(20, 117, 50, 22, 1);
p = GetDlgItem(IDC_LIST_SEND_FILE);
p->ShowWindow(1);
p->MoveWindow(20, 145, 180, 60, 1);
p = GetDlgItem(IDC_BUTTON_ADD);
p->ShowWindow(1);
p->MoveWindow(210, 160, 47, 23, 1);
p = GetDlgItem(IDC_BUTTON_DELETE);
p->ShowWindow(1);
p->MoveWindow(210, 180, 47, 23, 1);
p = GetDlgItem(IDC_BUTTON_HAND_IN_TASK);
p->MoveWindow(115, 210, 100, 24, 1);
}
void CSecondDlg::OnRadioMultiFileEx()
{
// TODO: Add your control notification handler code here
UpdateData();
CWnd * p = GetDlgItem(IDC_EDIT_SEND_PATH);
p->ShowWindow(0);
p = GetDlgItem(IDC_BUTTON_SEND_PATH);
p->ShowWindow(0);
p = GetDlgItem(IDC_STATIC_SEND_PATH);
p->ShowWindow(0);
p = GetDlgItem(IDC_EDIT_START_PAGE);
p->ShowWindow(1);
p->MoveWindow(90, 115, 40, 22, 1);
p = GetDlgItem(IDC_EDIT_END_PAGE);
p->ShowWindow(1);
p->MoveWindow(220, 115, 40, 22, 1);
p = GetDlgItem(IDC_LIST_SEND_FILE);
p->ShowWindow(1);
p->MoveWindow(20, 145, 180, 60, 1);
p = GetDlgItem(IDC_BUTTON_ADD);
p->ShowWindow(1);
p->MoveWindow(210, 160, 47, 23, 1);
p = GetDlgItem(IDC_BUTTON_DELETE);
p->ShowWindow(1);
p->MoveWindow(210, 180, 47, 23, 1);
p = GetDlgItem(IDC_BUTTON_HAND_IN_TASK);
p->MoveWindow(115, 210, 100, 24, 1);
p = GetDlgItem(IDC_STATIC_START_PAGE);
p->ShowWindow(1);
p->MoveWindow(20, 120, 100, 20, 1);
p = GetDlgItem(IDC_STATIC_END_PAGE);
p->ShowWindow(1);
p->MoveWindow(155, 120, 100, 20, 1);
}
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_strSendFile.GetBuffer(MAX_PATH), cf.GetPathName());
UpdateData(FALSE);
m_strSendFile.ReleaseBuffer(-1);
}
}
else if(m_nHowFile == 1) //multi-file
{
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_strSendFile.GetBuffer(MAX_PATH), cf.GetFileName());
UpdateData(FALSE);
m_strSendFile.ReleaseBuffer(-1);
}
}
}
void CSecondDlg::OnButtonSendPath()
{
// TODO: Add your control notification handler code here
char t[] = "Please choose the route to save fax files";
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_strSendPath.GetBuffer(MAX_PATH)))
{
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);
}
//Chinese: 提交任务
//English: 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);
FAX_TASK *p = (PFAX_TASK)malloc(sizeof(FAX_TASK));
strcpy(p->szCallNo, m_strCallNo.GetBuffer(m_strCallNo.GetLength()));
m_strCallNo.ReleaseBuffer();
if(str1 == "None")
p->nTrkCh = -1;
else
p->nTrkCh = atoi(str1);
if(str2 == "None")
p->nFaxCh = -1;
else
p->nFaxCh = atoi(str2);
p->nHowFile = m_nHowFile;
p->nSCTNumber = nSCTNumber;
if(m_nHowFile == 0) //single file
{
p->nStartPage = nStartPage; //start page
p->nEndPage = nEndPage; //end page
strcpy(p->szSendFile, m_strSendFile.GetBuffer(m_strSendFile.GetLength()));
m_strSendFile.ReleaseBuffer();
}
else if(m_nHowFile == 1) //multi-file
{
for(int i = 0; i < nSCTNumber; i++)
{
p->ffSCT[i] = ffSCT[i];
}
strcpy(p->szSendPath, m_strSendPath.GetBuffer(m_strSendPath.GetLength()));
m_strSendPath.ReleaseBuffer();
}
else if(m_nHowFile == 2) //multi-file(page number is optional)
{
for(int i = 0; i < nSCTNumber; i++)
{
p->ffSCT[i] = ffSCT[i];
}
}
//Chinese: 将传真任务加入到队列中
//English: add faxing task to queue
pRear->pNext = p;
p->pNext = NULL;
pRear = p;
}
void CSecondDlg::OnButtonAdd()
{
// TODO: Add your control notification handler code here
if(m_strSendFile.IsEmpty()) return;
UpdateData();
int n = m_ListBox.InsertString(-1, m_strSendFile);
strcpy(ffSCT[nSCTNumber].szFileName, m_strSendFile);
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);
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_SEND_PATH, strLab[8]);
SetWinTextLab(this, IDC_BUTTON_SEND_PATH, strLab[9]);
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 + -