📄 ngutils.h
字号:
// 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__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -