| View previous topic :: View next topic |
| Author |
Message |
chris Guest
|
Posted: Tue Dec 23, 2003 12:13 pm Post subject: TMemo and streams |
|
|
Hi all,
I am on a big problem I can not solve from hours. I am now wondering if what
i want to do is posible....
Well, here is my problem:
I want to link a TMemo with a std::ostream. What does it mean you will say?
It means that every change on the stream must appear on the TMemo. See the
following example:
1/put a memo on a form
2/put a button on the form
3/declare a private std::ostream variable in your main form and initialize
it in ctor:
#include <iostream>
[....]
private:
std::ostream* os;
#include <fstream>
[...]
void __fastcall TForm1::TForm1(TObject* AOwner):
TForm(AOwner)
{
os = new std::ofstream("test.txt");
}
4/define the OnClick button method to:
void __fastcall Button1OnClick(TObject* Sender)
{
os << "button1 were clicked" << std::endl;
}
what I want to do is print "button1 were click" into the TMemo without
adding a line like Memo1->Lines->Add("button1 were clicked") under os <<
line.
So my questions are:
Is it possible?
If no why?
If yes, how?
If you wonder why I want to do so here is the answer: I have a library that
write logs via std::ostream and I want these logs appeared in my memo.
Of course, I do not have the source code to modify the way the library logs
(if i have them, I would simply add the Memo1->Lines->Add to the
code).
thanks for your help
--
chris
|
|
| Back to top |
|
 |
Rodolfo Frino - Macrosoft Guest
|
Posted: Tue Dec 23, 2003 1:30 pm Post subject: Re: TMemo and streams |
|
|
Do you have a log file with the logs> if so, can you load that log file, or
the
desired part of it, into your Memo?
Rodolfo
"chris" <blin_c (AT) epita (DOT) fr> wrote
| Quote: | Hi all,
I am on a big problem I can not solve from hours. I am now wondering if
what
i want to do is posible....
|
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Tue Dec 23, 2003 1:37 pm Post subject: Re: TMemo and streams |
|
|
chris wrote:
| Quote: | void __fastcall TForm1::TForm1(TObject* AOwner):
TForm(AOwner)
{
os = new std::ofstream("test.txt");
what I want to do is print "button1 were click" into the TMemo without
adding a line like Memo1->Lines->Add("button1 were clicked") under os
line.
So my questions are:
Is it possible?
|
Don't know yet. But I do nots ee a connection with your library.
| Quote: | If you wonder why I want to do so here is the answer: I have a library that
write logs via std::ostream and I want these logs appeared in my memo.
|
But... is the library writing a std::ostream that you declared first
and then handed ove to that library ? In other words: is the
ostream used by the library accessible ?
Hans.
|
|
| Back to top |
|
 |
chris Guest
|
Posted: Tue Dec 23, 2003 2:27 pm Post subject: Re: TMemo and streams |
|
|
"Rodolfo Frino - Macrosoft" <Macrosoft (AT) Atlantis (DOT) com> a écrit dans le message
de news: [email]3fe8436e (AT) newsgroups (DOT) borland.com[/email]...
| Quote: | Do you have a log file with the logs> if so, can you load that log file,
or
the
desired part of it, into your Memo?
|
yes I have but it will be a pain to periodically reload the memo contents
from the file...
I really need the link between std::osteram and a TMemo.
This is a network application with big amount of log. What I want to do is
directly display the logs in my memo.
After I will have manage that, I will do syntax highliting which will be
another problem.
--
chris
|
|
| Back to top |
|
 |
chris Guest
|
Posted: Tue Dec 23, 2003 2:31 pm Post subject: Re: TMemo and streams |
|
|
"Hans Galema" <dontusethis (AT) dontusethis (DOT) nl> a écrit dans le message de news:
[email]3fe84429 (AT) newsgroups (DOT) borland.com[/email]...
| Quote: | chris wrote:
void __fastcall TForm1::TForm1(TObject* AOwner):
TForm(AOwner)
{
os = new std::ofstream("test.txt");
what I want to do is print "button1 were click" into the TMemo without
adding a line like Memo1->Lines->Add("button1 were clicked") under os
line.
So my questions are:
Is it possible?
Don't know yet. But I do nots ee a connection with your library.
|
My library writes logs in a std::ostream and I want to display them in a
TMemo instead of (or in the same time that) in the file.
| Quote: |
If you wonder why I want to do so here is the answer: I have a library
that
write logs via std::ostream and I want these logs appeared in my memo.
But... is the library writing a std::ostream that you declared first
and then handed ove to that library ? In other words: is the
ostream used by the library accessible ?
|
That is the second solution: I am doing something like:
std::ostream* os = new std::ofstream("test.log");
MyLib* lib = new MyLib(*os); //proto is: MyLib(std::osteram&);
So yes the stream is accessible and its type is std::ostream.
thanks for your attention
--
chris
|
|
| Back to top |
|
 |
Timothy H. Buchman Guest
|
Posted: Tue Dec 23, 2003 3:34 pm Post subject: Re: TMemo and streams |
|
|
"chris" <blin_c> wrote
| Quote: | I really need the link between std::osteram and a TMemo.
|
You've said that you don't have the library source code. So in what
way is the ostream accessible to you? Even if you have access to the
stream variable ("os" in your example), I can't see any way to access
data that were streamed out at an earlier time-unless the stream can
be read as well, in which case you could check whether the seek
pointer has changed...
| Quote: | After I will have manage that, I will do syntax highliting which
will be
another problem.
|
You can't do highlighting (other than
capitalization) in a TMemo, so you will probably have to switch to
TRichEdit or one of the third-party components derived from it around.
You might as well start with the same component you'll finish with.
--
Timothy H. Buchman
========================================
City Center Theater, New York NY
mail address tbuchmanPLEASE(at sign)REMOVEcitycenterD O Torg
Search .borland message archive on http://www.tamaracka.com/search.htm
|
|
| Back to top |
|
 |
chris Guest
|
Posted: Wed Dec 24, 2003 8:26 am Post subject: Re: TMemo and streams |
|
|
"Timothy H. Buchman" <tbuchmanREMOVE(at)PLEASEcitycenter D O To r g> a écrit
dans le message de news: 3fe861a9$1 (AT) newsgroups (DOT) borland.com...
| Quote: | "chris" <blin_c> wrote in message
news:3fe84ff6$1 (AT) newsgroups (DOT) borland.com...
I really need the link between std::osteram and a TMemo.
You've said that you don't have the library source code. So in what
way is the ostream accessible to you? Even if you have access to the
stream variable ("os" in your example), I can't see any way to access
data that were streamed out at an earlier time-unless the stream can
be read as well, in which case you could check whether the seek
pointer has changed...
|
The other post I did to Hans demonstrate how I access the std::ostream.
| Quote: |
After I will have manage that, I will do syntax highliting which
will be
another problem.
You can't do highlighting (other than
capitalization) in a TMemo, so you will probably have to switch to
TRichEdit or one of the third-party components derived from it around.
You might as well start with the same component you'll finish with.
|
As I said, it will be another problem.
For the moment, I concentrate myself on the log display (TMemo or TRichEdit,
it does not matter).
--
chris
|
|
| Back to top |
|
 |
chris Guest
|
Posted: Wed Dec 24, 2003 10:09 am Post subject: Re: TMemo and streams |
|
|
I manage to solve the pb.
The library modelisation provided a hack.
--
chris
|
|
| Back to top |
|
 |
|