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

📄 queenview.cpp

📁 经典的八皇后问题
💻 CPP
字号:
 // QueenView.cpp : implementation of the CQueenView class
//

#include "stdafx.h"
#include "Queen.h"

#include "QueenDoc.h"
#include "QueenView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CQueenView

IMPLEMENT_DYNCREATE(CQueenView, CView)

BEGIN_MESSAGE_MAP(CQueenView, CView)
	//{{AFX_MSG_MAP(CQueenView)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CQueenView construction/destruction

CQueenView::CQueenView()
{
	// TODO: add construction code here
    m_pDlg=new CCheckDlg;
	m_queen.Queen(0);
}

CQueenView::~CQueenView()
{
	m_pDlg->DestroyWindow();
    delete m_pDlg;
	
}

BOOL CQueenView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CQueenView drawing

void CQueenView::OnDraw(CDC* pDC)
{
	CQueenDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	m_tableDrawer.InitDC(pDC);
	CRect  rt,rt2;
//	AfxMessageBox("sdf");
	
	this->GetClientRect(rt);
	m_pDlg->GetClientRect(rt2);
	rt.bottom=rt.bottom-rt2.Height();
	TRACE("%d\n",m_pDlg->m_selectNum);
	m_tableDrawer.DrawTable(m_queen.backup[m_pDlg->m_selectNum],rt,m_pDlg->m_ischeack);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CQueenView printing

BOOL CQueenView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CQueenView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CQueenView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CQueenView diagnostics

#ifdef _DEBUG
void CQueenView::AssertValid() const
{
	CView::AssertValid();
}

void CQueenView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CQueenDoc* CQueenView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CQueenDoc)));
	return (CQueenDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CQueenView message handlers

void CQueenView::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	CString str;
	// TODO: Add your specialized code here and/or call the base class
	m_pDlg->Create(IDD_DIALOG1,this);
    MoveCheckWnd();
	
	for(int i=0;i<m_queen.iCount;i++){
		str.Format("%d",i+1);
		m_pDlg->m_checkCB.InsertString(i,str);
	}
	m_pDlg->m_checkCB.SetCurSel(0);

}

void CQueenView::MoveCheckWnd()
{
	CRect rt,rtClient,rt2;
	m_pDlg->GetClientRect(&rt);
	this->GetClientRect(&rtClient);
    rt2=CRect();
	m_pDlg->MoveWindow(0,rtClient.bottom-rt.Height(),
		rtClient.Width(),rt.Height());
}

void CQueenView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	if (m_pDlg->GetSafeHwnd()) {
		MoveCheckWnd();
	}
	
}

⌨️ 快捷键说明

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