Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

How to wrap an MFC collection into an STL compliant iterator with the Boost iterator_facade

, 20 Oct 2008 CPOL
How to wrap an MFC collection into an STL compliant iterator with the Boost iterator_facade.
// IterTestDoc.cpp : implementation of the CIterTestDoc class
//

#include "stdafx.h"
#include "IterTest.h"

#include "IterTestDoc.h"
#include "mfc_iters.h"
#include <string>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CIterTestDoc

IMPLEMENT_DYNCREATE(CIterTestDoc, CDocument)

BEGIN_MESSAGE_MAP(CIterTestDoc, CDocument)
   ON_COMMAND(ID_TESTMFCITERATORS_TESTCVIEWITERATOR, &CIterTestDoc::OnTestmfciteratorsTestcviewiterator)
END_MESSAGE_MAP()


// CIterTestDoc construction/destruction

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

}

CIterTestDoc::~CIterTestDoc()
{
}

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

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

	return TRUE;
}




// CIterTestDoc serialization

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


// CIterTestDoc diagnostics

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

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


// CIterTestDoc commands

void CIterTestDoc::OnTestmfciteratorsTestcviewiterator()
{
   mfc_cview_iterator it = mfc_cview_iterator(this).begin();
   while(*it)
   {
      // Repaint the view
      std::string s = "Testing CView Iterator";
      it->SendMessage(MY_TEST_MSG, 0, (LPARAM)s.c_str());
      it++;
   }
}

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)

Share

About the Author

steveb
Architect Robotz Software
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150123.1 | Last Updated 20 Oct 2008
Article Copyright 2008 by steveb
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid