Click here to Skip to main content
15,066,928 members
Articles / Desktop Programming / MFC
Article
Posted 17 Oct 2000

Stats

512.9K views
12.9K downloads
231 bookmarked

QuickWin - Turn a Console Application into a Windows Program

Rate me:
Please Sign up or sign in to vote.
4.83/5 (51 votes)
17 Oct 2000
Redirect stdin, stdout and stderr into a window
QuickWin is a very useful program to spawn script programs or console applications in a Windows environment without opening a DOS box. In this article, you will see how QuickWin works.

Sample Image

Introduction

QuickWin is a Windows application that spawns a Win32 console application that redirected its stdin, stdout and stderr handles to a window. The console application is hidden and all I/O operations are made through QuickWin.

This is a very useful program to spawn script programs or console applications in a Windows environment without opening a DOS box.

How QuickWin Works

QuickWin contains one or two windows depending on whether you want the same stdout view for stderr output or another view. stdin is in the same view as stdout. The view is a CRichEditView window and is not limited in space for the output. Commands like cut, copy, paste, find are also available. QuickView can spawn console applications, shell (COMMAND.COM or CMD.EXE) or batch files. You start the console application from the command line or browse your disk. You can also stop and restart the console application many times. The content of the output view can be saved to file. The last 10 programs are saved into the registry and available for quick start.

The following parameters are available:

Full or Half Duplex

In full duplex, characters are send to stdin and displayed into the view. In half duplex, they are only sent to stdin.

Enter

The enter key (CR) can be translated into CR, LF or CR+LF.

Close on Exit

If the console application is terminated, QuickWin will terminate.

Show Child Window

You can display the DOS box child window. If you want to write into this "Console", open the "CON" file and write into it.

OEM -> Ansi

Normally, we must translate characters for console application.

Use Input Buffer

If it is not necessary to send each character one at a time to the stdin. Characters can be stored in an input buffer until CR is pressed.

Command Line

For COMMAND.COM or CMD.EXE, the command is echoed to stdout. This option removes the typed command.

Options for COMMAND.COM or CMD.EXE.

Fullduplex, CR->CR+LF,Oem->ANSI, Use input buffer and Command line.

For standard applications, remove the Command line option.

Main Points of Interest in the Source Code

A CRedirect class that can be used in any WIN32 or MFC applications. This class contains four virtual functions for notification.

C++
virtual void OnChildStarted(LPCSTR lpszCmdLine);
virtual void OnChildStdOutWrite(LPCSTR lpszOutput);
virtual void OnChildStdErrWrite(LPCSTR lpszOutput);
virtual void OnChildTerminate();

The main program is an MFC application that uses the CRedirect class. PostThreadMessage is used to post commands in a multithread environment. WM_COPYDATA is used to post messages to the window.

The MFC print preview bug is not corrected!

Thanks to Paul DiLascia for some pieces of code from TraceWin.

History

  • 17th October, 2000: Initial post

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.

Share

About the Author

Lanz Jean-Claude
Switzerland Switzerland
No Biography provided

Comments and Discussions

 
GeneralMemory Leak after calling CMainFrame::ShowSplitter( FALSE ) [modified] Pin
karel_tandd8-Jun-11 19:29
Memberkarel_tandd8-Jun-11 19:29 
GeneralGreat Code and Solution - Thanks For Sharing Pin
oldbritthumper8-Jan-10 3:27
Memberoldbritthumper8-Jan-10 3:27 
QuestionCrash,when dropfile into the app Pin
suxiaojack1-Jul-08 17:27
Membersuxiaojack1-Jul-08 17:27 
QuestionIssues in XP/VS2003 Pin
John Lomen24-Oct-07 6:13
MemberJohn Lomen24-Oct-07 6:13 
Generalkbhit that works on child stdin Pin
mycal19-Sep-07 19:11
Membermycal19-Sep-07 19:11 
QuestionSending ALT-] Pin
kdekome21-Feb-07 6:47
Memberkdekome21-Feb-07 6:47 
GeneralQuickWin Example for VB.Net Pin
gprodri8-Feb-07 7:18
Membergprodri8-Feb-07 7:18 
GeneralRe: QuickWin Example for VB.Net Pin
berilium9-Feb-07 0:32
Memberberilium9-Feb-07 0:32 
GeneralRe: QuickWin Example for VB.Net Pin
berilium9-Feb-07 4:17
Memberberilium9-Feb-07 4:17 
GeneralRe: QuickWin Example for VB.Net Pin
berilium9-Feb-07 4:33
Memberberilium9-Feb-07 4:33 
GeneralRe: QuickWin Example for VB.Net Pin
gprodri9-Feb-07 6:32
Membergprodri9-Feb-07 6:32 
GeneralRe: QuickWin Example for VB.Net Pin
berilium26-Feb-07 23:47
Memberberilium26-Feb-07 23:47 
GeneralCtrl+C and redirected console Pin
axelsw3-Nov-06 7:19
Memberaxelsw3-Nov-06 7:19 
GeneralRe: Ctrl+C and redirected console Pin
jorgening19-Jan-07 7:47
Memberjorgening19-Jan-07 7:47 
QuestionRedirect output form time critical application Pin
MariuszGorczak18-Dec-05 5:14
MemberMariuszGorczak18-Dec-05 5:14 
GeneralHaving trouble getting the output when implementing Redirect class Pin
hackerjack1235-Dec-05 15:16
Memberhackerjack1235-Dec-05 15:16 
GeneralRe: Having trouble getting the output when implementing Redirect class Pin
tish18-Mar-14 1:34
Membertish18-Mar-14 1:34 
GeneralAssertion on CRedirect Line 173 Pin
Crercio O. Silva28-Aug-05 6:06
MemberCrercio O. Silva28-Aug-05 6:06 
GeneralRe: Assertion on CRedirect Line 173 Pin
Member 1447886211-Jun-19 1:50
MemberMember 1447886211-Jun-19 1:50 
GeneralOutput is displayed after my console application exits Pin
Hamid Reza Mohammadi20-Aug-05 21:53
MemberHamid Reza Mohammadi20-Aug-05 21:53 
GeneralRe: Output is displayed after my console application exits Pin
Hamid Reza Mohammadi27-Aug-05 7:23
MemberHamid Reza Mohammadi27-Aug-05 7:23 
GeneralNot all console applications work Pin
Stuart Konen5-Apr-05 8:46
MemberStuart Konen5-Apr-05 8:46 
AnswerRe: Not all console applications work Pin
LeFauve10-Oct-05 1:55
MemberLeFauve10-Oct-05 1:55 
QuestionCan QuickWin Output be Redirected to a File? Pin
jroeb24-Mar-05 8:06
Memberjroeb24-Mar-05 8:06 
Generalwin console to wince Pin
lagunasun6-Feb-05 16:58
Memberlagunasun6-Feb-05 16:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.