Listing 1 Definition of classes MyDebugStreambuf and MyDebugStream

class MyDebugStreambuf : public strstreambuf
{
public:
    MyDebugStreambuf( BOOL UseMessageBox, char* pTitle );
    ~MyDebugStreambuf()
    {
        delete [];
    }
    virtual int overflow( int ch );
    virtual int sync();
protected:
    void Flush();

    BOOL  m_UseMessageBox;
    char* m_pTitle;
    unsigned m_BufferSize;
    char* m_pBuffer;
};

class MyDebugStream : public ostream
{
public:
    MyDebugStream( BOOL UseMessageBox = FALSE, char* pTitle = NULL );
protected:
    MyDebugStreambuf m_buf;
};

#define FLUSH_TO_BOX 0x01
#define FLUSH_TO_DEBUG 0x02

ostream& BoxFlush( ostream& os );

ostream& DebugFlush( ostream& os );
// End of File