Click here to Skip to main content
12,352,739 members (57,088 online)
Click here to Skip to main content

Stats

42.7K views
1.9K downloads
41 bookmarked
Posted

Internet Explorer AdBlock

, 17 Jan 2008 GPL3
Internet Explorer AdBlock Add-on
IE AdBlockPS
IE AdBlockps.def
IE AdBlock
AdBlockBand.rgs
AdBlockBHO.rgs
bin
XListCtrlSSDU.lib
XListCtrlSSRU.lib
IE AdBlock.def
IE AdBlock.rgs
res
bmpToolbar.bmp
checkboxes.bmp
icoSettings.ico
XListCtrl
checkboxes.bmp
//*********************************************************************
// INCLUDES
//*********************************************************************

#include "stdafx.h"
#include "SettingsAbout.h"
#include "FileVersion.h"

//*********************************************************************
// MESSAGE MAP
//*********************************************************************

BEGIN_MESSAGE_MAP(CSettingsAbout, CSettingsPage)
	ON_COMMAND(btnCheckForUpdates, OnBtnCheckForUpdates)
END_MESSAGE_MAP()

//*********************************************************************
// CONSTRUCTOR & DESTRUCTOR
//*********************************************************************

IMPLEMENT_DYNAMIC(CSettingsAbout, CSettingsPage)

//=====================================================================

CSettingsAbout::CSettingsAbout()
	: CSettingsPage(CSettingsAbout::IDD)
{
}

//=====================================================================

CSettingsAbout::~CSettingsAbout()
{
}

//*********************************************************************
// PUBLIC FUNCTIONS
//*********************************************************************

BOOL CSettingsAbout::OnInitDialog()
{
	// Declare variables
	CSettings * pSettings = CSettings::Instance();
	CPath * pPath = CPath::Instance();
	CString sTemp = _T(""), sCopyright = _T("");
	CFileVersion fileVersion;

	// Call original function
	CSettingsPage::OnInitDialog();

	// Load strings
	m_btnCheckForUpdates.SetWindowText(m_pLanguage->GetString(IDS_ABOUT_CHECKFORUPDATES));
	sTemp.Format(m_pLanguage->GetString(IDS_ABOUT_DEVELOPED), m_pLanguage->GetString(IDS_PROJNAME), 
		IEADBLOCK_DEVELOPER, IEADBLOCK_IDEABY);
	m_lblDeveloped.SetWindowText(sTemp);
	m_lblWebsiteText.SetWindowText(m_pLanguage->GetString(IDS_ABOUT_WEBSITE));
#ifdef _DEBUG
	m_lblVersionText.SetWindowText(m_pLanguage->GetString(IDS_ABOUT_VERSION) + _T(" (debug version)"));
#else
	m_lblVersionText.SetWindowText(m_pLanguage->GetString(IDS_ABOUT_VERSION));
#endif

	// Set hyperlink text & options
	m_lblWebsite.SetWindowText(IEADBLOCK_WEBADDRESS);
	m_lblWebsite.SetHyperlink(IEADBLOCK_WEBADDRESS);
	m_lblWebsite.SetAutoResize(true);
	//m_lblWebsite.

	// Set version
	fileVersion.Open(pPath->GetPathAdBlockLocation());
	m_lblVersion.SetWindowText(fileVersion.GetFileVersion());
	fileVersion.Close();

	// Set copyright message
	sCopyright.Format(_T("%s%s%s%s"),
		_T("Warning: This program is protected by copyright law and international treaties. "),
		_T("Unauthorized reproduction or distribution of this program, or any portion of it, "),
		_T("may result in severe civil and criminal penalties, and will be prosecuted to the "),
		_T("maximum extent possible under the law."));
	m_lblCopyright.SetWindowText(sCopyright);

	// Return TRUE unless you want to set focus to control
	return TRUE;
}

//=====================================================================

BOOL CSettingsAbout::OnApply()
{
	// Declare variables
	CSettings * pSettings = CSettings::Instance();

	// Save data

	// Call original function
	return CSettingsPage::OnApply();
}

//*********************************************************************
// PRIVATE FUNCTIONS
//*********************************************************************

void CSettingsAbout::DoDataExchange(CDataExchange* pDX)
{
	CSettingsPage::DoDataExchange(pDX);
	DDX_Control(pDX, lblDeveloped, m_lblDeveloped);
	DDX_Control(pDX, lblVersionText, m_lblVersionText);
	DDX_Control(pDX, lblVersion, m_lblVersion);
	DDX_Control(pDX, lblWebsiteText, m_lblWebsiteText);
	DDX_Control(pDX, lblCopyright, m_lblCopyright);
	DDX_Control(pDX, lblWebsite, m_lblWebsite);
	DDX_Control(pDX, btnCheckForUpdates, m_btnCheckForUpdates);
}

//=====================================================================

void CSettingsAbout::OnBtnCheckForUpdates()
{
	// Declare variables
	CString sPath = _T(""), sTemp = _T("");
	CPath * pPath = CPath::Instance();

	// Set up path
	sPath.Format(_T("%supdater\\updater.exe"), pPath->ExtractFilePath(pPath->GetPathAdBlockLocation()));

	// Check if path exists
	if (PathFileExists(sPath))
	{
		// Run Updater
		SHELLEXECUTEINFO ShRun = {0};
		ShRun.cbSize = sizeof(SHELLEXECUTEINFO);
		ShRun.fMask = SEE_MASK_NOCLOSEPROCESS;
		ShRun.hwnd = NULL;
		ShRun.lpVerb = NULL;
		ShRun.lpFile = _T("updater.exe");
		ShRun.lpParameters = NULL;
		ShRun.lpDirectory = pPath->ExtractFilePath(sPath);
		ShRun.nShow = SW_SHOW;
		ShRun.hInstApp = NULL;

		// Execute the file with the parameters
		ShellExecuteEx(&ShRun);	
	}
	else
	{
		// Show error
		AfxMessageBox(m_pLanguage->GetString(IDS_ERROR_UPDATERNOTFOUND), MB_ICONERROR);

		// Disable the button
		m_btnCheckForUpdates.EnableWindow(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 GNU General Public License (GPLv3)

Share

About the Author

Geert van Horrik
Software Developer CatenaLogic
Netherlands Netherlands
I am Geert van Horrik, and I have studied Computer Science in the Netherlands.

I love to write software using .NET (especially the combination of WPF and C#). I am also the lead developer of Catel, an open-source application development framework for WPF, Silverlight, WP7 and WinRT with the focus on MVVM.

I have my own company since January 1st 2007, called CatenaLogic. This company develops commercial and non-commercial software.

To download (or buy) applications I have written, visit my website: http://www.catenalogic.com

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 17 Jan 2008
Article Copyright 2008 by Geert van Horrik
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid