Click here to Skip to main content
15,881,204 members
Articles / Desktop Programming / MFC

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

Rate me:
Please Sign up or sign in to vote.
4.98/5 (71 votes)
10 Jan 2005CPOL25 min read 529.9K   12.1K   201  
An application/add-in to organise and renumber resource symbol IDs
// Utils.h : Utility functions
//

#ifndef	__UTILS_H__
#define __UTILS_H__

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000


#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif

/////////////////////////////////////////////////////////////////////////////
// Definitions
//
// (none)


/////////////////////////////////////////////////////////////////////////////
// Helper functions

		// Mainframe Window persistance
		//
	NGLIB_EXT_API		BOOL					ReadWindowPlacement(LPWINDOWPLACEMENT pwp);

	NGLIB_EXT_API		void					WriteWindowPlacement(LPWINDOWPLACEMENT pwp);

		/////////////////////////////////////////////////////////////////////
		// Files and I/O
		//
	NGLIB_EXT_API		BOOL					FileExists(const CString& sFileName);
	NGLIB_EXT_API		BOOL					FolderExists(const CString& sDirName);

	// This function does the same thing as PathCombine() in Shlwapi.dll but using CStrings
	NGLIB_EXT_API		CString					CombinePath(const CString& sFolder,
															const CString& sRelativePath);

		/////////////////////////////////////////////////////////////////////
		// System, and App information
		//
	NGLIB_EXT_API		BOOL					SetHelpFileName(const CString& sFileName);

	NGLIB_EXT_API		CString					GetAppStartDir(void);

	NGLIB_EXT_API		BOOL					AddRunOnceKey(	const CString& rsAppName,
																		const CString& rsCmdLine);

	NGLIB_EXT_API		CString					GetComputerName(void);
	NGLIB_EXT_API		CString					GetUserName(void);
	NGLIB_EXT_API		CSize					GetDisplayResolution(void);
	NGLIB_EXT_API		CSize					GetDisplaySize(void);
	NGLIB_EXT_API		int						GetColourDepth(void);
	NGLIB_EXT_API		BOOL					Is256ColorSupported(void);

		/////////////////////////////////////////////////////////////////////
		// Messaging
	NGLIB_EXT_API		BOOL					SendCommandMsg(CCmdTarget* pTarget, UINT uID);

	NGLIB_EXT_API		BOOL					SendNotifyMsg(	CCmdTarget* pTarget,
																		  UINT uID,
																		  int nCode,
																		  NMHDR* pNMHDR,
																		  LRESULT* pResult);

		/////////////////////////////////////////////////////////////////////
		// Misc

	NGLIB_EXT_API		BOOL					SetStatusBarText(const CString& rsText, UINT uID = AFX_IDW_STATUS_BAR);
		
		/////////////////////////////////////////////////////////////////////
		// String Mangling and Conversion

		// Replace tabs with spaces
	NGLIB_EXT_API		CString					UnTabify(const CString& rsData, int nTabWidth = 4);

		// Return source string up to, but not including, target
	NGLIB_EXT_API		CString					Before(const CString& rsSource, LPCTSTR pszTarget);

		// Return source string after, but not including, target
	NGLIB_EXT_API		CString					After(const CString& rsSource, LPCTSTR pszTarget);

		// Return source string between two target strings
	NGLIB_EXT_API		CString					Between(const CString& rsSource, LPCTSTR pszStartAfter, LPCTSTR pszStopBefore);

		//  Chomp the next parameter out of the given string
		//	consuming it in the process
	NGLIB_EXT_API		CString					Chomp(CString& rsSource, LPCTSTR pszDelimiter /*= ","*/);

		// Return pos of next none white space char, starting at nPos
	NGLIB_EXT_API		int						FindNoneWhiteSpace(LPCTSTR pszData, int nPos);

	NGLIB_EXT_API		BOOL					IsNumeric(LPCTSTR pszValue, double* pdValue = NULL);

		// Convert int to CString [more convenient than CString::Format()]
	NGLIB_EXT_API		CString					IntToStr(int i);
	NGLIB_EXT_API		CString					IntToStr(long i);
	NGLIB_EXT_API		CString					UIntToStr(unsigned int i);
	NGLIB_EXT_API		CString					UIntToStr(unsigned long i);
	NGLIB_EXT_API		CString					HexUIntToStr(unsigned int i, int nMinWidth = 0);
	NGLIB_EXT_API		CString					HexUIntToStr(unsigned long i, int nMinWidth = 0);
	NGLIB_EXT_API		CString					FloatToStr(float f,  int nDigits = 7);
	NGLIB_EXT_API		CString					FloatToStr(double f, int nDigits = 15);
	NGLIB_EXT_API		double					Round(double dVal);
	NGLIB_EXT_API		double					Round(double dVal, UINT nDecPlaces);

	NGLIB_EXT_API		BOOL					IsEven(int n);
	NGLIB_EXT_API		BOOL					IsOdd(int n);

	NGLIB_EXT_API		unsigned long			SetBit(unsigned long nData, UINT nBitNo, BOOL bBitState);
	NGLIB_EXT_API		BOOL					GetBit(unsigned long nData, UINT nBitNo);

		// Functions for loading rich text format file contents from "RTF" resources
		// (useful when using Rich Edit Controls with static text)
	NGLIB_EXT_API		int						LoadRtfString(	HMODULE hInst,
																UINT nID,
																LPTSTR lpszBuf,
																UINT nMaxBuf);

	NGLIB_EXT_API		int						LoadRtfString(	UINT nID,
																LPTSTR lpszBuf,
																UINT nMaxBuf);

	NGLIB_EXT_API		CString					LoadRtfString(	UINT uID);

#endif // !__UTILS_H__

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)


Written By
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!

Comments and Discussions