Click here to Skip to main content
15,886,639 members
Articles / Programming Languages / C++

Genetic and Ant Colony Optimization Algorithms

Rate me:
Please Sign up or sign in to vote.
4.78/5 (105 votes)
26 Sep 2006CPOL11 min read 772.4K   33.9K   206  
Genetic and Ant Colony Optimization Algorithms
// ButtonDemoDoc.cpp : implementation of the CAIDoc class
//

#include "stdafx.h"
#include "AIDemo.h"
#include "AIDoc.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAIDoc

IMPLEMENT_DYNCREATE(CAIDoc, CDocument)

BEGIN_MESSAGE_MAP(CAIDoc, CDocument)
END_MESSAGE_MAP()


// CAIDoc construction/destruction

CAIDoc::CAIDoc()
{
	// TODO: add one-time construction code here

}

CAIDoc::~CAIDoc()
{
}

BOOL CAIDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}

BOOL CAIDoc::SwitchToView(CRuntimeClass* pNewViewClass)
{
   CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();
   CView* pOldActiveView = pMainWnd->GetActiveView();

   // If we're already displaying this kind of view, no need to go further.
  // if (pOldActiveView->IsKindOf(pNewViewClass))
     // return TRUE;
	
   // Set the child window ID of the active view to AFX_IDW_PANE_FIRST.
   // This is necessary so that CFrameWnd::RecalcLayout will allocate
   // this "first pane" to that portion of the frame window's client
   // area not allocated to control bars.  Set the child ID of
   // the previously active view to some other ID.
   ::SetWindowLong(pOldActiveView->m_hWnd, GWL_ID, 0);

   // create the new view
   CCreateContext context;
   context.m_pNewViewClass = pNewViewClass;
   context.m_pCurrentDoc = this;
   CView* pNewView = STATIC_DOWNCAST(CView, pMainWnd->CreateView(&context));
   if (pNewView != NULL)
   {
      // the new view is there, but invisible and not active...
      pNewView->ShowWindow(SW_SHOW);
      pNewView->OnInitialUpdate();
      pMainWnd->SetActiveView(pNewView);
      pMainWnd->RecalcLayout();

      // destroy the old view...
      pOldActiveView->DestroyWindow();
      return TRUE;
  }

  return FALSE;
}



// CAIDoc serialization

void CAIDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}


// CAIDoc diagnostics

#ifdef _DEBUG
void CAIDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CAIDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG


// CAIDoc commands

void CAIDoc::SetTitle(LPCTSTR lpszTitle)
{
	//Set the title
	CFrameWnd* pWnd = (CFrameWnd*)AfxGetMainWnd();		
	CString csTitle; 
	//csTitle.LoadString(IDS_CUSTINFO_TITLE); 

	if ( CString(lpszTitle) == CString(_T("Untitled")) ) 
	{ 
		if (pWnd) 
			pWnd->SetWindowText((LPCTSTR)(csTitle)); 
	} 
	else 
	{ 
		csTitle = csTitle + _T(" - ") + lpszTitle; 
		if (pWnd) 
			pWnd->SetWindowText((LPCTSTR)(csTitle)); 
	} 

}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions