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

📄 ga_saview.cpp

📁 采用遗传模拟退火的方法解决TSP问题
💻 CPP
字号:
// GA_SAView.cpp : implementation of the CGA_SAView class
//

#include "stdafx.h"
#include "GA_SA.h"

#include "GA_SADoc.h"
#include "GA_SAView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CGA_SAView

IMPLEMENT_DYNCREATE(CGA_SAView, CListView)

BEGIN_MESSAGE_MAP(CGA_SAView, CListView)
	//{{AFX_MSG_MAP(CGA_SAView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_MESSAGE(WM_INFOVIEWAPPEND, OnAppendOutputInfo)
	ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGA_SAView construction/destruction

CGA_SAView::CGA_SAView()
{
	// TODO: add construction code here

}

CGA_SAView::~CGA_SAView()
{
}

BOOL CGA_SAView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
	cs.style |= WS_HSCROLL | WS_VSCROLL;
	cs.style |= LVS_REPORT;

	return CListView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CGA_SAView drawing

void CGA_SAView::OnDraw(CDC* pDC)
{
	CGA_SADoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

void CGA_SAView::OnInitialUpdate()
{
	CListView::OnInitialUpdate();

	CListCtrl& control = GetListCtrl();
	control.InsertColumn(0, _T(""),LVCFMT_LEFT );
	control.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER );

	// TODO: You may populate your ListView with items by directly accessing
	//  its list control through a call to GetListCtrl().
}

/////////////////////////////////////////////////////////////////////////////
// CGA_SAView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CGA_SAView diagnostics

#ifdef _DEBUG
void CGA_SAView::AssertValid() const
{
	CListView::AssertValid();
}

void CGA_SAView::Dump(CDumpContext& dc) const
{
	CListView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CGA_SAView message handlers
void CGA_SAView::AddString(CString strAppendString)
{
    CListCtrl& control = GetListCtrl();
	int nIndex = control.GetItemCount();

	nIndex = control.GetItemCount();
	
	control.InsertItem( nIndex, strAppendString );
	//保证可见,FALSE 表示不可部分可见
	control.EnsureVisible( nIndex, FALSE );
	
}

void CGA_SAView::OnAppendOutputInfo(WPARAM pString, LPARAM nType)
{
	CString *pAddstring = (CString*)pString;
	AddString( *pAddstring );
}

void CGA_SAView::ClearInfos()
{
	CListCtrl& control = GetListCtrl();
	control.DeleteAllItems();
}

⌨️ 快捷键说明

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