⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shwresult.cpp

📁 利用VC开发的一个八数码程序
💻 CPP
字号:
// SHWRESULT.cpp : implementation file
//

#include "stdafx.h"
#include "EightPuzzles.h"
#include "EIGHTNUMS1.h"
#include "EightPuzzlesDlg.h"
#include "SHWRESULT.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSHWRESULT dialog


CSHWRESULT::CSHWRESULT(CWnd* pParent /*=NULL*/)
	: CDialog(CSHWRESULT::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSHWRESULT)
	m_cur1 = 0;
	m_cur2 = 0;
	m_cur3 = 0;
	m_cur4 = 0;
	m_cur5 = 0;
	m_cur6 = 0;
	m_cur7 = 0;
	m_cur8 = 0;
	m_cur9 = 0;
	m_process = _T("");
	//}}AFX_DATA_INIT
}


void CSHWRESULT::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSHWRESULT)
	DDX_Text(pDX, IDC_CURSTATE1, m_cur1);
	DDX_Text(pDX, IDC_CURSTATE2, m_cur2);
	DDX_Text(pDX, IDC_CURSTATE3, m_cur3);
	DDX_Text(pDX, IDC_CURSTATE4, m_cur4);
	DDX_Text(pDX, IDC_CURSTATE5, m_cur5);
	DDX_Text(pDX, IDC_CURSTATE6, m_cur6);
	DDX_Text(pDX, IDC_CURSTATE7, m_cur7);
	DDX_Text(pDX, IDC_CURSTATE8, m_cur8);
	DDX_Text(pDX, IDC_CURSTATE9, m_cur9);
	DDX_Text(pDX, IDC_SHWPROCESS, m_process);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSHWRESULT, CDialog)
	//{{AFX_MSG_MAP(CSHWRESULT)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSHWRESULT message handlers

//DEL void CSHWRESULT::OnShwexit() 
//DEL {
//DEL 	// TODO: Add your control notification handler code here
//DEL 	OnOK();
//DEL 	DestroyWindow();
//DEL 	
//DEL }

BOOL CSHWRESULT::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	
	//UpdateData(false);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//DEL CSHWRESULT CSHWRESULT::SHOW(CEightPuzzlesDlg *p)
//DEL {
//DEL 	m_process=p->m_bpro;
//DEL 	UpdateData(false);
//DEL 
//DEL }

void CSHWRESULT::ShowReuslt(CEIGHTNUMS *p)
{ 
	int m_dStep=0;
	for(int i=0;i<=p->ResultList.GetCount();i++)
	{
      if(m_dStep==0&&p->ResultList.IsEmpty()==false)
	
	  {
		m_process.Format("%d steps are needed!",p->ResultList.GetCount()-1);
		UpdateData(false);
		UpdateWindow();
	    void *q;
	     q=p->ResultList.GetHead();
	     NightNumstate *xy;
	    xy=(NightNumstate *)q;
	    m_cur1=xy->state[0][0];
		m_cur2=xy->state[0][1];
		m_cur3=xy->state[0][2];
		m_cur4=xy->state[1][0];
		m_cur5=xy->state[1][1];
		m_cur6=xy->state[1][2];
		m_cur7=xy->state[2][0];
		m_cur8=xy->state[2][1];
		m_cur9=xy->state[2][2];
		UpdateData(false);
		UpdateWindow();
		m_dStep++;
//Sleep(100);
}

 else if(m_dStep<(p->ResultList.GetCount()-1))
	{
		POSITION tempindex;
		tempindex=p->ResultList.FindIndex(m_dStep);
		void *q;
	    q=p->ResultList.GetAt(tempindex);
	    NightNumstate *xy;
	    xy=(NightNumstate *)q;
	    m_cur1=xy->state[0][0];
		m_cur2=xy->state[0][1];
		m_cur3=xy->state[0][2];
		m_cur4=xy->state[1][0];
		m_cur5=xy->state[1][1];
		m_cur6=xy->state[1][2];
		m_cur7=xy->state[2][0];
		m_cur8=xy->state[2][1];
		m_cur9=xy->state[2][2];
		m_process.Format("the %dstep",m_dStep);
		UpdateData(false);
		UpdateWindow();
		m_dStep++;
		//UpdateData(false);
				
	}
	else
	{
		m_process.Format("now we get");
		UpdateData(false);
		void *q;
	    q=p->ResultList.GetTail();
	    NightNumstate *xy; 
	    xy=(NightNumstate *)q;
	    m_cur1=xy->state[0][0];
		m_cur2=xy->state[0][1];
		m_cur3=xy->state[0][2];
		m_cur4=xy->state[1][0];
		m_cur5=xy->state[1][1];
		m_cur6=xy->state[1][2];
		m_cur7=xy->state[2][0];
		m_cur8=xy->state[2][1];
		m_cur9=xy->state[2][2];
		UpdateData(false);
		UpdateWindow();
				
	}
	Sleep(1000+100*m_dStep);
	}
  // CEIGHTNUMS m_bfree;
   //m_bfree.FreeList(&(m_bfree.Openlist));
   //m_bfree.FreeList(&(m_bfree.Closelist));
   //m_bfree.FreeList(&(m_bfree.ResultList));
}


HBRUSH CSHWRESULT::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here

	pDC->SetTextColor(RGB(255,255,0));
	pDC->SetBkColor(RGB(0,20,200));
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -