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

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.zip
ResOrg103.exe
resorg104.zip
ResOrg104.exe
resorgaddinsetup.zip
ResOrgAddInSetup.exe
resorgaddin_executables.zip
ResOrg.exe
BXFileDialog.dll
CJ609Lib.dll
NGLib103.dll
ResOrgAddIn.dll
ResOrgCore.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
resorgnetaddinsetup.zip
ResOrgNETAddInSetup.msi
resorgnetaddin_executables.zip
ResOrgNETAddInToolWindows.ocx
ResOrgNET.exe
CJ609LibVc7.dll
NGLib103Vc7.dll
ResOrgNETAddIn.dll
ResOrgNETCore.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
ReadMe.rtf
Licence.rtf
resorgnet_executables.zip
ResOrgNET_executables
CJ609LibVc7.dll
NGLib103Vc7.dll
QHTMLight.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
ResOrgNETAddIn.dll
ResOrgNETAddInToolWindows.ocx
ResOrgNETCore.dll
resorg_demo.zip
ResOrg103.exe
resorg_executables.zip
ResOrgAddIn.dll
BXFileDialog.dll
CJ609Lib.dll
ResOrg.exe
ResOrg.cnt
resorg.fts
ResOrg.hlp
ResOrgCore.dll
NGLib103.dll
resorg_src.zip
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
/************************************************************************
 *
 *                 Resource ID Organiser Core Library
 *
 * (c) Copyright 2000-2004 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : SymbolPropertiesGeneralPage.cpp
 *
 *  Description : CSymbolPropertiesGeneralPage - property page class
 *                
 *  Compiler    : Microsoft Visual C++ 6.0, Service Pack 3 or later
 *                Microsoft Visual C++ .NET 2002
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 98/NT/2000/XP
 *
 *  NOTE:
 *
 *    This software is provided "as is" free for personal use. All
 *    title and copyrights in and to the software, including but not
 *    limited to any images, text, etc. incorporated into it, are
 *    owned by Anna-Jayne Metcalfe, except where acknowledged otherwise.
 *
 *    Your may freely to use this code in your own products, PROVIDED
 *    this notice is not removed or modified.
 *
 *
 *    Visit http://www.annasplace.me.uk/resorg for latest updates
 *
 ************************************************************************
 *
 *   MODIFICATION HISTORY:
 *
 *           This is a controlled document. See project configuration
 *           control tool for latest version and full version history.
 *
 *    $Archive: /Projects/AddIns/ResOrg/ResOrgCore/SymbolPropertiesGeneralPage.cpp $
 *   $Revision: 18 $
 *       $Date: 23/08/04 21:37 $
 *     $Author: Anna $
 *
 *    $History: SymbolPropertiesGeneralPage.cpp $
 * 
 * *****************  Version 18  *****************
 * User: Anna         Date: 23/08/04   Time: 21:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * The value of a symbol is now automatically recalculated when its type
 * is changed
 * 
 * *****************  Version 17  *****************
 * User: Anna         Date: 11/07/04   Time: 16:13
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Added support for detection of out of range symbols
 * 
 * *****************  Version 16  *****************
 * User: Anna         Date: 25/02/03   Time: 21:25
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Symbol conflict checking now handles inter-file conflicts better
 * 
 * *****************  Version 15  *****************
 * User: Anna         Date: 2/01/03    Time: 0:10
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Added a "File Name" control
 * 
 * *****************  Version 14  *****************
 * User: Anna         Date: 3/12/02    Time: 20:17
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Replaced the rich edit control with an HTML static control
 * 
 * *****************  Version 13  *****************
 * User: Anna         Date: 25/11/02   Time: 15:19
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed website address in banner
 * 
 * *****************  Version 12  *****************
 * User: Anna         Date: 22/10/02   Time: 13:24
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Changed name/mail address (at last!)
 * 
 * *****************  Version 11  *****************
 * User: Andy         Date: 7/06/02    Time: 17:04
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Renamed the ResOrgUtils module to ResOrgCore. Updated file banners
 * accordingly
 * 
 * *****************  Version 10  *****************
 * User: Andy         Date: 27/05/02   Time: 13:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Knock on changes from CResourceSymbolBuffer (now
 * CResourceSymbolManager)
 * 
 * *****************  Version 9  *****************
 * User: Andy         Date: 12/27/01   Time: 10:39p
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Added an option to allow editing of the value but not the name
 * 
 * *****************  Version 8  *****************
 * User: Andy         Date: 23/04/01   Time: 21:15
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 1.  Added "Fix Conflict" button
 * 2.  A warning message is now displayed when a symbol is made read-only
 * 
 * *****************  Version 7  *****************
 * User: Andy         Date: 2/04/01    Time: 17:26
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 1.  Added a rich edit control (and associated icon) to warn of symbol
 * name/value conflicts
 * 2.  Improved validation routines and messages
 * 
 * *****************  Version 6  *****************
 * User: Andy         Date: 27/03/01   Time: 15:22
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 1.  Added validation of symbol names
 * 2.  When the symbol value changes, the parent property sheet is
 * notified to update the "Conflicts" page
 * 
 * *****************  Version 5  *****************
 * User: Andy         Date: 9/03/01    Time: 7:06
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Make the warning prompt when a symbol name is changed optional, so it
 * can be disabled when the dialog is used to edit the properties of a
 * symbol being added
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 17/02/01   Time: 7:05
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 1.  Converted to proeprty page
 * 2.  Added "type" icon
 * 3.  Added support for read only symbols
 * 4.  The "type" control is now set automatically when the symbol name is
 * changed
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 29/11/00   Time: 18:38
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 *  Added file banners
 *
 * $Nokeywords: $
 *
 ************************************************************************/

#include "StdAfx.h"
#include <Shlwapi.h>

#include "ResOrgCore_Priv.h"

#include "SymbolPropertiesGeneralPage.h"

#pragma comment(lib, "Shlwapi.lib")


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


// Registered message definitions
const UINT WM_SYM_CHANGING	= ::RegisterWindowMessage( _T("SymbolChanging") );


/////////////////////////////////////////////////////////////////////////////
// CSymbolPropertiesGeneralPage property page

CSymbolPropertiesGeneralPage::CSymbolPropertiesGeneralPage(void)
	: CSymbolPropertiesGeneralPage_BASE(CSymbolPropertiesGeneralPage::IDD)
{
	m_pSymbols		= NULL;
	m_pSymbol		= NULL;

	m_sName					= _T("");
	m_sType					= _T("");
	m_uIconID				= 0;
	m_uValue				= 0;
	m_sFileName				= _T("");

	m_sSavedName			= _T("");

	m_bReadOnly				= false;
	m_bEditValueOnly		= false;

	m_bWarnOnSymbolChanges = Options.WarnOnSymbolChanges();
}


CSymbolPropertiesGeneralPage::~CSymbolPropertiesGeneralPage(void)
{
}


void CSymbolPropertiesGeneralPage::DoDataExchange(CDataExchange* pDX)
{
	CSymbolPropertiesGeneralPage_BASE::DoDataExchange(pDX);

	DDX_Control(pDX,		IDC_SYM_ICON,				m_ctrlIcon);
	DDX_Control(pDX,		IDC_SYM_WARNING,			m_ctrlWarning);
	DDX_Control(pDX,		IDC_SYM_WARNING_ICON,		m_ctrlWarningIcon);
	DDX_Control(pDX,		IDC_SYM_READONLY_CAUTION,	m_ctrlReadOnlyWarning);
	DDX_SymbolName(pDX,		IDC_SYM_NAME,				m_sName);
	DDV_SymbolName(pDX,									m_sName);
	DDX_Text(pDX,			IDC_SYM_TYPE,				m_sType);
	DDX_Text(pDX,			IDC_SYM_VALUE,				m_uValue);
	DDV_MinMaxUInt(pDX,									m_uValue, 1, 65535);
	DDX_Check(pDX,			IDC_SYM_READONLY,			m_bReadOnly);

	if (!pDX->m_bSaveAndValidate)
	{
		::PathSetDlgItemPath(	m_hWnd,
								IDC_SYM_FILENAME,
								m_sFileName);
	}
}


BEGIN_MESSAGE_MAP(CSymbolPropertiesGeneralPage, CSymbolPropertiesGeneralPage_BASE)

	ON_COMMAND(				IDC_SYM_NAME,				OnCmdSymbolName)
	ON_COMMAND(				IDC_SYM_VALUE,				OnCmdSymbolValue)
	ON_COMMAND(				IDC_SYM_READONLY,			OnCmdReadOnly)
	ON_BN_CLICKED(			IDC_SYM_FIX_VALUE,			OnClickedFixValue)

END_MESSAGE_MAP()


BOOL CSymbolPropertiesGeneralPage::OnInitDialog(void)
{
	CSymbolPropertiesGeneralPage_BASE::OnInitDialog();

	m_sSavedName = m_sName;

	OnCmdSymbolName();		// Set the type and icon, and
							// check for name conflicts
	OnCmdSymbolValue();		// Check for value conflicts
	OnCmdReadOnly();		// Set available controls

	return true;
}


BOOL CSymbolPropertiesGeneralPage::OnKillActive(void)
{
	// Force the "Conflicts" page to update before losing focus
	GetParent()->SendMessage(	WM_SYM_CHANGING,
								m_uValue,
								(LPARAM)(LPCTSTR)m_sName);

	return CSymbolPropertiesGeneralPage_BASE::OnKillActive();
}


void CSymbolPropertiesGeneralPage::OnOK(void)
{
	// If the option is enabled, show a warning
	// if the symbol name has been changed
	if (m_bWarnOnSymbolChanges && (m_sSavedName != m_sName) )
	{
		CNGMessageBox dlg;
		dlg.SetMsgEx( MAKEINTRESOURCE(IDP_SYM_RENAME_WARNING), _T("RTF") );
		dlg.SetRtf();
		dlg.SetStandardIcon(IDI_EXCLAMATION);
		dlg.AddButton(IDYES, false, false, _T("Yes") );
		dlg.AddButton(IDNO, true, true, _T("No") );

		if (IDYES != dlg.DoModal())
		{
			m_sName = m_sSavedName;
			UpdateData(false);

			return;
		}
	}
	CSymbolPropertiesGeneralPage_BASE::OnOK();
}


/////////////////////////////////////////////////////////////////////////////
// CSymbolPropertiesGeneralPage operations

bool CSymbolPropertiesGeneralPage::Initialise(	CResourceSymbolManager* pSymbols,
												CResourceSymbol* pSymbol,
												bool bEditValueOnly /*= false*/)

{
	m_pSymbols	= pSymbols;
	ASSERT(NULL != m_pSymbols);

	m_pSymbol	= pSymbol;
	ASSERT(NULL != m_pSymbol);

	m_bEditValueOnly	= bEditValueOnly;

	if (NULL != m_pSymbol)
	{
		m_sName			= m_pSymbol->GetName();
		m_uValue		= m_pSymbol->GetValue();
		m_sFileName		= m_pSymbol->GetFileName();
		m_bReadOnly		= m_pSymbol->IsReadOnly();
	}

	return (m_pSymbols !=  NULL);
}


void CSymbolPropertiesGeneralPage::DisableSymbolChangeWarnings(void)
{
	m_bWarnOnSymbolChanges = false;
}



/////////////////////////////////////////////////////////////////////////////
// CSymbolPropertiesGeneralPage implementation

bool CSymbolPropertiesGeneralPage::SetTypeIcon(UINT uIconID)
{
	if ( (uIconID != 0) && ::IsWindow(m_ctrlIcon.m_hWnd) )
	{
		m_uIconID = uIconID;

		HICON hIcon = AfxGetApp()->LoadIcon(m_uIconID);
		ASSERT(hIcon != NULL);

		m_ctrlIcon.SetIcon(hIcon);

		return true;
	}
	return false;
}


void CSymbolPropertiesGeneralPage::DDX_SymbolName(CDataExchange* pDX,
												  UINT uIDC,
												  CString& rsSymbolName)
{
	if (pDX->m_bSaveAndValidate)
	{
		CString sNewSymbolName;

		::DDX_Text(pDX, uIDC, sNewSymbolName);

		// Remove whitespace before validating
		sNewSymbolName.TrimLeft();
		sNewSymbolName.TrimRight();

		// Now work out whether it's valid
		if (CResourceSymbol::IsValidName(sNewSymbolName) )
		{
			rsSymbolName = sNewSymbolName;
		}
		else
		{
			// Nope - alert the user
			CNGMessageBox dlg;

			dlg.FormatMsgEx(MAKEINTRESOURCE(IDP_SYM_NAME_INVALID),
							_T("RTF"),
							sNewSymbolName);
			dlg.SetRtf();
			dlg.SetStandardIcon(IDI_ERROR);
			dlg.AddButton(IDOK, true, true, _T("OK") );

			dlg.DoModal();

			pDX->Fail();
		}
	}
	else
	{
		::DDX_Text(pDX, uIDC, rsSymbolName);
	}
}


void CSymbolPropertiesGeneralPage::DDV_SymbolName(CDataExchange* pDX,
												  CString& rsSymbolName)
{
	if (pDX->m_bSaveAndValidate)
	{
		if ( (m_pSymbol != NULL) && !IsNameUnique(m_pSymbol, rsSymbolName, true) )
		{
			CNGMessageBox dlg;
			dlg.SetMsgEx( MAKEINTRESOURCE(IDP_SYM_NAME_WARNING), _T("RTF") );
			dlg.SetRtf();
			dlg.SetStandardIcon(IDI_ERROR);
			dlg.AddButton(IDOK, true, true, _T("OK") );

			dlg.DoModal();

			pDX->Fail();
		}
	}
}


bool CSymbolPropertiesGeneralPage::IsNameUnique(CResourceSymbol* pSymbol,
												const CString& sName,
												bool bCheckSameFileOnly) const
{
	bool bUnique = true;

	if ( (m_pSymbols != NULL) && (pSymbol != NULL) )
	{
		CResourceSymbolList listSymbols;
		m_pSymbols->GetSymbols(sName, listSymbols);

		POSITION pos = listSymbols.GetHeadPosition();
		while (pos != NULL)
		{
			CResourceSymbol* pNextSymbol = listSymbols.GetNext(pos);
			if (pNextSymbol != NULL)
			{
				if (pNextSymbol != pSymbol)
				{
					if (bCheckSameFileOnly)
					{
						if (AreSymbolsInSameFile(pNextSymbol, pSymbol) )
						{
							bUnique = false;
						}
					}
					else
					{
						bUnique = false;
						break;
					}
				}
			}
		}
	}
	return bUnique;
}


bool CSymbolPropertiesGeneralPage::IsValueUnique(CResourceSymbol* pSymbol,
												 UINT uValue,
												 bool bCheckSameFileOnly) const
{
	bool bUnique = true;

	if ( (NULL != m_pSymbols) && (NULL != pSymbol) )
	{
		CResourceSymbolList listSymbols;
		m_pSymbols->GetSymbols(uValue, listSymbols);

		POSITION pos = listSymbols.GetHeadPosition();
		while (pos != NULL)
		{
			CResourceSymbol* pNextSymbol = listSymbols.GetNext(pos);
			if (pNextSymbol != NULL)
			{
				if (pNextSymbol != pSymbol)
				{
					if (bCheckSameFileOnly)
					{
						if (AreSymbolsInSameFile(pNextSymbol, pSymbol) )
						{
							bUnique = false;
						}
					}
					else
					{
						bUnique = false;
						break;
					}
				}
			}
		}
	}
	return bUnique;
}

bool CSymbolPropertiesGeneralPage::SetWarningText(	const CString& sWarning,
													LPCTSTR pszIconID /*= NULL*/)
{
	if (!sWarning.IsEmpty() )
	{
		// Set the icon
		m_ctrlWarningIcon.SetIcon(AfxGetApp()->LoadStandardIcon(pszIconID));

		// Set the text
		m_ctrlWarning.SetWindowText(sWarning);
		m_ctrlWarningIcon.ShowWindow(true);
		m_ctrlWarning.ShowWindow(true);

		return true;
	}
	m_ctrlWarningIcon.ShowWindow(false);
	m_ctrlWarning.ShowWindow(false);

	return false;
}


bool CSymbolPropertiesGeneralPage::AreSymbolsInSameFile(CResourceSymbol* pSymbol1, CResourceSymbol* pSymbol2) const
{
	return (pSymbol1->GetUserData() == pSymbol2->GetUserData() );
}


void CSymbolPropertiesGeneralPage::CheckNameAndValue(void)
{
	CString sWarning;
	if (!IsNameUnique(m_pSymbol, m_sName, true) )
	{
		sWarning.LoadString(IDS_SYM_NAME_CONFLICT_CAPTION);
		SetWarningText( sWarning,
						IDI_ERROR);								// Check same files

		ShowDlgControl(IDC_SYM_FIX_VALUE, false);
	}
	else if (!IsNameUnique(m_pSymbol, m_sName, false) )			// Check other files
	{
		sWarning.LoadString(IDS_SYM_NAME_CONFLICT_CAPTION_EXTERNAL);
		SetWarningText( sWarning,
						IDI_WARNING);

		ShowDlgControl(IDC_SYM_FIX_VALUE, false);
	}
	else if (!IsValueUnique(m_pSymbol, m_uValue, true) )		// Check same file
	{
		sWarning.LoadString(IDS_SYM_VALUE_CONFLICT_CAPTION);
		SetWarningText( sWarning,
						IDI_WARNING);

		ShowDlgControl(IDC_SYM_FIX_VALUE, true);
	}
	else if (!IsValueUnique(m_pSymbol, m_uValue, false) )		// Check other files
	{
		sWarning.LoadString(IDS_SYM_VALUE_CONFLICT_CAPTION_EXTERNAL);
		SetWarningText( sWarning,
						IDI_WARNING);

		ShowDlgControl(IDC_SYM_FIX_VALUE, true);
	}
	else if (m_pSymbols->IsOutOfRange(SymbolTypes.GetType(m_sName), m_uValue) )			// Check if out of range
	{
		sWarning.LoadString(IDS_SYM_VALUE_OUT_OF_RANGE_CAPTION);
		SetWarningText( sWarning,
						IDI_WARNING);

		ShowDlgControl(IDC_SYM_FIX_VALUE, true);
	}
	else
	{
		SetWarningText( _T("") );

		ShowDlgControl(IDC_SYM_FIX_VALUE, false);
	}

	// Force a repaint so the warning paints correctly
	Invalidate();

	// Inform the parent that the symbol is changing
	// This is used to update the "Conflicts" page
	GetParent()->SendMessage(	WM_SYM_CHANGING,
								m_uValue,
								(LPARAM)(LPCTSTR)m_sName);
}


/////////////////////////////////////////////////////////////////////////////
// CSymbolPropertiesGeneralPage message handlers

void CSymbolPropertiesGeneralPage::OnCmdSymbolName(void)
{
	// Update type control and icon
	int eType = SymbolTypes.GetType(m_sName);

	// Set the icon...
	SetTypeIcon( SymbolTypes.GetIconID(eType) );

	// ...and the displayed description
	CString sNewType = SymbolTypes.GetTypeName(eType);
		
	bool bTypeChanged = (!m_sType.IsEmpty() && (sNewType != m_sType) );

	m_sType = sNewType;
	ASSERT(!m_sType.IsEmpty());

	if (bTypeChanged)
	{
		 // Pick a value for the symbol which is within range for its new type
		OnClickedFixValue();
	}
	UpdateData(false);

	// Check for name conflicts...
	CheckNameAndValue();
}


void CSymbolPropertiesGeneralPage::OnCmdSymbolValue(void)
{
	CheckNameAndValue();
}


void CSymbolPropertiesGeneralPage::OnCmdReadOnly(void)
{
	ShowDlgControl(		IDC_SYM_READONLY_CAUTION,	m_bReadOnly);

	SetReadOnly(		IDC_SYM_NAME,				m_bReadOnly || m_bEditValueOnly);
	SetReadOnly(		IDC_SYM_VALUE,				m_bReadOnly);

	EnableDlgControl(	IDC_SYM_FIX_VALUE,			!m_bReadOnly);

	if (m_bEditValueOnly)
	{
		// If only the value is editable, set the focus to it
		GetDlgItem(IDC_SYM_VALUE)->SetFocus();
	}
}

void CSymbolPropertiesGeneralPage::OnClickedFixValue(void)
{
	BOOL bFailed = false;

	UINT uNewValue = m_pSymbols->GetBaseSymbolValue( SymbolTypes.GetType(m_sName) );

	while (!IsValueUnique(m_pSymbol, uNewValue, false) )
	{
		uNewValue++;
		if (uNewValue >= IDC_STATIC)
		{
			bFailed = true;
			ASSERT(false);
			break;		// Can't fix this one
		}
	}

	if (!bFailed)
	{
		m_uValue = uNewValue;
		UpdateData(false);

		CheckNameAndValue();
	}
	else
	{
		::AfxMessageBox(IDP_SYM_FIX_VALUE_FAILED,
						MB_OK | MB_ICONEXCLAMATION);
	}
}

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!
Follow on   Twitter

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