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
#include "stdafx.h"

#ifdef _PSEUDO_DEBUG   // entire file

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

LONG AssertBusy = -1;
LONG AssertReallyBusy = -1;

BOOL AssertFailedLine(LPCSTR lpszFileName, int nLine)
{
	TCHAR szMessage[_MAX_PATH*2];

	InterlockedDecrement(&AssertReallyBusy);

	// format message into buffer
	wsprintf(szMessage, _T("File %hs, Line %d"),
		lpszFileName, nLine);

	TCHAR szT[_MAX_PATH*2 + 20];
	wsprintf(szT, _T("Assertion Failed: %s\n"), szMessage);
	OutputDebugString(szT);

	if (InterlockedIncrement(&AssertBusy) > 0)
	{
		InterlockedDecrement(&AssertBusy);

		// assert within assert (examine call stack to determine first one)
		DebugBreak();
		return FALSE;
	}

	// active popup window for the current thread
	HWND hWndParent = GetActiveWindow();
	if (hWndParent != NULL)
		hWndParent = GetLastActivePopup(hWndParent);

	// display the assert
	int nCode = ::MessageBox(hWndParent, szMessage, _T("Assertion Failed!"),
		MB_TASKMODAL|MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SETFOREGROUND);

	// cleanup
	InterlockedDecrement(&AssertBusy);

	if (nCode == IDIGNORE)
		return FALSE;   // ignore

	if (nCode == IDRETRY)
		return TRUE;    // will cause DebugBreak

	AfxAbort();     // should not return (but otherwise DebugBreak)
	return TRUE;
}

void Trace(LPCTSTR lpszFormat, ...)
{
	va_list args;
	va_start(args, lpszFormat);

	int nBuf;
	TCHAR szBuffer[512];

	nBuf = _vstprintf(szBuffer, lpszFormat, args);
	ASSERT(nBuf < (sizeof(szBuffer)/sizeof(szBuffer[0])));

	CString strMessage;

	if (AfxGetApp() != NULL)
		strMessage = ((CString) (AfxGetApp()->m_pszExeName)) + _T(": ");
	strMessage += szBuffer;
	OutputDebugString(strMessage);

	va_end(args);
}


#endif // _PSEUDO_DEBUG

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
Web03 | 2.8.140827.1 | Last Updated 23 Jun 2004
Article Copyright 2004 by Fabio Fornaro
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid