Click here to Skip to main content
15,897,518 members
Articles / Desktop Programming / MFC

Solitaire Puzzle with Backtracking

Rate me:
Please Sign up or sign in to vote.
4.26/5 (9 votes)
10 Sep 20056 min read 80.4K   2.7K   33  
A program to play Solitaire puzzle and to seek solutions using backtracking.
#include "stdafx.h"
#include "AboutDlg.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


LPCSTR AboutDlg::ms_programInfo =
	"�   This program implements a simple backtracking algorithm to search for a solution starting from the current disposition of the pieces on the board.\r\n\r\n"

	"�   It illustrates the concepts of recursive function, inherently recursive problem and backtracking.\r\n"
	"�   It also provides an object oriented vestment to backtracking, in the form of a reusable class holding all the backtracking logic.\r\n"
	"�   The source code comprises the template class Stack<class TYPE>, a simple typed stack.\r\n";


LPCSTR AboutDlg::ms_licenseInfo =
	"This program is freeware.\r\n"
	"You can use or distribute it provided that you keep intact this notice and all the other notices that refer to the copyright of the author and to the absence of any warranty.\r\n\r\n"
    
	"This program is distributed WITHOUT ANY WARRANTY.\r\n"
	"It is provided \"AS IS\", and its author accepts no responsibility for damages resulting from its use.\r\n";

LPCSTR AboutDlg::ms_contactInfo =
	"For comments, questions or suggestions please write to:\r\n\r\n"

	"Paolo Martinoli\r\n"
	"pmartinoli@programmer.net\r\n"
	"Via Valsolda, 169 - 00141 Rome (Italy)\r\n";


BEGIN_MESSAGE_MAP(AboutDlg, CDialog)
	//{{AFX_MSG_MAP(AboutDlg)
	ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


AboutDlg::AboutDlg() : CDialog(AboutDlg::IDD)
{
	//{{AFX_DATA_INIT(AboutDlg)
	m_edit = _T("");
	//}}AFX_DATA_INIT
}

AboutDlg::~AboutDlg()
{
}

void AboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(AboutDlg)
	DDX_Text(pDX, IDC_EDIT, m_edit);
	DDX_Control(pDX, IDC_TAB, m_tab);
	//}}AFX_DATA_MAP
}

BOOL AboutDlg::OnInitDialog() 
{
	m_edit = ms_programInfo;
	
	CDialog::OnInitDialog();
	
	m_tab.InsertItem(0, "Program");
	m_tab.InsertItem(1, "License");
	m_tab.InsertItem(2, "Contacts");

	return TRUE;
}

void AboutDlg::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult) 
{
	switch ( m_tab.GetCurSel() )
	{
		case 0:
			m_edit = ms_programInfo;

			break;

		case 1:
			m_edit = ms_licenseInfo;

			break;

		case 2:
			m_edit = ms_contactInfo;
	}

	UpdateData(FALSE);
	
	*pResult = 0;
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) Avventure nel Mondo
Italy Italy
I have a degree in Computer Science and I've been earning my living since the early 90s by making the compiler dance.

I was born in Milan in 1963 and live in Rome since 1995.

In my spare time I sing in a vocal ensemble and play guitar and keyboard. Unfortunately, I program much better than I play. Occasionally I coordinate travel groups for the Italian tour operator Avventure nel Mondo.

https://www.paolomartinoli.it
programmer@paolomartinoli.it

Comments and Discussions