Click here to Skip to main content
15,879,239 members
Articles / Desktop Programming / MFC

A Sudoku Teacher Using Boost Libraries

Rate me:
Please Sign up or sign in to vote.
4.73/5 (27 votes)
7 Jul 20067 min read 68K   1.9K   60  
A Sudoku teacher using multi_index_container, lambda, and other Boost libraries.
// STUBLDlg.h : header file
//
#pragma once
#include "SudokuEdit.h"

class Sudoku;

// CSTUBLDlg dialog
class CSTUBLDlg : public CDialog
{
// Construction
public:
	CSTUBLDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_STUBL_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

    CSudokuEdit* Boxes[9][9];

    Sudoku* pPuzzle;

	CFont* cf;
	CFont* cfAnswer;
	CFont* cfHints;

	CBrush* cbAnswer;
	CBrush* cbHint;
	CBrush* cbBlank;
	CBrush* cbImposs;

	CBrush* cdDlgBgColor;

	bool bShowHints;

	void Restore(char *fName);

	int m_puzzleDef[81];	// puzzle as entered or loaded by the user 

	enum SudokuPlayState
	{
		SPS_UNINIT = 1,
		SPS_ENTERING_PUZZLE,
		SPS_PLAYING
	};

	SudokuPlayState m_playState;

	void PerformInitialCheck();

public:
    afx_msg void OnBnClickedButtonSolve();
	afx_msg void OnBnClickedButtonHistory();
	afx_msg void OnBnClickedButtonStep();
	afx_msg void OnBnClickedButtonShowhints();
	afx_msg void OnBnClickedButtonStepUntilAnswerfound();

	afx_msg void OnSquareChanged( UINT nID );
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg void OnDropFiles(HDROP hDropInfo);

    bool GetFileName(bool save, CString& cs);
	CButton m_buttonHints;
	void SetHints(bool hintsOn);
	CListBox m_lbReasons;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

	afx_msg void OnFileOpen();
	afx_msg void OnFileSaveAs();
	afx_msg void OnFileTypeInPuzzle();
	afx_msg void OnFileClose();
	afx_msg void OnPuzzleClear();
	afx_msg void OnPuzzleReset();
	afx_msg void OnHelpAboutStubl();
public:
	afx_msg void OnBnClickedButtonShowanswers();
};

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
Web Developer
United States United States
I live in Minnesota with my wife and son, having moved here from Montana. I enjoy creating software which benefits people, and I am fortunate to have a job where I am able to do that.
I enjoy reading, hunting and fishing, any sport with a racquet or paddle, and rooting for the New England Patriots.
In addition to my full-time job, I founded Rohawk, LLC which creates software for Christian churches.

Comments and Discussions