Click here to Skip to main content
12,635,132 members (27,178 online)
Click here to Skip to main content

Stats

389.6K views
10.5K downloads
201 bookmarked
Posted

Resource ID Organiser Add-In for Visual C++ 5.0/6.0/.NET

, 10 Jan 2005 CPOL
An application/add-in to organise and renumber resource symbol IDs
ResOrg103.exe
ResOrg104.exe
ResOrgAddInSetup.exe
ResOrg.exe
BXFileDialog.dll
CJ609Lib.dll
NGLib103.dll
ResOrgAddIn.dll
ResOrgCore.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
ResOrgNETAddInSetup.msi
ResOrgNETAddInToolWindows.ocx
ResOrgNET.exe
CJ609LibVc7.dll
NGLib103Vc7.dll
ResOrgNETAddIn.dll
ResOrgNETCore.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
ReadMe.rtf
Licence.rtf
ResOrgNET_executables
CJ609LibVc7.dll
NGLib103Vc7.dll
QHTMLight.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
ResOrgNETAddIn.dll
ResOrgNETAddInToolWindows.ocx
ResOrgNETCore.dll
ResOrg103.exe
ResOrgAddIn.dll
BXFileDialog.dll
CJ609Lib.dll
ResOrg.exe
ResOrg.cnt
resorg.fts
ResOrg.hlp
ResOrgCore.dll
NGLib103.dll
BXFileDialog
BXFileDialog.dsp
Lib
Release
Res
bitmap2.bmp
FileOpen.bmp
filesave.bmp
CJLibrary
CJLibrary
CJLibrary.def
CJLibrary.dsp
CJLibrary.dsw
CJLibrarydep.jpg
CJLibraryStatic.dsp
Debug_Unicode
Release
Release_Unicode
res
Include
res
btn_arro.bmp
btn_explorer.bmp
button_images.bmp
cj_logo.bmp
dragging.cur
handcur.cur
headerba.bmp
hsplitba.cur
icr_hand.cur
nodraggi.cur
PushPin.bmp
Toolbar.bmp
vsplitba.cur
Lib
default.doxygen
NGLibrary
Bin
NGLibrary.def
NGLibrary.dsp
NGLibrary.dsw
Release
Res
Drives.bmp
Release
ResOrg.dsw
ResOrgAddIn
Release
Res
HtmlDoc.ico
ResOrg.ico
ResOrgDoc.ico
TBarLrge.bmp
TBarMedm.bmp
Toolbar.bmp
WorkspaceTabs.bmp
ResOrgAddIn.def
ResOrgAddIn.dsp
ResOrgAddIn.odl
ResOrgAddIn_Res.hm
ResOrgApp
Lint
Release
Res
HtmlDoc.ico
MAINFRAM.BMP
ResOrg.ico
ResOrgDoc.ico
TBarLrge.bmp
TBarMedm.bmp
Toolbar.bmp
workspace.ico
WorkspaceTabs.bmp
ResOrgApp.dsp
ResOrgApp_Res.hm
ResOrgApp_Res.resorg
ResOrgCore
Lint
Release
Res
Anna.bmp
BuildOptions.ico
ComCtl Version Prompt.rtf
File Reload Warning Ex.rtf
File Reload Warning.rtf
Global Next Symbol Value Warning Prompt.rtf
information.ico
Invalid Symbol Name.rtf
Mailing List Prompt.rtf
Next Symbol Value Warning Prompt.rtf
project context menu.bmp
project.ico
RenumWiz Completion.rtf
Report.ico
ResOrg Logo.bmp
ResOrg Updated.rtf
ResOrg.ico
resource file.ico
riverblade_logo.bmp
solution.ico
Symbol Delete Warning.rtf
Symbol Name Warning.rtf
Symbol Rename Warning.rtf
SymbolFile.ico
Symbols Delete Warning.rtf
sym_binary.ico
sym_bitmap.ico
sym_command.ico
sym_control.ico
sym_dialog.ico
sym_icon.ico
sym_menu.ico
sym_prompt.ico
sym_resource.ico
sym_string.ico
Toolbar.bmp
VcAddIn.ico
VersionCheck.ico
warning.ico
WizardHeader256.bmp
WizardWatermark256.bmp
ResOrgCore.def
ResOrgCore.dsp
ResOrgCore_Res.hm
ResOrgCore_Res.resorg
Xml
ProblemSymbolReportHtml.xsl
SymbolsReportHtml.xsl
ResOrgNETAddIn
AddIn.def
Release
Res
AddIn.rgs
HtmlDoc.ico
ResOrg.ico
ResOrgDoc.ico
Toolbar.bmp
WorkspaceTabs.bmp
ResOrgNETAddInSetup
Banner.jpg
Intro screen.jpg
Licence.rtf
ReadMe.rtf
Release
ResOrg.ico
ResOrgNETAddInSetup.vdproj
ResOrgNETAddInToolWindows
Release
Res
Edit.ico
Properties.ico
Renumber.ico
ResOrgNETAddInToolWindows.ico
ResOrgNETAddInToolWindowsCtrl.bmp
ResOrgNETAddInToolWindows.def
SatelliteDll
Release
res
AboutBoxCmd.bmp
OpenResOrgCmd.bmp
OptionsCmd.bmp
ViewMainToolWinCmd.bmp
/*
 *	$Header: /MindProbe/IMapi.cpp 38    11/03/98 2:10p Admin $
 *
 *	$Log: /MindProbe/IMapi.cpp $
 * 
 * 38    11/03/98 2:10p Admin
 * Added jackpot and gambit.  Removed random player selection.  Added part
 * of MPede support.  Added response to ChatgamesID request.  Added code
 * to track server name.
 */
