Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SIMPLE way to use TextOut for multiple lines???

734 views
Skip to first unread message

Al Blake

unread,
Aug 1, 1998, 3:00:00 AM8/1/98
to
I am porting a functional C++ console application to the MFC framework to
produce a windows app. The interface is VERY simple and all the app needs to
do is write to the scrolling view. There is no file I/O, it just needs to
show a 'log' of what it is doing on the view.
I am trying to show the output using the CDC::TextOut() function but cannot
find a simple way to get it to print multiple line text strings.
I want to duplicate the functionality of:

printf("This is the first line\nThis is the second line\n");

in the console app but TextOut does NOT recognise \n as a linefeed character
and the whole thing comes out on one line. Is there a simple way to write
plain text to a view so that multiple lines can be written and the write
position updated automatically? (I have tried CDC:SetTextAlign() but that
only seems to set the horizontal position not the vertical one.)

Am I really going to be forced to calculate and save the position of the
text after every write? It seems a huge overhead just to display a simple
scrolling log.
Thanks for any tips or suggestions as to the simplest way to accomplish
this.


--
Al Blake
Information Technology Manager
Secretariat of the Pacific Community
Noumea, New Caledonia

Dirk Djuga

unread,
Aug 1, 1998, 3:00:00 AM8/1/98
to
Al Blake wrote in message <35c32...@home.spc.org.nc>...


You should simply use a CEditView to show text. Next best would be a
CEdit...

If there is any reason why you couldn't, you can use CDC::DrawText() instead
of TextOut(). It draws multiline text ("\r\n" is the linefeed token)

cU
--
Dirk Djuga mailto:di...@solaris.stuttgart.netsurf.de
http://djuga.home.ml.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Retriever 2.0 is out: http://retriever.home.ml.org

Shareware image viewer, thumbnailer & database
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


David Lowndes

unread,
Aug 1, 1998, 3:00:00 AM8/1/98
to
>I am trying to show the output using the CDC::TextOut() function but cannot
>find a simple way to get it to print multiple line text strings.
>I want to duplicate the functionality of:
>
> printf("This is the first line\nThis is the second line\n");
>
>Is there a simple way to write
>plain text to a view so that multiple lines can be written and the write
>position updated automatically?

Al,

Have a look at DrawText. I think that'll do what you want, including
calculating the bounding rectangle extent of the text.

Dave
----
Address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow up email copies.

Spytech

unread,
Aug 10, 1998, 3:00:00 AM8/10/98
to
> >I want to duplicate the functionality of:
> >
> > printf("This is the first line\nThis is the second line\n");
> >
> >in the console app but TextOut does NOT recognise \n as a linefeed
> character
> >and the whole thing comes out on one line. Is there a simple way to
write


try to use \n\r or \r\n ... with the EditBox and simple label the \r\n is a
line feed!


Any One

unread,
Aug 11, 1998, 3:00:00 AM8/11/98
to
I missed the original thread, but couldn't you use DrawText ?

Spytech <ain...@hotmail.com> wrote in article
<01bdc4b3$26d62380$2503d8d4@stighy>...

0 new messages