Output to a control instead of the MS Dos box for C programs

  • Follow


Hello all,

I'm looking for a sample program in C to print out lines not to the
standard MS Dos Box but into a different control e.g. text control.

Has C the possibility to do printouts to a control instead of using the
MS Dos Box? And what control can I use for this purpose when I need to
have the most similar look to the MS Dos Box?

Every help is greatly appreciated.
Thanks in advance.

With kind regards,
Tiziana

0
Reply tiziana.ravalli (1) 11/7/2006 11:03:37 AM

In article <1162897417.327888.130450@m73g2000cwd.googlegroups.com>,
tizi_de <tiziana.ravalli@web.de> wrote:
>Hello all,
>
>I'm looking for a sample program in C to print out lines not to the
>standard MS Dos Box but into a different control e.g. text control.
>
>Has C the possibility to do printouts to a control instead of using the
>MS Dos Box? And what control can I use for this purpose when I need to
>have the most similar look to the MS Dos Box?

Off topic.  Not portable.  Cant discuss it here.  Blah, blah, blah.

Useful clc-related links:

http://en.wikipedia.org/wiki/Aspergers
http://en.wikipedia.org/wiki/Clique
http://en.wikipedia.org/wiki/C_programming_language

0
Reply gazelle2 (1306) 11/7/2006 11:10:59 AM


tizi_de wrote:
> 
> I'm looking for a sample program in C to print out lines not to the
> standard MS Dos Box but into a different control e.g. text control.
> 
> Has C the possibility to do printouts to a control instead of using
> the MS Dos Box? And what control can I use for this purpose when I
> need to have the most similar look to the MS Dos Box?

See the links below.

-- 
Some useful references about C:
  <http://www.ungerhu.com/jxh/clc.welcome.txt>
  <http://www.eskimo.com/~scs/C-faq/top.html>
  <http://benpfaff.org/writings/clc/off-topic.html>
  <http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
  <http://www.dinkumware.com/refxc.html>           (C-library}
  <http://gcc.gnu.org/onlinedocs/>                  (GNU docs)
  <http://clc-wiki.net>                               (C-info)


0
Reply cbfalconer (19183) 11/7/2006 12:06:37 PM

On 7 Nov 2006 03:03:37 -0800, "tizi_de" wrote:
>I'm looking for a sample program in C to print out lines not to the
>standard MS Dos Box but into a different control e.g. text control.
>Has C the possibility to do printouts to a control instead of using the
>MS Dos Box? 

Of course, don't you know that you can do anything in C?

>And what control can I use for this purpose when I need to
>have the most similar look to the MS Dos Box?

Write your output to a file with extension *.html and the following
structure: 

<html>
  <body>
    <pre>

// your output here

    </pre>
  </body>
</html>

Open that file in/with your browser. 

Good luck,
Roland Pibinger
0
Reply rpbg123 (870) 11/7/2006 12:15:22 PM

tizi_de wrote:

> I'm looking for a sample program in C to print out lines not to the
> standard MS Dos Box but into a different control e.g. text control.
>
> Has C the possibility to do printouts to a control instead of using the
> MS Dos Box? And what control can I use for this purpose when I need to
> have the most similar look to the MS Dos Box?

try comp.os.ms-windows.programmer.win32 where you might get better
answers.
Ignore Kenny he's the group idiot.


-- 
Nick Keighley

0
Reply nick_keighley_nospam (4574) 11/7/2006 1:09:07 PM

Nick Keighley said:

<snip>

> Ignore Kenny he's the group idiot.

With the greatest respect, Nick, I cannot agree with your choice of article.

-- 
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
0
Reply invalid171 (6555) 11/7/2006 2:33:45 PM

tizi_de a �crit :
> Hello all,
> 
> I'm looking for a sample program in C to print out lines not to the
> standard MS Dos Box but into a different control e.g. text control.
> 
> Has C the possibility to do printouts to a control instead of using the
> MS Dos Box? And what control can I use for this purpose when I need to
> have the most similar look to the MS Dos Box?
> 
> Every help is greatly appreciated.
> Thanks in advance.
> 
> With kind regards,
> Tiziana
> 

Many people have done that, a "printf" in a control.
It is not VERY hard to do, but maybe the simplest thing
is to create the control, then call SetWindowText with
the handle of the control and the text you want to put into it.


(I am assuming is a static text control or an edit field)

More sophisticated usages with scrolling, etc are more demanding and
you would have to reimplement the "Dos box" what is nothing else
than a window with scrolling in it.

jacob
0
Reply jacob (2538) 11/7/2006 4:14:09 PM

jacob navia wrote:
> tizi_de a �crit :
>>
>> I'm looking for a sample program in C to print out lines not to the
>> standard MS Dos Box but into a different control e.g. text control.
>>
>> Has C the possibility to do printouts to a control instead of using
>> the MS Dos Box? And what control can I use for this purpose when I
>> need to have the most similar look to the MS Dos Box?
> 
> Many people have done that, a "printf" in a control.
> It is not VERY hard to do, but maybe the simplest thing
> is to create the control, then call SetWindowText with
> the handle of the control and the text you want to put into it.

Haven't you learned yet that SetWindowText and 'a control' have
nothing to do with standard C?  Neither does a MS Dos Box, nor a
handle.  Please stop cluttering this group with off-topic
foolishness.

-- 
Chuck F (cbfalconer at maineline dot net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>


0
Reply cbfalconer (19183) 11/7/2006 6:48:56 PM

jacob navia <jacob@jacob.remcomp.fr> writes:
> tizi_de a �crit :
>> Hello all,
>> I'm looking for a sample program in C to print out lines not to the
>> standard MS Dos Box but into a different control e.g. text control.
>> Has C the possibility to do printouts to a control instead of using
>> the
>> MS Dos Box? And what control can I use for this purpose when I need to
>> have the most similar look to the MS Dos Box?
>>
>
> Many people have done that, a "printf" in a control.
> It is not VERY hard to do, but maybe the simplest thing
> is to create the control, then call SetWindowText with
> the handle of the control and the text you want to put into it.
[snip]

jacob's advice may be correct, but since he's not talking about
standard C, most of us here can't confirm or refute his information.

Tiziana: You need to post to a newsgroup that's specific to your
system.  comp.os.ms-windows.programmer.win32 *might* be the right
place.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.
0
Reply kst-u (21460) 11/7/2006 6:49:44 PM

CBFalconer wrote:
> jacob navia wrote:
> 
>>tizi_de a �crit :
>>
>>>I'm looking for a sample program in C to print out lines not to the
>>>standard MS Dos Box but into a different control e.g. text control.
>>>
>>>Has C the possibility to do printouts to a control instead of using
>>>the MS Dos Box? And what control can I use for this purpose when I
>>>need to have the most similar look to the MS Dos Box?
>>
>>Many people have done that, a "printf" in a control.
>>It is not VERY hard to do, but maybe the simplest thing
>>is to create the control, then call SetWindowText with
>>the handle of the control and the text you want to put into it.
> 
> 
> Haven't you learned yet that SetWindowText and 'a control' have
> nothing to do with standard C?  Neither does a MS Dos Box, nor a
> handle.  Please stop cluttering this group with off-topic
> foolishness.
> 

A handle is an opaque pointer.

Its definition can be expressed in standard see as:

struct window;

typedef struct window *WindowHandle; // Or HWND for short.

This is very common in windows systems, and since the Mac,
opaque pointers are part of the life of C programmers.

0
Reply jacob (2538) 11/7/2006 9:51:51 PM

tizi_de <tiziana.ravalli@web.de> wrote in message
news:1162897417.327888.130450@m73g2000cwd.googlegroups.com...

> Hello all,
>
> I'm looking for a sample program in C to print out lines not to the
> standard MS Dos Box but into a different control e.g. text control.
>
> Has C the possibility to do printouts to a control instead of using the
> MS Dos Box? And what control can I use for this purpose when I need to
> have the most similar look to the MS Dos Box?
>
OFF TOPIC!!!

> Every help is greatly appreciated.
> Thanks in advance.
>
> With kind regards,
> Tiziana
>
But since you asked so nicely...

First off, I'm assuming you're talking about using something like
printf() to print to a Windows "control" rather than the actual function
found in the winapi (or equivalent) for printing to the control.  To
do the latter, check your Windows API package documentation...

However, to do the former, sure, I do it all the time, but as
usual exactly how you code this depends on what you really
want and what you're starting off with...

Here's the basic trick though: you have to selectively
re-define "printf()" to "print" to the control as if it
were the "console" (what you're calling a "DOS Box", or
equivalently, an "xterm" in Unix).  Here's how I do it,
but again, your mileage may vary:

#ifdef __WINGUI__
#include <vcl.h>
#pragma hdrstop
#include <p_output.h>
#define printf gui_printf
#endif

Now this assumes a couple of things.  First, I'm using
a particular development package (so "vcl.h" may be
something else for you, or you are using the "winapi" package
available bone-stock free from Microsoft on their website, which
may be the best idea of all, frankly).  Second, this
is clearly "dual-use" code; I can conditionally compile
it as either Windows GUI application or as a "console"
(or "xterm") command-line interface application.

So if I compile the thing as a Windows GUI application,
the pre-processor turns all occurences of printf() into
gui_printf(), which is declared in "p_output.h" and defined
in a file called "p_output.c" which is linked into your
program.

gui_printf() is declared with the exact same "signature"
as "printf()", and defined as follows:

int gui_printf(char *format,...) {
    unsigned print_length;

    p_line_buffer[0]=NUL;
    va_list ap;

    va_start(ap,format);
    vsprintf(p_line_buffer,format,ap);
    va_end(ap);

    print_length=(int)strlen(p_line_buffer);

    print_line_buffer();

    return print_length;
    }

Note that the trick here is the use of the "vsprintf()"
function to handle all the functionality of "printf()" without
the nasty consequence of actually sending the output to
the "console".  Instead, the formatted output is "printed"
to a buffer, and then the buffer is "printed" to the
Windows control by the "print_line_buffer()" function.

Now this is where you have to figure out where you're
coming from and where you "want to go today".  What "control"
do you "print" to?  Well, it's been a while since I looked
directly at the winapi package, but I think it's called
the "memo" control.  In any event, it's the one Microsoft
uses in "Notepad" for displaying and editing relatively
small (36K limit) text-only files (my development package
supplies a "visual component" class called "TMemo" that
I use for this purpose, so unless you use the same package
the calls and configuration of this "object" won't make
too much sense).

But you'll probably want to implement some type of  "scrolling"
functionality to allow you to freely and asynchronously "print"
to the control in the same way that "printf()" prints to
the "console".  One thing is for sure: if you use the "memo" control,
your program will blow up to smithereens if you exceed the 36K text
limit, so unless you are sure you won't exceed that amount of
text, you'll have to "scroll out" old text from the "memo" control
buffer in order to "scroll in" new text.

This actually can be implemented by creating a "console buffer"
that ties into the calls to the "memo" control (or whatever it's called),
but I think you'll always wind up with (I've wound up with) some
fairly small "flickering" when scrolling large amounts of text because
the control was not designed to scroll asynchronous amounts of
text in the first place, just display a discrete single block of text.

For me, it's OK, but I think to get rid of that artifact
completely, you would have to go back to scratch and
work with rudimentary calls like "WM_PAINT" or whatever
and build your own console "work-alike"...

---
William Ernest Reid



0
Reply hormelfree (257) 11/7/2006 9:58:40 PM

On 7 Nov 2006 03:03:37 -0800, in comp.lang.c , "tizi_de"
<tiziana.ravalli@web.de> wrote:

>Hello all,
>
>I'm looking for a sample program in C to print out lines not to the
>standard MS Dos Box but into a different control e.g. text control.

Assuming you're using Windows, you need to ask in a Windows
programming group, GUI interfaces are not part of hte C language. 
-- 
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place. 
 Therefore, if you write the code as cleverly as possible, you are, 
 by definition, not smart enough to debug it."
--Brian Kernighan
0
Reply markmcintyre (4547) 11/7/2006 10:13:11 PM

On Tue, 07 Nov 2006 22:51:51 +0100, in comp.lang.c , jacob navia
<jacob@jacob.remcomp.fr> wrote:

>
>A handle is an opaque pointer.

So you claim. Its impossible to verify that here, since its not part
of standard C. 

You /know/ this is offtopic, why are you persisting in being such a
jerk?

>This is very common in windows systems, and since the Mac,
>opaque pointers are part of the life of C programmers.

So what? Cola and cake part of the life of C programmers. Are either
of those topical here? 
-- 
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place. 
 Therefore, if you write the code as cleverly as possible, you are, 
 by definition, not smart enough to debug it."
--Brian Kernighan
0
Reply markmcintyre (4547) 11/7/2006 10:15:52 PM

Mark McIntyre wrote:


> So what? Cola and cake part of the life of C programmers. Are either
> of those topical here? 


I didn't know there was going to be cake today. What kind?




Brian
0
Reply defaultuserbr (3657) 11/7/2006 11:03:53 PM

In article <r812l211jhfl7sbrs10a778594bh1h21hb@4ax.com>,
Mark McIntyre  <markmcintyre@spamcop.net> wrote:
>On Tue, 07 Nov 2006 22:51:51 +0100, in comp.lang.c , jacob navia
><jacob@jacob.remcomp.fr> wrote:
>
>>
>>A handle is an opaque pointer.
>
>So you claim. Its impossible to verify that here, since its not part
>of standard C. 
>
>You /know/ this is offtopic, why are you persisting in being such a
>jerk?
>
>>This is very common in windows systems, and since the Mac,
>>opaque pointers are part of the life of C programmers.
>
>So what? Cola and cake part of the life of C programmers. Are either
>of those topical here? 

You guys really need to get a grip.

0
Reply gazelle2 (1306) 11/8/2006 2:27:15 AM

jacob navia <jacob@jacob.remcomp.fr> wrote:

> tizi_de a �crit :
> > I'm looking for a sample program in C to print out lines not to the
> > standard MS Dos Box but into a different control e.g. text control.
> > 
> > Has C the possibility to do printouts to a control instead of using the
> > MS Dos Box? And what control can I use for this purpose when I need to
> > have the most similar look to the MS Dos Box?
> 
> Many people have done that, a "printf" in a control.
> It is not VERY hard to do, but maybe the simplest thing
> is to create the control, then call SetWindowText with
> the handle of the control and the text you want to put into it.
> 
> (I am assuming is a static text control or an edit field)

Not necessarily correct, and very unlikely to be sufficient. Thus jacob
proves once more both the inadvisability of answering off-topic
questions in comp.lang.c, and the lack of depth of his own knowledge.

Richard
0
Reply rlb (4118) 11/8/2006 8:03:52 AM

CBFalconer wrote:
>
> See the links below.
>
>   <http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)

You could consider linking to n1124 , as there are important
differences between n869 and the actual C99 text.

0
Reply oldwolf (2278) 11/8/2006 10:34:58 PM

Old Wolf wrote:
> CBFalconer wrote:
>> See the links below.
>>
>>   <http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
> 
> You could consider linking to n1124 , as there are important
> differences between n869 and the actual C99 text.

However N1124 doesn't offer a text version.  Bad.

-- 
Chuck F (cbfalconer at maineline dot net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>


0
Reply cbfalconer (19183) 11/9/2006 12:41:37 AM

CBFalconer <cbfalconer@yahoo.com> writes:
> Old Wolf wrote:
>> CBFalconer wrote:
>>> See the links below.
>>>
>>>   <http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
>> 
>> You could consider linking to n1124 , as there are important
>> differences between n869 and the actual C99 text.
>
> However N1124 doesn't offer a text version.  Bad.

Using Adobe Reader, I was able to load n1124.pdf and export it as
text.  Other PDF readers can probably do the same thing.  I haven't
really tried using the resulting text version; I just use the pdf.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.
0
Reply kst-u (21460) 11/9/2006 2:43:30 AM

Keith Thompson <kst-u@mib.org> writes:
> CBFalconer <cbfalconer@yahoo.com> writes:
>> Old Wolf wrote:
>>> CBFalconer wrote:
>>>> See the links below.
>>>>
>>>>   <http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
>>> 
>>> You could consider linking to n1124 , as there are important
>>> differences between n869 and the actual C99 text.
>>
>> However N1124 doesn't offer a text version.  Bad.
>
> Using Adobe Reader, I was able to load n1124.pdf and export it as
> text.  Other PDF readers can probably do the same thing.  I haven't
> really tried using the resulting text version; I just use the pdf.

And Ghostview's seems to give a cleaner text conversion than Adobe
Reader does.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.
0
Reply kst-u (21460) 11/9/2006 2:55:35 AM

Keith Thompson wrote:
> CBFalconer <cbfalconer@yahoo.com> writes:
>> Old Wolf wrote:
>>> CBFalconer wrote:
>>>> See the links below.
>>>>
>>>>   <http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
>>>
>>> You could consider linking to n1124 , as there are important
>>> differences between n869 and the actual C99 text.
>>
>> However N1124 doesn't offer a text version.  Bad.
> 
> Using Adobe Reader, I was able to load n1124.pdf and export it as
> text.  Other PDF readers can probably do the same thing.  I haven't
> really tried using the resulting text version; I just use the pdf.

I use the text version all the time.  It is quickly and easily
searched and/or grepped.  I modified the published version slightly
(reducing the lh margin, and stripping the page breaks) so it is
easily used for usenet quotes, etc.  The result is bz2d, and
available on:

  <http://cbfalconer.home.att.net/download/>

The results of a text dump from N1124 are virtually useless.  So I
put up with the differences.

-- 
Chuck F (cbfalconer at maineline dot net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>

0
Reply cbfalconer (19183) 11/9/2006 3:12:55 AM

2006-11-09 <45529CB7.82398F53@yahoo.com>,
CBFalconer wrote:
> Keith Thompson wrote:
>> CBFalconer <cbfalconer@yahoo.com> writes:
>>> Old Wolf wrote:
>>>> CBFalconer wrote:
>>>>> See the links below.
>>>>>
>>>>>   <http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
>>>>
>>>> You could consider linking to n1124 , as there are important
>>>> differences between n869 and the actual C99 text.
>>>
>>> However N1124 doesn't offer a text version.  Bad.
>> 
>> Using Adobe Reader, I was able to load n1124.pdf and export it as
>> text.  Other PDF readers can probably do the same thing.  I haven't
>> really tried using the resulting text version; I just use the pdf.
>
> I use the text version all the time.  It is quickly and easily
> searched and/or grepped.  I modified the published version slightly
> (reducing the lh margin, and stripping the page breaks) so it is
> easily used for usenet quotes, etc.  The result is bz2d, and
> available on:
>
>   <http://cbfalconer.home.att.net/download/>
>
> The results of a text dump from N1124 are virtually useless.  So I
> put up with the differences.

Has anyone tried making a "polished" text version of N1124? Would such 
a thing be compatible with WG14's copyrights (though it seems to me that 
if your modifications to n869 are ok, this would be)
0
Reply random21 (344) 11/9/2006 3:59:43 AM

Jordan Abel wrote:
> CBFalconer wrote:
>
.... snip ...
>>
>> I use the text version all the time.  It is quickly and easily
>> searched and/or grepped.  I modified the published version slightly
>> (reducing the lh margin, and stripping the page breaks) so it is
>> easily used for usenet quotes, etc.  The result is bz2d, and
>> available on:
>>
>>   <http://cbfalconer.home.att.net/download/>
>>
>> The results of a text dump from N1124 are virtually useless.  So I
>> put up with the differences.
> 
> Has anyone tried making a "polished" text version of N1124? Would
> such a thing be compatible with WG14's copyrights (though it seems
> to me that if your modifications to n869 are ok, this would be)

I have no reason to assume that it is ok, I only know that I have
received no requests to withdraw it.

-- 
Chuck F (cbfalconer at maineline dot net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>


0
Reply cbfalconer (19183) 11/9/2006 11:28:41 AM

On 7 Nov 2006 23:03:53 GMT, in comp.lang.c , "Default User"
<defaultuserbr@yahoo.com> wrote:

>Mark McIntyre wrote:
>
>
>> So what? Cola and cake part of the life of C programmers. Are either
>> of those topical here? 
>
>
>I didn't know there was going to be cake today. What kind?

Oat. 
-- 
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place. 
 Therefore, if you write the code as cleverly as possible, you are, 
 by definition, not smart enough to debug it."
--Brian Kernighan
0
Reply markmcintyre (4547) 11/9/2006 10:37:19 PM

Mark McIntyre <markmcintyre@spamcop.net> wrote:

> On 7 Nov 2006 23:03:53 GMT, in comp.lang.c , "Default User"
> 
> >Mark McIntyre wrote:
> >
> >> So what? Cola and cake part of the life of C programmers. Are either
> >> of those topical here? 
> >
> >I didn't know there was going to be cake today. What kind?
> 
> Oat. 

Once the Scotsman, always the Scotsman, right Mark?

I wanted Cherry Cake. At least it _starts_ with a C.

Richard
0
Reply rlb (4118) 11/10/2006 8:19:36 AM

24 Replies
29 Views

(page loaded in 0.264 seconds)


Reply: