Article View: borland.public.cppbuilder.nativeapi
Article #7953Re: Console Window for GUI application
From: Bob Gonder
Date: Thu, 09 Dec 2004 15:16
Date: Thu, 09 Dec 2004 15:16
27 lines
1883 bytes
1883 bytes
Richard Ulrich wrote: > > // redirect unbuffered STDOUT to the console > pStdHandle = reinterpret_cast<intptr_t>(::GetStdHandle(STD_OUTPUT_HANDLE)); > SetConsoleMode(stdout,ENABLE_PROCESSED_OUTPUT | You don't have the right stdout. Take another look at my code. > hConHandle = _open_osfhandle(pStdHandle, O_TEXT); > pFile = _fdopen(hConHandle, "w"); > *stdout = *pFile; This doesn't look right. It looks like you are copying the FILE structure. I would think stdout = pfile; > ret = setvbuf(stdout, NULL, _IONBF, 0); Not sure why you need setvbuf. I also find it unsettling that "*stdout=" would affect cout. Also, if the previous "copy FILE" is an error, then quite likely it would cause your "The handle is invalid." problem at this point. > ios::sync_with_stdio(true);
Technical Details
Message-ID:
<elpgr0dtlq2ctcr8soeds7hh6vi3g34a5c@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41b5d8dc@newsgroups.borland.com> <j6vbr0djl2alcs374q8q9su4vd6u88liqb@4ax.com> <41b82e09@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,29bc3d9d57e77864 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Console Window for GUI application Date: Thu, 09 Dec 2004 07:16:45 -0800 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <elpgr0dtlq2ctcr8soeds7hh6vi3g34a5c@4ax.com> References: <41b5d8dc@newsgroups.borland.com> <j6vbr0djl2alcs374q8q9su4vd6u88liqb@4ax.com> <41b82e09@newsgroups.borland.com> 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.77.144.21 X-Trace: newsgroups.borland.com 1102605402 67.77.144.21 (9 Dec 2004 07:16:42 -0800) Lines: 30 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail