Solved

Modifying an AppWiz application to be console application

Posted on 1998-02-13
1
233 Views
Last Modified: 2013-11-20
Is it possible to modify a standard program generated
by the AppWizard so it can be started As a console application?

It also has to be able to accept input :  
 main(int argc, char **argv)

and the AppWizard program can't be a spawned
process of the console app.

Thanks,

Eric
0
Comment
Question by:nielsew
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
mikeblas earned 20 total points
ID: 1316172
It is possible, but it's not worth the trouble--you end up removing ten times more than you would use.

I don't understand your requirement that "the AppWizard program can't be a spawned process of the console app". I can't reconcile your statement: a console application is free to create windows, so that can't be what you mean.  And a console app can spawn a /SUBSYSTEM:WINDOWS application any time it wants to.  So, that can't be what you mean.

What is it that you're really trying to say?

You don't mention which version of which development environment you're using, so I'll assume you're using VC++ 5.0. Anyhow, to get an MFC app that runs as a console, you should:

1) Ask for a new "Win32 Console Application"
2) In the resulting project, use the "Settings" command in the "project menu"
3) Make sure "All Configurations" is selected in the "Settings For" box
4) In the "Microsoft Foundation Classes" drop down, select either "in a Shared DLL" or "in a static library"--whichever you like.
5) Press OK to close the "Project Settings" dialog
6) Create a new *.CPP file.  Name it whatever you like.
7) Add the *.CPP file you created to your project.
8) Edit the *.CPP file.  Put this code in it:

#include <afx.h>
#include <afxwin.h>

CWinApp theApp;

int main(int argc, char* argv[])
{
   int nRetVal = 1;

   if (!AfxWinInit(GetModuleHandle(), NULL, GetCommandLine(), 0))
   {
      // MFC failed to initialize.
      printf("startup error!");
   }
   else
   {
      // your app is up!  make whatever Win32 API, standard lib,
      // or MFC calls you'd like.

      CString str("Hello");
      printf("%s world!\n", (LPCTSTR) str);
      nRetVal = 0;
   }

   return nRetVal;
}

9) Save it.
10) Build it.

You're in business.

.B ekiM



0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 56
if loop in java 3 174
sum13 challenge 24 150
Message not shown 5 106
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question