Click here to Skip to main content
11,805,604 members (50,153 online)
Click here to Skip to main content
Add your own
alternative version

Screen Saver AppWizard

, 17 Jun 2004 CPOL 36.6K 659 23
An article on creating a Screen Saver AppWizard
// ScreenSaverWizardaw.cpp : implementation file

#include "stdafx.h"
#include "ScreenSaverWizard.h"
#include "ScreenSaverWizardaw.h"

#undef THIS_FILE
static char THIS_FILE[] = __FILE__;

// This is called immediately after the custom AppWizard is loaded.  Initialize
//  the state of the custom AppWizard here.
void CScreenSaverWizardAppWiz::InitCustomAppWiz()
	// There are no steps in this custom AppWizard.

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

// This is called just before the custom AppWizard is unloaded.
void CScreenSaverWizardAppWiz::ExitCustomAppWiz()
	// 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* CScreenSaverWizardAppWiz::Next(CAppWizStepDlg* pDlg)
		ASSERT(pDlg == NULL);	// By default, this custom AppWizard has no steps

	// Set template macros based on the project name entered by the user.

	// Get value of $$root$$ (already set by AppWizard)
	CString strRoot;
	m_Dictionary.Lookup(_T("root"), strRoot);
	// Set value of $$Doc$$, $$DOC$$
	CString strDoc = strRoot.Left(6);
	m_Dictionary[_T("Doc")] = strDoc;
	m_Dictionary[_T("DOC")] = strDoc;

	// Set value of $$MAC_TYPE$$
	strRoot = strRoot.Left(4);
	int nLen = strRoot.GetLength();
	if (strRoot.GetLength() < 4)
		CString strPad(_T(' '), 4 - nLen);
		strRoot += strPad;
	m_Dictionary[_T("MAC_TYPE")] = strRoot;

	// Return NULL to indicate there are no more steps.  (In this case, there are
	//  no steps at all.)
	return NULL;

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

	long Count=0;

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

			[Link Debug]

			[Link Release]

			[C++ Debug]

			/I "d:\imageclass\cximage" 
			/D "WIN32" 
			/D "_DEBUG" 
			/D "_WINDOWS" 
			/D "_MBCS" 
			[C++ Release]

			/I "d:\imageclass\cximage" 
			/D "WIN32" 
			/D "NDEBUG" 
			/D "_WINDOWS" 
			/D "_MBCS" 


		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);
		pConfig->AddToolSettings(L"link.exe", L"scrnsave.lib", dummy);


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

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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


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.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151002.1 | Last Updated 18 Jun 2004
Article Copyright 2004 by Fabio Fornaro
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid