#ifdef WIN32 #include "resource.h" #include "PromptDialog.h" #include "StdAfx.h" #include "winbuff.h" #endif // WIN32 |
#ifdef WIN32 PromptDialog* md = new PromptDialog(AfxGetMainWnd()); EnableWindow(AfxGetMainWnd()->GetSafeHwnd(),FALSE); md->m_displaytext = "Initial output string.\r\n"; md->m_strEdit1 = ""; // No input default. md->Create(); // Store the old stream handles istream *in = &cin; ostream *out = &cout; ostream *err = &cerr; // You can also specify the size of the input buffer you want. (No dire consequences for // a small buffer.) inWinStream win(md,3); cin = win; // You can also specify the size of the output buffer you want. (It will dump output as it // is filled.) The default is 256 outWinStream wout(md); cout = wout; // You can also specify the size of the error buffer you want. (It will dynamically grow // as needed.) errWinStream werr(3); cerr = werr; // Tie the input to the output so that pending output will be flushed when input is // needed. cin.tie(&cout); #endif // WIN32 |
#ifdef WIN32 // destroy our window md->DestroyWindow(); EnableWindow(AfxGetMainWnd()->GetSafeHwnd(),TRUE); // restore the streams. cout = *out; cin = *in; cerr = *err; #endif // WIN32 |
#ifdef WIN32 // Here's how to wait for an OK. // It's an unfortunate fact of life that Microsoft's implementation // of cout doesn't automatically flush on newlines. cout.flush(); md->WaitForOK(); #endif // WIN32Unfortunately, when using buffering, Microsoft's implementation of cout doesn't call my code to flush the output whenever a newline is encountered. You have to manually flush it before waiting for and OK.
Back to my code.
Last changed June 24 2005 16:01:41.
David Coppit,
david@coppit.org
There have been 1100 hits since Fri Apr 18 14:13:16 2008