|
|
#include "stdafx.h"
#include "Test.h"
#include "TestDlg.h"
// download by http://www.NewXing.com
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*========================================================================*/
CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestDlg)
//}}AFX_DATA_INIT
}
void CTestDlg: oDataExchange(CDataExchange* pDX)
{
CDialog: oDataExchange(pDX);
//{{AFX_DATA_MAP(CTestDlg)
DDX_Control(pDX, IDC_PROGRESS1, m_pp);
DDX_Control(pDX, IDC_LIST1, m_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
//{{AFX_MSG_MAP(CTestDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_EN_KILLFOCUS(IDC_EDIT1, OnKillfocusEdit1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/*========================================================================*/
#define MAX 10
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_imagelist.Create(16,16,TRUE,2,2);
m_imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
m_list.SetImageList(&m_imagelist,LVSIL_SMALL);
m_font.CreateFont(16, 0,0,0,FW_NORMAL, 0,0,0,
DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
m_list.SetFont(&m_font);
/*-----------------------------------------------------------*/
m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
m_list.SetBkColor(RGB(247,247,255));
m_list.SetTextColor(RGB(0,0,255));
m_list.SetTextBkColor(RGB(247,247,255));
m_list.InsertColumn(0, "序号", LVCFMT_LEFT, 50);
m_list.InsertColumn(1, "文件名", LVCFMT_LEFT, 350);
m_list.InsertColumn(2, "下载状态", LVCFMT_LEFT, 150);
m_pp.SetRange(1,MAX+1);
m_pp.SetPos(0);
m_pp.SetStep(1);
CString strURL,strI;
for(int i=1; i<=MAX; i++)
{
strI.Format("%d",i);
strURL="http://www.xiaozhou.net/cooldog/magicface/flash/" +strI+ ".swf";
int nIndex=m_list.InsertItem(0xffff,strI,0);
m_list.SetItemText(nIndex,1,strURL);
}
return TRUE;
}
void CTestDlg::OnButton1()
{
CString strURL,strI;
for(int i=1; i<=MAX; i++)
{
strI.Format("%d",i);
strURL="http://www.xiaozhou.net/cooldog/magicface/flash/" +strI+ ".swf";
if(::URLDownloadToFile(NULL,strURL,"d:\\"+strI+".swf",0,NULL) ==S_OK)
{
m_pp.StepIt();
m_list.SetItemText(i-1,2,"文件下载完成!");
}
else
{
m_pp.StepIt();
m_list.SetItemText(i-1,2,"文件下载失败...");
}
}
}
void CTestDlg::OnKillfocusEdit1()
{
} |
|