Click here to Skip to main content
Click here to Skip to main content

Three Windows Demo

, 18 Apr 2004
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

Roger65

United States United States
No Biography provided

Comments and Discussions

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

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

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

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