Click here to Skip to main content
Licence 
First Posted 18 Apr 2004
Views 27,472
Bookmarked 14 times

Three Windows Demo

By | 18 Apr 2004 | Article
Creates other processes (windows).

Introduction

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.

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

About the Author

Roger65



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 19 Apr 2004
Article Copyright 2004 by Roger65
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid