N
news.tkdsoftware.com
How would one go about connecting std::cout to a CRichEditCtrl object?
--
--
news.tkdsoftware.com said:How would one go about connecting std::cout to a CRichEditCtrl object?
John Harrison said:You need to derive a class from std::streambuf that outputs to a
CRichEditCtrl object. Then you replace the stream buffer that std::cout has
with your derived buffer.
class RichEditControlBuffer : public std::streambuf
{
...
};
int main()
{
RichEditControlBuffer my_buffer;
std::streambuf* old_buffer = std::cout.rdbuf(&my_buffer);
// now std::cout is connected to your buffer;
...
std::cout(old_buffer); // restore the old buffer before you quit
}
Writing the RichEditControlBuffer class is not a trivial task. You need a
good book, like The C++ Standard Library by Josuttis.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.