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

Redirecting an arbitrary Console's Input/Output

, 27 Nov 2003
Redirecting an arbitrary console's input/output in a simple, graceful way
#include "StdAfx.h"
#include "demoredir.h"

CDemoRedirector::CDemoRedirector(void)
{
	m_pWnd = NULL;
}

CDemoRedirector::~CDemoRedirector(void)
{
}

void CDemoRedirector::WriteStdOut(LPCSTR pszOutput)
{
	if (m_pWnd != NULL)
	{
		int nSize = m_pWnd->GetWindowTextLength();
		m_pWnd->SetSel(nSize, nSize);
		m_pWnd->ReplaceSel(pszOutput);		// add the message to the end of Edit control
	}
}

void CDemoRedirector::WriteStdError(LPCSTR pszError)
{
	WriteStdOut("\r\nError message: ");
	WriteStdOut(pszError);
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

nickadams
Web Developer
Canada Canada
Nick Adams is one of my favorite figures in Hemingway's stories. I use it because Jeff Lee has been occupied on Codeproject.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 28 Nov 2003
Article Copyright 2003 by nickadams
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid