472,971 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problems displaying output from vc++ program

Hi, I've got a simple vc++ program that basically just runs a daemon in
the background and sends update messages to a logfile as it goes along.

What I'd like to do is see these log messages also displayed in a
window - either a dos window or a 'proper' window with a text field
etc...

I can easily create a window with a text field, but I can't find any
way to attach it to my project so I can write to it from there (I'm
looking to just 'add' it to my project somehow so I can then say
mywindow.mytextfield.text = "and another thing ...\n"; or something
like that).

Alternativley I'd be happy with a dos window popping up that displays
the messages, but using cout << "and another thing ..." << endl;
doesn't make a dos window appear.

Any ideas on how to make either of these solutions work would be very
welcome - 2 vc++ developers have failed to get this working for me, so
I'll be most impressed if you manage it!!

Dec 23 '05 #1
1 1147
"royzeb" <ro******@yahoo.co.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi, I've got a simple vc++ program that basically just runs a daemon in
the background and sends update messages to a logfile as it goes along.

What I'd like to do is see these log messages also displayed in a
window - either a dos window or a 'proper' window with a text field
etc...

I can easily create a window with a text field, but I can't find any
way to attach it to my project so I can write to it from there (I'm
looking to just 'add' it to my project somehow so I can then say
mywindow.mytextfield.text = "and another thing ...\n"; or something
like that).

Alternativley I'd be happy with a dos window popping up that displays
the messages, but using cout << "and another thing ..." << endl;
doesn't make a dos window appear.

Any ideas on how to make either of these solutions work would be very
welcome - 2 vc++ developers have failed to get this working for me, so
I'll be most impressed if you manage it!!


Well, when you set out to build an application under Windows you have two
choices, and within them two more.

First, are you to build a "native" application or one that runs under the
..Net framework?

Second, does your application uses ("proper") windows for its user interface
or does it display a character-at-a-time to a console?

If you choose to target the .Net environment, and if you choose a windowed
rather than console application, then you can have the easy I/O model that
seems to be your first choice.

If you choose a native application (which I expect is what you did) you are
in for a bit more work. And as you are asking about how to create a console,
my guess is that you created a native, windowed application (one that starts
at WinMain) but did not create any windows. Of course, I could be wrong.

If that is so, you can create a console with a call to AllocConsole(). You
could use WriteConsole() to direct text there. If you want to use ordinary C
and C++ I/O then you add this little bit of voodoo to your application:

#include <io.h>
#include <stdio.h>
#include <fstream.h>

int fd;
FILE *fp;
HANDLE hCon;

AllocConsole();
hCon = GetStdHandle(STD_OUTPUT_HANDLE);

fd = _open_osfhandle(reinterpret_cast<long>(hCon), 0);
fp = _fdopen(fd, "w");

*stdout = *fp;
setvbuf(stdout, NULL, _IONBF, 0);

Regards,
Will
Dec 23 '05 #2

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

Similar topics

6
by: Ryan D. Lucey | last post by:
ok I'm trying out a small program using operator overloading from the book C++ How To Program by Deitel Deitel. In their code they use the old style headers and the program compiles and runs as...
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
5
by: Hendrik Schober | last post by:
Hi, we just run into the problem, that "default" alignment in the project properies dialog seem to be different. We have a project that's a DLL, which is linked with a couple of LIBs. All are...
2
by: electrixnow | last post by:
I am about to pull my hair out! I have VS 2005 PRO and I am coding in C++ I have a console program that parses data and creates a text output. I need to use MSWords mailmerge to merge the text...
5
by: Mike Krell | last post by:
I'm running into problems trying to override __str__ on the path class from Jason Orendorff's path module (http://www.jorendorff.com/articles/python/path/src/path.py). My first attempt to do...
3
by: Wilson | last post by:
i am very new to c++ and am creating a new program, below are two seperate parts of the program, made to run seperately, however the constructor in one works (prints "constructing" on the screen),...
1
by: rocky0893 | last post by:
hello, Can any one help me regarding displaying output on consol in VC++ .net 2005. I have tried to write "cout" and include "iostream.h". but still gave error error C2065: 'cout' : undeclared...
8
by: mickey22 | last post by:
Hi all, I am trying to compile a VC++ project and it is win32 console application.When I try to compile it I get a lot of linking problems.I have included all the header files needed for the...
9
by: =?Utf-8?B?SG93YXJkIFNtaXRo?= | last post by:
I am using VC++ 6.0 (with SP5 installed). When using WinXP this is with SP2 installed. I am developing an instrumentation system comprising a set of networked PCs connected using TCP/IP TCP links....
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.