🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12456

Re: cout, printf

#12456
From: Bob Gonder
Date: Thu, 04 Dec 2003 16:33
33 lines
2169 bytes
dESFasado wrote:

>I know maybe this is a so trivial question. I've recently moved from delphi to builder c++ and found out that's not that simple to use the console;
>
>I've search on google many code snippets that'll do the work using printf, cout and friends but none worked at all.
>
>So my question is simple. Which is the most easiest way to have a console ouput in a gui application using borlnad c++ builder 6 under windows xp?

Three ways to go about it:

1) You could write a console app instead of a gui one. (Change the
Target to console, start the program at main instead of WinMain.)

2) If you really want console output in a gui program, then you need
to create a console.

AllocConsole()
stdin = GetStdHandle(STD_INPUT_HANDLE);
stdout = GetStdHandle(STD_OUTPUT_HANDLE);

3) On the other hand, if you want text output on your gui window, you
could use something like

	switch (message) {
	case WM_PAINT:
		hdc=BeginPaint(hWnd,&ps);
		SetMapMode(hdc,MM_TEXT);
		TextOut(hdc, 70, 50, szMsg1, strlen(szMsg1) );
		TextOut(hdc, 70, 90, szMsg2, strlen(szMsg2) );
		TextOut(hdc, 70, 130, szMsg3, strlen(szMsg3) );
		TextOut(hdc, 70, 150, szMsg4, strlen(szMsg4) );
		EndPaint(hWnd,&ps);
		break;
Technical Details
Message-ID: <umnusvcv4h8ov9esm51jrb2kn602l7df46@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <oprznx7gmf3sxi43@localhost>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,3b40ef498405c7c4
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-04 08:41:14 PST
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: cout, printf
Date: Thu, 04 Dec 2003 08:33:04 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <umnusvcv4h8ov9esm51jrb2kn602l7df46@4ax.com>
References: <oprznx7gmf3sxi43@localhost>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.31.165.64
X-Trace: newsgroups.borland.com 1070555586 67.31.165.64 (4 Dec 2003 08:33:06 -0700)
Lines: 36
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail