473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 1163
"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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.