home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_09
/
1109059a
< prev
next >
Wrap
Text File
|
1993-07-08
|
1KB
|
49 lines
// ostrwnd.cpp
#include "stdhdr.h"
#include "ostrwnd.h"
ostreamWnd::ostreamWnd (const char * window_name)
: CStrWnd (window_name)
{
max_lines_in_buffer = 50;
CMenu * control_menu = GetSystemMenu (FALSE);
VERIFY (control_menu->EnableMenuItem
(SC_CLOSE, MF_GRAYED ) != -1);
}
BEGIN_MESSAGE_MAP (ostreamWnd, CStrWnd)
ON_WM_CLOSE ()
END_MESSAGE_MAP ()
void ostreamWnd::PutText (const char * buf,
int no_of_chars)
{
int ub = text_buffer.GetUpperBound ();
if (ub < 0)
// text_buffer is empty so initialise it
// by adding a null entry
{
text_buffer.Add ("");
ub = text_buffer.GetUpperBound ();
}
char * ptr = (char *) buf;
for (int i = 0; i < no_of_chars; i++)
{
if (*buf != '\n')
// Append the character to the end of the
// last CString in the text_buffer
text_buffer [ub] += *buf;
else
{
text_buffer.Add (""); // Add a new line
ub = text_buffer.GetUpperBound ();
}
buf++;
}
while (text_buffer.GetUpperBound ()
>= max_lines_in_buffer)
text_buffer.RemoveAt (0);
UpdateScreen ();
}