#include "StdAfx.h"

#include <mapi.h>

#include "NGMapi.h"


HINSTANCE CNGMapi::m_hInstMail = (HINSTANCE) NULL;
BOOL	  CNGMapi::m_isMailAvail = (BOOL) -1;


CNGMapi::CNGMapi()
{
	m_error = 0;										//	Initially error free
	m_uError = 0;

	memset(&m_message, 0, sizeof(MapiMessage));
	memset(&m_from, 0, sizeof(MapiRecipDesc));
	m_message.lpOriginator = &m_from;
	m_from.ulRecipClass = MAPI_ORIG;

	if (m_hInstMail == (HINSTANCE) NULL)				//	Load the MAPI dll
		m_hInstMail = ::LoadLibraryA("MAPI32.DLL");

	if (m_hInstMail == (HINSTANCE) NULL)
	{
		AfxMessageBox(AFX_IDP_FAILED_MAPI_LOAD);
		m_error = IMAPI_LOADFAILED;
		return;
	}

	ASSERT(m_hInstMail != (HINSTANCE) NULL);			//	Now get the pointer to the send function
	(FARPROC&) m_lpfnSendMail = GetProcAddress(m_hInstMail, "MAPISendMail");

	if (m_lpfnSendMail == NULL)
	{
		AfxMessageBox(AFX_IDP_INVALID_MAPI_DLL);
		m_error = IMAPI_INVALIDDLL;
		return;
	}

	ASSERT(m_lpfnSendMail != NULL);
}

CNGMapi::~CNGMapi()
{
	if (m_hInstMail != (HINSTANCE) NULL)
		::FreeLibrary(m_hInstMail);

	m_hInstMail = (HINSTANCE) NULL;
	
	free(m_message.lpFiles);
	free(m_message.lpRecips);
}

BOOL CNGMapi::HasEmail()
{
	if (m_isMailAvail == (BOOL) -1)
		m_isMailAvail = ::GetProfileInt(_T("MAIL"), _T("MAPI"), 0) != 0 && SearchPath(NULL, _T("MAPI32.DLL"), NULL, 0, NULL, NULL) != 0;

	return m_isMailAvail;
}

UINT CNGMapi::Error()
{
	UINT temp = m_error;

	m_error = IMAPI_SUCCESS;
	return temp;
}

BOOL CNGMapi::AllocNewTo()
{
	//	Allocate a new MapiRecipDesc structure and initialise it to all zeros
	m_message.lpRecips = (MapiRecipDesc *) realloc(m_message.lpRecips, (m_message.nRecipCount + 1) * sizeof(MapiRecipDesc));
	memset(&m_message.lpRecips[m_message.nRecipCount], 0, sizeof(MapiRecipDesc));

	ASSERT(m_message.lpRecips);
	return m_message.lpRecips != (MapiRecipDesc *) NULL;
}

BOOL CNGMapi::To(LPCTSTR recip)
{
	if (AllocNewTo())
	{
		//	We succeeded in allocating a new recipient record
		m_message.lpRecips[m_message.nRecipCount].lpszName = (LPTSTR) malloc(strlen(recip) + 1);
		strcpy(m_message.lpRecips[m_message.nRecipCount].lpszName, recip);
		m_message.lpRecips[m_message.nRecipCount].ulRecipClass = MAPI_TO;
		m_message.nRecipCount++;
		return TRUE;
	}

	m_error = IMAPI_FAILTO;
	return FALSE;
}

BOOL CNGMapi::Cc(LPCTSTR recip)
{
	if (AllocNewTo())
	{
		//	We succeeded in allocating a new recipient record
		m_message.lpRecips[m_message.nRecipCount].lpszName = (LPTSTR) malloc(strlen(recip) + 1);
		strcpy(m_message.lpRecips[m_message.nRecipCount].lpszName, recip);
		m_message.lpRecips[m_message.nRecipCount].ulRecipClass = MAPI_CC;
		m_message.nRecipCount++;
		return TRUE;
	}

	m_error = IMAPI_FAILCC;
	return FALSE;
}

BOOL CNGMapi::Attach(LPCTSTR path, LPCTSTR name)
{
	//	Add a new attachment record
	m_message.lpFiles = (MapiFileDesc *) realloc(m_message.lpFiles, (m_message.nFileCount + 1) * sizeof(MapiFileDesc));
	memset(&m_message.lpFiles[m_message.nFileCount], 0, sizeof(MapiFileDesc));

	ASSERT(m_message.lpFiles);
	
	if (m_message.lpFiles == (MapiFileDesc *) NULL)
	{
		m_error = IMAPI_FAILATTACH;
		return FALSE;
	}

	m_message.lpFiles[m_message.nFileCount].lpszPathName = (LPTSTR) malloc(strlen(path) + 1);
	strcpy(m_message.lpFiles[m_message.nFileCount].lpszPathName, path);

	if (name != (LPCTSTR) NULL)
	{
		m_message.lpFiles[m_message.nFileCount].lpszFileName = (LPTSTR) malloc(strlen(name) + 1);
		strcpy(m_message.lpFiles[m_message.nFileCount].lpszFileName, name);
	}

	m_message.nFileCount++;
	return TRUE;
}


ULONG CNGMapi::Send(ULONG flags)
{
	CWaitCursor wait;
	int			offset = m_text.GetLength();

	//	Add 1 space per attachment at the end of the body text.
	m_text += CString(' ', m_message.nFileCount);

	//	Set each attachment to replace one of the added spaces at the end of the body text.
	for (UINT i = 0; i < m_message.nFileCount; i++)
		m_message.lpFiles[i].nPosition = offset++;

	m_message.lpszNoteText = (LPTSTR) (LPCTSTR) m_text;	//  Set the body text

	// prepare for modal dialog box
	AfxGetApp()->EnableModeless(FALSE);
	HWND hWndTop;
	CWnd* pParentWnd = CWnd::GetSafeOwner(NULL, &hWndTop);

	// some extra precautions are required to use MAPISendMail as it
	// tends to enable the parent window in between dialogs (after
	// the login dialog, but before the send note dialog).
	pParentWnd->SetCapture();
	::SetFocus(NULL);
	pParentWnd->m_nFlags |= WF_STAYDISABLED;

	int nError = m_lpfnSendMail(0, (ULONG) pParentWnd->GetSafeHwnd(), &m_message, MAPI_LOGON_UI | flags, 0);

	// after returning from the MAPISendMail call, the window must
	// be re-enabled and focus returned to the frame to undo the workaround
	// done before the MAPI call.
	::ReleaseCapture();
	pParentWnd->m_nFlags &= ~WF_STAYDISABLED;

	pParentWnd->EnableWindow(TRUE);
	::SetActiveWindow(NULL);
	pParentWnd->SetActiveWindow();
	pParentWnd->SetFocus();
	
	if (hWndTop != NULL)
		::EnableWindow(hWndTop, TRUE);
	
	AfxGetApp()->EnableModeless(TRUE);

	//	Now free malloced recipients
	for (i = 0; i < m_message.nRecipCount; i++)
		free(m_message.lpRecips[i].lpszName);

	//	Then free malloced attachments
	for (i = 0; i < m_message.nFileCount; i++)
	{
		free(m_message.lpFiles[i].lpszPathName);
		free(m_message.lpFiles[i].lpszFileName);
	}

	if (nError != SUCCESS_SUCCESS && nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
	{
		AfxMessageBox(AFX_IDP_FAILED_MAPI_SEND);
//		return FALSE;
	}

//	return TRUE;
	m_uError = nError;
	return nError;
}


CString CNGMapi::GetLastError(void) const
{
	CString sMsg;
	switch (m_uError)
	{
		case MAPI_E_AMBIGUOUS_RECIPIENT:
			sMsg = _T("A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set. No message was sent.");
			break;

		case MAPI_E_ATTACHMENT_NOT_FOUND: 
			sMsg = _T("The specified attachment was not found. No message was sent.");
			break;

		case MAPI_E_ATTACHMENT_OPEN_FAILURE:
			sMsg = _T("The specified attachment could not be opened. No message was sent.");
			break;

		case MAPI_E_BAD_RECIPTYPE:
			sMsg = _T("The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC. No message was sent.");
			break;

		case MAPI_E_FAILURE:
			sMsg = _T("One or more unspecified errors occurred. No message was sent.");
			break;

		case MAPI_E_INSUFFICIENT_MEMORY:
			sMsg = _T("There was insufficient memory to proceed. No message was sent.");
			break;

		case MAPI_E_INVALID_RECIPS:
			sMsg = _T("One or more recipients were invalid or did not resolve to any address.");
			break;

		case MAPI_E_LOGIN_FAILURE:
			sMsg = _T("There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed. No message was sent.");
			break;

		case MAPI_E_TEXT_TOO_LARGE: 
			sMsg = _T("The text in the message was too large. No message was sent.");
			break;

		case MAPI_E_TOO_MANY_FILES:
			sMsg = _T("There were too many file attachments. No message was sent.");
			break;

		case MAPI_E_TOO_MANY_RECIPIENTS:
			sMsg = _T("There were too many recipients. No message was sent.");
			break;

		case MAPI_E_UNKNOWN_RECIPIENT:
			sMsg = _T("A recipient did not appear in the address list. No message was sent.");
			break;

		case MAPI_E_USER_ABORT:
			sMsg = _T("The user canceled one of the dialog boxes. No message was sent");
			break;

		case SUCCESS_SUCCESS:
			sMsg = _T("The message was sent successfully");
			break;

		default:
			sMsg = _T("Unknown error");
			break;
	}
	return sMsg;
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Anna-Jayne Metcalfe
Founder Riverblade Limited
United Kingdom United Kingdom
I haven't always written software for a living. When I graduated from Surrey University in 1989, it was with an Electronic Engineering degree, but unfortunately that never really gave me the opportunity to do anything particularly interesting (with the possible exception of designing Darth Vader's Codpiece * for the UK Army in 1990).
    * Also known as the Standard Army Bootswitch. But that's another story...
Since the opportunity arose to lead a software team developing C++ software for Avionic Test Systems in 1996, I've not looked back. More recently I've been involved in the development of subsea acoustic navigation systems, digital TV broadcast systems, port security/tracking systems, and most recently software development tools with my own company, Riverblade Ltd.

One of my personal specialities is IDE plug-in development. ResOrg was my first attempt at a plug-in, but my day to day work is with Visual Lint, an interactive code analysis tool environment with works within the Visual Studio and Eclipse IDEs or on build servers.

I love lots of things, but particularly music, photography and anything connected with history or engineering. I despise ignorant, intolerant and obstructive people - and it shows...I can be a bolshy cow if you wind me up the wrong way...Laugh | :laugh:

I'm currently based 15 minutes walk from the beach in Bournemouth on the south coast of England. Since I moved here I've grown to love the place - even if it is full of grockles in Summer!

You may also be interested in...

Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161208.2 | Last Updated 10 Jan 2005
Article Copyright 2001 by Anna-Jayne Metcalfe
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid