📄 linkgendlg.cpp
字号:
// LinkGenDlg.cpp : implementation file
//
#include "stdafx.h"
#include "LinkGen.h"
#include "LinkGenDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLinkGenDlg dialog
CLinkGenDlg::CLinkGenDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLinkGenDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLinkGenDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_nMsgNum = 0;
}
void CLinkGenDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLinkGenDlg)
DDX_Control(pDX, IDC_RICHEDITSTATE, m_redtState);
DDX_Control(pDX, IDC_CHECKTOP, m_btnTopDesk);
DDX_Control(pDX, IDC_EDITMEETINGNO, m_edtMeetingNumber);
DDX_Control(pDX, IDC_EDITCRNO, m_edtCRNumber);
DDX_Control(pDX, IDC_COMBOWG, m_cmbWorkGroup);
DDX_Control(pDX, IDC_STATICNUM, m_stcNum);
DDX_Control(pDX, IDC_EDITOUTFILE, m_edtOutFile);
DDX_Control(pDX, IDC_EDITINFILE, m_edtInFile);
DDX_Control(pDX, IDC_EDITHEAD, m_edtBaseAddr);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLinkGenDlg, CDialog)
//{{AFX_MSG_MAP(CLinkGenDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BTN_INFILE, OnBtnInfile)
ON_BN_CLICKED(IDC_BTN_OUTFILE, OnBtnOutfile)
ON_BN_CLICKED(IDC_BTN_GEN, OnBtnGen)
ON_BN_CLICKED(IDC_BTN_DOWNLOAD, OnBtnDownload)
ON_BN_CLICKED(IDC_RADIOBATCH, OnRadiobatch)
ON_BN_CLICKED(IDC_CHECKTOP, OnChecktop)
ON_BN_CLICKED(IDC_RADIOSINGLECR, OnRadiosinglecr)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLinkGenDlg message handlers
BOOL CLinkGenDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_edtBaseAddr.SetWindowText("http://www.3gpp.org/ftp/tsg_ran/WG2_RL2/TSGR2_59/Docs/");
((CButton *)GetDlgItem(IDC_RADIOBATCH))->SetCheck(FALSE);//选上
((CButton *)GetDlgItem(IDC_RADIOSINGLECR))->SetCheck(TRUE);//不选上
m_cmbWorkGroup.SetCurSel(2);
m_edtMeetingNumber.SetWindowText("59");
EnableBatchWindow(FALSE);
m_btnTopDesk.SetCheck(0);
//SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | WS_EX_TOPMOST);
return TRUE; // return TRUE unless you set the focus to a control
}
void CLinkGenDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CLinkGenDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CLinkGenDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CLinkGenDlg::OnBtnInfile()
{
//CFileDialog dlg(TRUE,"exe",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"可执行文件(*.exe) | *.exe|视频文件(*.bat) | *.bat |All Files (*.*) | *.* ||",NULL);
CFileDialog dlg( TRUE, "txt", NULL, OFN_HIDEREADONLY,"Txt Files(*.txt)|*.txt|All Files (*.*)|*.*||",NULL);
if (dlg.DoModal()==IDOK)
{
m_edtInFile.SetWindowText(dlg.GetPathName());
}
ShowMessage(CString("Set input File OK."));
}
void CLinkGenDlg::OnBtnOutfile()
{
CFileDialog dlg(FALSE, "txt", NULL, OFN_HIDEREADONLY/*|OFN_OVERWRITEPROMPT*/,
"Txt Files(*.txt)|*.txt|", NULL);
if (dlg.DoModal()==IDOK)
{
m_edtOutFile.SetWindowText(dlg.GetPathName());
}
ShowMessage(CString("Set Output File OK."));
}
void CLinkGenDlg::OnBtnGen()
{
CString strIn, strOut, strBaseAddr;
m_edtInFile.GetWindowText(strIn);
m_edtOutFile.GetWindowText(strOut);
m_edtBaseAddr.GetWindowText(strBaseAddr);
if (( 0 ==strIn.GetLength() )||
( 0 == strOut.GetLength() )||
( 0 == strBaseAddr.GetLength()) )
{
ShowMessage("Please Fill in Input/Output filename and Base URL.");
return;
}
ShowMessage("Begin of generating RC URL file ...");
if (strBaseAddr[strBaseAddr.GetLength()-1] != '/')
{
strBaseAddr+='/';
m_edtBaseAddr.SetWindowText(strBaseAddr);
}
CStdioFile inFile, outFile;
if(!inFile.Open(strIn, CStdioFile::modeRead))
{
ShowMessage("Can not open input file.");
return;
}
if(!outFile.Open(strOut, CStdioFile::modeCreate|CStdioFile::modeReadWrite))
{
ShowMessage("Can not open output file.");
inFile.Close();
return;
}
CString strLine,strNum;
INT number=1;
while (inFile.ReadString(strLine))
{
outFile.SeekToEnd();
strOut=strBaseAddr+strLine+".zip\n";
outFile.WriteString(strOut);
strNum.Format("%d",number++);
m_stcNum.SetWindowText(strNum);
}
inFile.Close();
outFile.Close();
ShowMessage("End of generating RC URL file ...");
}
void CLinkGenDlg::OnBtnDownload()
{
INT nDownMode=((CButton *)GetDlgItem(IDC_RADIOBATCH))->GetCheck();//返回1表示选上,0表示没选上
if (1 == nDownMode)
{
BatchDownload();
}
else
{
SingleRCDownload();
}
}
void CLinkGenDlg::BatchDownload()
{
CStdioFile urlFile;
CString strUrlFile;
m_edtOutFile.GetWindowText(strUrlFile);
if (strUrlFile.IsEmpty())
{
ShowMessage("Please choose a CR URL file");
return;
}
if(!urlFile.Open(strUrlFile, CStdioFile::modeRead))
{
ShowMessage("Can not open CR URL file");
return;
}
//ShowMessage("URL link file openned successful ...");
m_btnTopDesk.SetCheck(0);
//GetDlgItem(IDC_CHECKTOP)->SendMessage(BN_CLICKED); // to Parent Window
SendMessage(WM_COMMAND,((WPARAM)BN_CLICKED)<<8|(WPARAM)IDC_CHECKTOP,0L);
CString strLink;
INT ret, intNum=0;
BOOL downflag=TRUE;
while(urlFile.ReadString(strLink)&&downflag)
{
ret=MessageBox("Do you want to download the following file?:\n"+strLink,"Notice ...", MB_YESNOCANCEL);
switch (ret)
{
case IDYES:
ShellExecute(NULL,"open",strLink, NULL, NULL,SW_SHOW);
intNum++;
ShowMessage("Download file: " + strLink);
break;
case IDNO:
ShowMessage("Canceled file: " + strLink);
break;
case IDCANCEL:
ShowMessage("Quit Download by user");
downflag=FALSE;
break;
default:
;
}
}
urlFile.Close();
}
void CLinkGenDlg::SingleRCDownload()
{
INT nMaxName=256,nRAN=m_cmbWorkGroup.GetCurSel();
BOOL bEnable=FALSE;
if (m_edtMeetingNumber.GetWindowTextLength()==0 ||
m_edtCRNumber.GetWindowTextLength() == 0)
{
ShowMessage("Please Fill in Meeting/CR Number.");
return;
}
CString /*,strAddrHeader2*/ strMeetingNo,strCRNo, strCRURL;
m_edtMeetingNumber.GetWindowText(strMeetingNo);
int nMeetingNo=atoi(strMeetingNo);
switch (nRAN)
{
case 0: //RAN
strCRURL="TSG_RAN/TSGR_";
ShowMessage("Download CR from RAN");
bEnable=TRUE;
break;
case 1: //RAN1
if (nMeetingNo>38)
{
strCRURL="WG1_RL1/TSGR1_"+strMeetingNo+"/Docs/";
}
else
{
strCRURL="WG1_RL1/TSGR1_"+strMeetingNo+"/Docs/zips/";
}
strCRURL="http://www.3gpp.org/ftp/tsg_ran/"+strCRURL;
bEnable=TRUE;
break;
case 2: //RAN2
strCRURL="WG2_RL2/TSGR2_"+strMeetingNo;
if (nMeetingNo>=46 && nMeetingNo <= 58 && strMeetingNo != CString("58bis"))
{
strCRURL+="/Documents/";
}
else if (nMeetingNo>32)
{
strCRURL+="/Docs/";
}
else
{
strCRURL+="/Docs/zips/";
}
strCRURL="http://www.3gpp.org/ftp/tsg_ran/"+strCRURL;
bEnable=TRUE;
break;
case 3: //RAN3
strCRURL="WG3_Iu/TSGR3_";
strCRURL="http://www.3gpp.org/ftp/tsg_ran/"+strCRURL+strMeetingNo+"/Docs/";
bEnable=TRUE;
break;
case 4: //RAN4
strCRURL="WG4_Radio/TSGR4_";
strCRURL="http://www.3gpp.org/ftp/tsg_ran/"+strCRURL+strMeetingNo+"/Docs/";
bEnable=TRUE;
break;
case 5: //RAN5
strCRURL="http://www.3gpp.org/ftp/tsg_ran/WG5_Test_ex-T1";
ShellExecute(NULL,"open",strCRURL, NULL, NULL,SW_SHOWMINIMIZED);
ShowMessage("Sorry, RAN 5 not supported");
//bEnable=FALSE;
break;
default:
bEnable = FALSE;
}
if (bEnable)
{
m_edtCRNumber.GetWindowText(strCRNo);
strCRURL+=strCRNo+".zip";
ShellExecute(NULL,"open",strCRURL, NULL, NULL,SW_SHOWMINIMIZED);
}
}
void CLinkGenDlg::OnRadiobatch()
{
EnableBatchWindow(TRUE);
ShowMessage("Batch Mode ...");
}
void CLinkGenDlg::OnChecktop()
{
int nRet=m_btnTopDesk.GetCheck();
if (nRet == 1)
{
SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | WS_EX_TOPMOST);
}
else
{
::SetWindowPos(GetSafeHwnd(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
}
void CLinkGenDlg::OnRadiosinglecr()
{
EnableBatchWindow(FALSE);
ShowMessage("Single Mode ...");
}
void CLinkGenDlg::EnableBatchWindow(BOOL bFlag)
{
m_edtBaseAddr.EnableWindow(bFlag);
m_edtInFile.EnableWindow(bFlag);
m_edtOutFile.EnableWindow(bFlag);
GetDlgItem(IDC_BTN_INFILE)->EnableWindow(bFlag);
GetDlgItem(IDC_BTN_OUTFILE)->EnableWindow(bFlag);
GetDlgItem(IDC_BTN_GEN)->EnableWindow(bFlag);
m_cmbWorkGroup.EnableWindow(!bFlag);
m_edtMeetingNumber.EnableWindow(!bFlag);
m_edtCRNumber.EnableWindow(!bFlag);
}
void CLinkGenDlg::ShowMessage(CString strMsg, INT nMode)
{
CString strNum;
strNum.Format("%3d ==> %s\r\n", m_nMsgNum++,strMsg);
m_redtState.SetSel(-1,-1);
m_redtState.ReplaceSel(strNum);
m_redtState.PostMessage(WM_VSCROLL, SB_BOTTOM, 0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -