Click here to Skip to main content
13,092,862 members (68,352 online)
Click here to Skip to main content
Add your own
alternative version


15 bookmarked
Posted 18 Apr 2004

Three Windows Demo

, 18 Apr 2004
Rate this:
Please Sign up or sign in to vote.
Creates other processes (windows).


This demo shows how to create a process to open a second window and pass data and Windows messages to the second window. The CreateProcess() function can either start a module or start a command line module. You could, for example, open a new command line window "notepad.exe", and pass it command line arguments.

This demo uses both interfaces. The code for this can be found in: ConsoleDemo.cpp. It is constructed before the dialog box is opened. The module now has to be tied to a CWnd pointer, this is done with the "FindWindow()" function. FindWindow will try to point to a window that matches the window title of the module. Now that we have a pointer initialized, we can pass it data using WM_COPYDATA Windows message. MyWindow is a Win32 Application only because I needed a message handler, you could use a Win32 Console Application and pass it command line arguments only.

Command.exe is the third window, it's a simple application that processes only command line information and calls system() function. ConsoleDemo has four commands:

  1. "new" causes the other window to be redrawn using a custom WM_USER message.
  2. "exit" which first closes the other window and then closes itself.
  3. "dir" displays the current directory and,
  4. "ver" displays the Windows version which are command line arguments.

Command.exe waits for the user to press any key and closes itself. Note: when you drag or resize ConsoleDemo's dialog box, the other window is sent WM_ERASEBKGND message, then you can use the "new" command to invalidate its window. All three modules have a post-build step that copies its Release executable to the ConsoleDemo directory.

*** VERY IMPORTANT *** ConsoleDemo is looking for the other two windows to be in the same directory as ConsoleDemo, therefore you must do a Release Build of MyWindow and Command before running ConsoleDemo. Any comments are welcome.


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


About the Author

United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Michael Haephrati מיכאל האפרתי25-Jan-13 5:09
mvpMichael Haephrati מיכאל האפרתי25-Jan-13 5:09 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 19 Apr 2004
Article Copyright 2004 by Roger65
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid