By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Nov 7 '06 #1
Share this Question
Share on Google+
24 Replies


P: n/a
In article <11**********************@m73g2000cwd.googlegroups .com>,
tizi_de <ti*************@web.dewrote:
>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

Nov 7 '06 #2

P: n/a
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
Nov 7 '06 #3

P: n/a
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

Nov 7 '06 #4

P: n/a
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)
Nov 7 '06 #5

P: n/a
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)
Nov 7 '06 #6

P: n/a
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
Nov 7 '06 #7

P: n/a
jacob navia <ja***@jacob.remcomp.frwrites:
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) ks***@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.
Nov 7 '06 #8

P: n/a
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>
Nov 7 '06 #9

P: n/a
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.

Nov 7 '06 #10

P: n/a

tizi_de <ti*************@web.dewrote in message
news:11**********************@m73g2000cwd.googlegr oups.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

Nov 7 '06 #11

P: n/a
On 7 Nov 2006 03:03:37 -0800, in comp.lang.c , "tizi_de"
<ti*************@web.dewrote:
>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
Nov 7 '06 #12

P: n/a
On Tue, 07 Nov 2006 22:51:51 +0100, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
>
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
Nov 7 '06 #13

P: n/a
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
Nov 7 '06 #14

P: n/a
In article <r8********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>On Tue, 07 Nov 2006 22:51:51 +0100, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
>>
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.

Nov 8 '06 #15

P: n/a
jacob navia <ja***@jacob.remcomp.frwrote:
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
Nov 8 '06 #16

P: n/a
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.

Nov 8 '06 #17

P: n/a
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>
Nov 9 '06 #18

P: n/a
CBFalconer <cb********@yahoo.comwrites:
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) ks***@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.
Nov 9 '06 #19

P: n/a
Keith Thompson <ks***@mib.orgwrites:
CBFalconer <cb********@yahoo.comwrites:
>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) ks***@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.
Nov 9 '06 #20

P: n/a
Keith Thompson wrote:
CBFalconer <cb********@yahoo.comwrites:
>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>

Nov 9 '06 #21

P: n/a
2006-11-09 <45***************@yahoo.com>,
CBFalconer wrote:
Keith Thompson wrote:
>CBFalconer <cb********@yahoo.comwrites:
>>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)
Nov 9 '06 #22

P: n/a
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>
Nov 9 '06 #23

P: n/a
On 7 Nov 2006 23:03:53 GMT, in comp.lang.c , "Default User"
<de***********@yahoo.comwrote:
>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
Nov 9 '06 #24

P: n/a
Mark McIntyre <ma**********@spamcop.netwrote:
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
Nov 10 '06 #25

This discussion thread is closed

Replies have been disabled for this discussion.