Click here to Skip to main content
15,884,892 members
Articles / Desktop Programming / MFC

Porcupine

Rate me:
Please Sign up or sign in to vote.
4.78/5 (25 votes)
15 Sep 2009CPOL4 min read 570.2K   15.4K   118  
A library for visible and invisible image watermarking
// 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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Greece Greece
Physicist/SW Engineer

Comments and Discussions