Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Win32 Simple Application AppWizard

, 22 Jun 2004
An article on creating an AppWizard to create Win32 based applications.
win32appwiz_src.zip
SimpleApplicationWizard
hlp
SIMPLEAPPLICATIONWIZARD.HLP
SimpleApplicationWizard.hm
SimpleApplicationWizard.hpj
SimpleApplicationWizard.LOG
SimpleApplicationWizard.ph
SimpleApplicationWizard.rtf
res
SimpleApplicationWizard.ico
SimpleApplicationWizard.dsp
SimpleApplicationWizard.dsw
Template
confirm.inf
newproj.inf
// SimpleApplicationWizardaw.cpp : implementation file
//

#include "stdafx.h"
#include "SimpleApplicationWizard.h"
#include "SimpleApplicationWizardaw.h"
#include "chooser.h"

#ifdef _PSEUDO_DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// This is called immediately after the custom AppWizard is loaded.  Initialize
//  the state of the custom AppWizard here.
void CSimpleApplicationWizardAppWiz::InitCustomAppWiz()
{
	// Create a new dialog chooser; CDialogChooser's constructor initializes
	//  its internal array with pointers to the steps.
	m_pChooser = new CDialogChooser;

	// Set the maximum number of steps.
	SetNumberOfSteps(LAST_DLG);

	// TODO: Add any other custom AppWizard-wide initialization here.
}

// This is called just before the custom AppWizard is unloaded.
void CSimpleApplicationWizardAppWiz::ExitCustomAppWiz()
{
	// Deallocate memory used for the dialog chooser
	ASSERT(m_pChooser != NULL);
	delete m_pChooser;
	m_pChooser = NULL;

	// TODO: Add code here to deallocate resources used by the custom AppWizard
}

// This is called when the user clicks "Create..." on the New Project dialog
//  or "Next" on one of the custom AppWizard's steps.
CAppWizStepDlg* CSimpleApplicationWizardAppWiz::Next(CAppWizStepDlg* pDlg)
{
	// Delegate to the dialog chooser
	return m_pChooser->Next(pDlg);
}

// This is called when the user clicks "Back" on one of the custom
//  AppWizard's steps.
CAppWizStepDlg* CSimpleApplicationWizardAppWiz::Back(CAppWizStepDlg* pDlg)
{
	// Delegate to the dialog chooser
	return m_pChooser->Back(pDlg);
}

void CSimpleApplicationWizardAppWiz::CustomizeProject(IBuildProject* pProject)
{
	CComPtr<IConfigurations> pConfigs;
	HRESULT hr=pProject->get_Configurations(&pConfigs);
	if(FAILED(hr))
	{
		AfxMessageBox("An error occurred while obtaining the IConfigurations interface pointer");
		return;
	}
	CComPtr<IConfiguration> pConfig;
	CComVariant index;
	VARIANT dummy = {0};
	CComBSTR Name;
	CString text;
	CString output;

	long Count=0;
	pConfigs->get_Count(&Count);

	// Iterate through all the configurations of the project
	for(int i=1; i <= Count; i++)
	{
		index=i;
		hr=pConfigs->Item(index, &pConfig);
		if(FAILED(hr))
		{
			AfxMessageBox("An error occurred while obtaining the IConfiguration pointer");
			return;
		}
		pConfig->get_Name(&Name);
		text = Name;
		
		if (text.Find("Debug") == -1)
			output = "Release";
		else
			output = "Debug";

		text.Format("/out:\"%s/%s.exe\"",output,m_Dictionary["Root"]);
		pConfig->AddToolSettings(L"link.exe", text.AllocSysString(), dummy);
		
		pConfig->AddToolSettings(L"mfc", L"0", dummy);
		pConfig->AddToolSettings(L"link.exe", L"/subsystem:windows", dummy);
		pConfig->AddToolSettings(L"link.exe", L"/incremental:yes", dummy);
		pConfig->AddToolSettings(L"link.exe", L"/machine:I386", dummy);
		pConfig->AddToolSettings(L"link.exe", L"/nodefaultlib:\"MSVCRTD\"", dummy);

		// change the preprocessor definitions
		pConfig->AddToolSettings(L"cl.exe", L"/D \"_WINDOWS\"", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/nologo", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/D \"_MBCS\"", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/D \"WIN32\"", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/Od", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/MD", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/W3", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/ZI", dummy);	// Program Database for "Edit & Continue" can not be defined when /driver option is defined
		pConfig->AddToolSettings(L"cl.exe", L"/GZ", dummy);	//GZ initializes all local variables not explicitly initialized by the program. It fills all memory used by these variables with 0xCC
		pConfig->AddToolSettings(L"cl.exe", L"/Zi", dummy);	// Program Database
		pConfig->AddToolSettings(L"cl.exe", L"/Oi", dummy);	// 
		pConfig->AddToolSettings(L"cl.exe", L"/Gz", dummy);	// __stdcall calling convention
		pConfig->AddToolSettings(L"cl.exe", L"/Gz", dummy);
		

		// Change the libraries
		pConfig->AddToolSettings(L"link.exe", L"kernel32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"user32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"gdi32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"winspool.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"comdlg32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"advapi32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"shell32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"ole32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"oleaut32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"uuid.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"odbc32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"odbccp32.lib", dummy);
		
		CString cstr;
		
		if(m_Dictionary.Lookup(TEXT("INIT_COMMON_CONTROLS"),cstr))
		{
			pConfig->AddToolSettings(L"link.exe", L"comctl32.lib", dummy);
		}

		if(m_Dictionary.Lookup(TEXT("USE_WINSOCK"),cstr))
		{
			pConfig->AddToolSettings(L"link.exe", L"ws2_32.lib", dummy);
		}

		pConfig=NULL;
	}
	pConfigs=NULL;
}


// Here we define one instance of the CSimpleApplicationWizardAppWiz class.  You can access
//  m_Dictionary and any other public members of this class through the
//  global SimpleApplicationWizardaw.
CSimpleApplicationWizardAppWiz SimpleApplicationWizardaw;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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

Fabio Fornaro
Software Developer (Senior)
Italy Italy
Worked as a Java developer targeting J2EE and J2SE for half a decade.
 
Now he's employed for Avanade as a Senior Associate Consultant on Microsoft technologies.
 
His hobbies are Win32 programming using SDK, MFC, ATL and COM; playing guitar and listening to music.

| Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 23 Jun 2004
Article Copyright 2004 by Fabio Fornaro
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid