Solved

Modifying an AppWiz application to be console application

Posted on 1998-02-13
1
230 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

777 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