473,385 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

RichEdit & Streams

How would one go about connecting std::cout to a CRichEditCtrl object?

--

Jul 22 '05 #1
2 1794

"news.tkdsoftware.com" <ch***@noreply.nospam.tkdsoftware.com> wrote in
message news:wc****************************@tkdsoftware.co m...
How would one go about connecting std::cout to a CRichEditCtrl object?


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.

john
Jul 22 '05 #2
"John Harrison" <jo*************@hotmail.com> wrote in message
news:2s*************@uni-berlin.de...

"news.tkdsoftware.com" <ch***@noreply.nospam.tkdsoftware.com> wrote in
message news:wc****************************@tkdsoftware.co m...
How would one go about connecting std::cout to a CRichEditCtrl object?

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.


Equally, if not more useful for this would be the Langer & Kreft book.

-Mike
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: regisser | last post by:
Is it true that cin,cout, etc are initialized on first use? And that no runtime initialization before main is needed; the first time the object is accessed, it grabs dynamic memory typically like 1K...
5
by: murlbrown | last post by:
I am using a class library built by michael kennedy that creates a system wide hook on the WH_KEYBOARD_LL, but I wanted to changed it to become a hook for a RichEdit box in another application. ...
0
by: PowerPlane | last post by:
Hi, all Happy valentine I am struggling to insert an animated-gif into a CRichEditCtrl. Before I post this question here, I did some googling. And I found an article to introduce how to insert a...
1
by: Patty O'Dors | last post by:
Hi I'm trying to create an application with a RichEdit control, I found that CreateWindow always returns a null hWnd unless I call LoadLibrary("riched20.dll") first (the error code from...
0
by: murlbrown | last post by:
I am using a class library built by michael kennedy that creates a system wide hook on the WH_KEYBOARD_LL, but I wanted to changed it to become a hook for a RichEdit box in another application. ...
8
by: Viswanathan S | last post by:
Hi All! What is the major difference or advantage of using VB.NET to create application compare to Visual Basic 6.0? Thanks in Advance S. Viswanathan
46
by: Sensei | last post by:
I was having an interesting discussion about the ANSI C and some ``weird inconsistencies'', or at least what at first sight can be seen as an imbalance. I hope someone can satisfy my curiosity. ...
30
by: Alf P. Steinbach | last post by:
I once suggested in that SomeOne Else(TM) should propose a string value class that accepted literals and char pointers and so on, with possible custom deleter, and in case of literal strings just...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.