|
// urldialog.cpp : implementation file
//
#include "stdafx.h"
#include "eikona.h"
#include "urldialog.h"
#include "WebGrab.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// urldialog dialog
urldialog::urldialog(CWnd* pParent /*=NULL*/)
: CDialog(urldialog::IDD, pParent)
{
//{{AFX_DATA_INIT(urldialog)
m_url = _T("http://");
m_status = _T("Normal");
m_message = _T("");
m_rate = 0;
//}}AFX_DATA_INIT
}
void urldialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(urldialog)
DDX_Text(pDX, IDC_EDIT1, m_url);
DDX_Text(pDX, IDC_EDIT3, m_status);
DDX_Text(pDX, IDC_EDIT4, m_message);
DDX_Text(pDX, IDC_EDIT5, m_rate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(urldialog, CDialog)
//{{AFX_MSG_MAP(urldialog)
ON_BN_CLICKED(IDC_BUTTON1, OnDownload)
ON_BN_CLICKED(IDC_BUTTON2, OnSave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// urldialog message handlers
void urldialog::OnDownload()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CWebGrab grab;
ok=grab.GetFile(m_url,buffer);
if (ok)
m_status="Normal";
else
m_status=grab.GetErrorMessage();
m_rate=grab.GetRate();
m_message="Downloaded..";
UpdateData(FALSE);
}
void urldialog::OnSave()
{
// TODO: Add your control notification handler code here
CString file;
static char BASED_CODE szFilter[]="All files (*.*)|*.*||";
CFileDialog t(FALSE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
if (t.DoModal()==IDOK)
{
file=t.GetPathName(); //write the file
CFile cf(file,CFile::modeCreate|CFile::modeWrite);
cf.Write(buffer,buffer.GetLength());
cf.Close();
m_message="Saved..";
UpdateData(FALSE);
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.