📄 afx.h
字号:
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#ifndef __AFX_H__
#define __AFX_H__
#ifndef __cplusplus
#error MFC requires C++ compilation (use a .cpp suffix)
#endif
/////////////////////////////////////////////////////////////////////////////
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, off)
#endif
#ifndef _AFX_FULLTYPEINFO
#pragma component(mintypeinfo, on)
#endif
#include <afxver_.h> // Target version control
#ifndef _AFX_NOFORCE_LIBS
/////////////////////////////////////////////////////////////////////////////
// Win32 libraries
#ifndef _AFXDLL
#ifndef _UNICODE
#ifdef _DEBUG
#pragma comment(lib, "nafxcwd.lib")
#else
#pragma comment(lib, "nafxcw.lib")
#endif
#else
#ifdef _DEBUG
#pragma comment(lib, "uafxcwd.lib")
#else
#pragma comment(lib, "uafxcw.lib")
#endif
#endif
#else
#ifndef _UNICODE
#ifdef _DEBUG
#pragma comment(lib, "mfc42d.lib")
#pragma comment(lib, "mfcs42d.lib")
#else
#pragma comment(lib, "mfc42.lib")
#pragma comment(lib, "mfcs42.lib")
#endif
#else
#ifdef _DEBUG
#pragma comment(lib, "mfc42ud.lib")
#pragma comment(lib, "mfcs42ud.lib")
#else
#pragma comment(lib, "mfc42u.lib")
#pragma comment(lib, "mfcs42u.lib")
#endif
#endif
#endif
#ifdef _DLL
#if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
#pragma comment(lib, "msvcrtd.lib")
#else
#pragma comment(lib, "msvcrt.lib")
#endif
#else
#ifdef _MT
#if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
#pragma comment(lib, "libcmtd.lib")
#else
#pragma comment(lib, "libcmt.lib")
#endif
#else
#if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
#pragma comment(lib, "libcd.lib")
#else
#pragma comment(lib, "libc.lib")
#endif
#endif
#endif
#pragma comment(lib, "kernel32.lib")
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "gdi32.lib")
#pragma comment(lib, "comdlg32.lib")
#pragma comment(lib, "winspool.lib")
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "shell32.lib")
#pragma comment(lib, "comctl32.lib")
// force inclusion of NOLIB.OBJ for /disallowlib directives
#pragma comment(linker, "/include:__afxForceEXCLUDE")
// force inclusion of DLLMODUL.OBJ for _USRDLL
#ifdef _USRDLL
#pragma comment(linker, "/include:__afxForceUSRDLL")
#endif
// force inclusion of STDAFX.OBJ for precompiled types
#ifdef _AFXDLL
#pragma comment(linker, "/include:__afxForceSTDAFX")
#endif
#endif //!_AFX_NOFORCE_LIBS
/////////////////////////////////////////////////////////////////////////////
// Classes declared in this file
// in addition to standard primitive data types and various helper macros
struct CRuntimeClass; // object type information
class CObject; // the root of all objects classes
class CException; // the root of all exceptions
class CArchiveException; // archive exception
class CFileException; // file exception
class CSimpleException;
class CMemoryException; // out-of-memory exception
class CNotSupportedException; // feature not supported exception
class CFile; // raw binary file
class CStdioFile; // buffered stdio text/binary file
class CMemFile; // memory based file
// Non CObject classes
class CString; // growable string type
class CTimeSpan; // time/date difference
class CTime; // absolute time/date
struct CFileStatus; // file status information
struct CMemoryState; // diagnostic memory support
class CArchive; // object persistence tool
class CDumpContext; // object diagnostic dumping
/////////////////////////////////////////////////////////////////////////////
// Other includes from standard "C" runtimes
#ifndef _INC_STRING
#include <string.h>
#endif
#ifndef _INC_STDIO
#include <stdio.h>
#endif
#ifndef _INC_STDLIB
#include <stdlib.h>
#endif
#ifndef _INC_TIME
#include <time.h>
#endif
#ifndef _INC_LIMITS
#include <limits.h>
#endif
#ifndef _INC_STDDEF
#include <stddef.h>
#endif
#ifndef _INC_STDARG
#include <stdarg.h>
#endif
#ifndef _AFX_NO_DEBUG_CRT
#ifndef _INC_CRTDBG
#include <crtdbg.h>
#endif
#endif // _AFX_NO_DEBUG_CRT
#ifdef _AFX_OLD_EXCEPTIONS
// use setjmp and helper functions instead of C++ keywords
#ifndef _INC_SETJMP
#pragma warning(disable: 4611)
#include <setjmp.h>
#endif
#endif
#ifdef _AFX_PACKING
#pragma pack(push, _AFX_PACKING)
#endif
/////////////////////////////////////////////////////////////////////////////
// Basic types
// abstract iteration position
struct __POSITION { };
typedef __POSITION* POSITION;
struct _AFX_DOUBLE { BYTE doubleBits[sizeof(double)]; };
struct _AFX_FLOAT { BYTE floatBits[sizeof(float)]; };
// Standard constants
#undef FALSE
#undef TRUE
#undef NULL
#define FALSE 0
#define TRUE 1
#define NULL 0
/////////////////////////////////////////////////////////////////////////////
// Diagnostic support
#ifdef _DEBUG
BOOL AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName, int nLine);
void AFX_CDECL AfxTrace(LPCTSTR lpszFormat, ...);
// Note: file names are still ANSI strings (filenames rarely need UNICODE)
void AFXAPI AfxAssertValidObject(const CObject* pOb,
LPCSTR lpszFileName, int nLine);
void AFXAPI AfxDump(const CObject* pOb); // Dump an object from CodeView
#define TRACE ::AfxTrace
#define THIS_FILE __FILE__
#define ASSERT(f) \
do \
{ \
if (!(f) && AfxAssertFailedLine(THIS_FILE, __LINE__)) \
AfxDebugBreak(); \
} while (0) \
#define VERIFY(f) ASSERT(f)
#define ASSERT_VALID(pOb) (::AfxAssertValidObject(pOb, THIS_FILE, __LINE__))
#define DEBUG_ONLY(f) (f)
// The following trace macros are provided for backward compatiblity
// (they also take a fixed number of parameters which provides
// some amount of extra error checking)
#define TRACE0(sz) ::AfxTrace(_T("%s"), _T(sz))
#define TRACE1(sz, p1) ::AfxTrace(_T(sz), p1)
#define TRACE2(sz, p1, p2) ::AfxTrace(_T(sz), p1, p2)
#define TRACE3(sz, p1, p2, p3) ::AfxTrace(_T(sz), p1, p2, p3)
// These AFX_DUMP macros also provided for backward compatibility
#define AFX_DUMP0(dc, sz) dc << _T(sz)
#define AFX_DUMP1(dc, sz, p1) dc << _T(sz) << p1
#else // _DEBUG
#define ASSERT(f) ((void)0)
#define VERIFY(f) ((void)(f))
#define ASSERT_VALID(pOb) ((void)0)
#define DEBUG_ONLY(f) ((void)0)
inline void AFX_CDECL AfxTrace(LPCTSTR, ...) { }
#define TRACE 1 ? (void)0 : ::AfxTrace
#define TRACE0(sz)
#define TRACE1(sz, p1)
#define TRACE2(sz, p1, p2)
#define TRACE3(sz, p1, p2, p3)
#endif // !_DEBUG
#define ASSERT_POINTER(p, type) \
ASSERT(((p) != NULL) && AfxIsValidAddress((p), sizeof(type), FALSE))
#define ASSERT_NULL_OR_POINTER(p, type) \
ASSERT(((p) == NULL) || AfxIsValidAddress((p), sizeof(type), FALSE))
/////////////////////////////////////////////////////////////////////////////
// Turn off warnings for /W4
// To resume any of these warning: #pragma warning(default: 4xxx)
// which should be placed after the AFX include files
#ifndef ALL_WARNINGS
// warnings generated with common MFC/Windows code
#pragma warning(disable: 4127) // constant expression for TRACE/ASSERT
#pragma warning(disable: 4134) // message map member fxn casts
#pragma warning(disable: 4201) // nameless unions are part of C++
#pragma warning(disable: 4511) // private copy constructors are good to have
#pragma warning(disable: 4512) // private operator= are good to have
#pragma warning(disable: 4514) // unreferenced inlines are common
#pragma warning(disable: 4710) // private constructors are disallowed
#pragma warning(disable: 4705) // statement has no effect in optimized code
#pragma warning(disable: 4191) // pointer-to-function casting
// warnings caused by normal optimizations
#ifndef _DEBUG
#pragma warning(disable: 4701) // local variable *may* be used without init
#pragma warning(disable: 4702) // unreachable code caused by optimizations
#pragma warning(disable: 4791) // loss of debugging info in release version
#pragma warning(disable: 4189) // initialized but unused variable
#pragma warning(disable: 4390) // empty controlled statement
#endif
// warnings specific to _AFXDLL version
#ifdef _AFXDLL
#pragma warning(disable: 4204) // non-constant aggregate initializer
#endif
#ifdef _AFXDLL
#pragma warning(disable: 4275) // deriving exported class from non-exported
#pragma warning(disable: 4251) // using non-exported as public in exported
#endif
#endif //!ALL_WARNINGS
#ifdef _DEBUG
#define UNUSED(x)
#else
#define UNUSED(x) x
#endif
#define UNUSED_ALWAYS(x) x
/////////////////////////////////////////////////////////////////////////////
// Other implementation helpers
#define BEFORE_START_POSITION ((POSITION)-1L)
/////////////////////////////////////////////////////////////////////////////
// explicit initialization for general purpose classes
BOOL AFXAPI AfxInitialize(BOOL bDLL = FALSE, DWORD dwVersion = _MFC_VER);
#undef AFX_DATA
#define AFX_DATA AFX_CORE_DATA
/////////////////////////////////////////////////////////////////////////////
// Basic object model
struct CRuntimeClass
{
// Attributes
LPCSTR m_lpszClassName;
int m_nObjectSize;
UINT m_wSchema; // schema number of the loaded class
CObject* (PASCAL* m_pfnCreateObject)(); // NULL => abstract class
#ifdef _AFXDLL
CRuntimeClass* (PASCAL* m_pfnGetBaseClass)();
#else
CRuntimeClass* m_pBaseClass;
#endif
// Operations
CObject* CreateObject();
BOOL IsDerivedFrom(const CRuntimeClass* pBaseClass) const;
// Implementation
void Store(CArchive& ar) const;
static CRuntimeClass* PASCAL Load(CArchive& ar, UINT* pwSchemaNum);
// CRuntimeClass objects linked together in simple list
CRuntimeClass* m_pNextClass; // linked list of registered classes
};
/////////////////////////////////////////////////////////////////////////////
// Strings
#ifndef _OLEAUTO_H_
#ifdef OLE2ANSI
typedef LPSTR BSTR;
#else
typedef LPWSTR BSTR;// must (semantically) match typedef in oleauto.h
#endif
#endif
struct CStringData
{
long nRefs; // reference count
int nDataLength; // length of data (including terminator)
int nAllocLength; // length of allocation
// TCHAR data[nAllocLength]
TCHAR* data() // TCHAR* to managed data
{ return (TCHAR*)(this+1); }
};
class CString
{
public:
// Constructors
// constructs empty CString
CString();
// copy constructor
CString(const CString& stringSrc);
// from a single character
CString(TCHAR ch, int nRepeat = 1);
// from an ANSI string (converts to TCHAR)
CString(LPCSTR lpsz);
// from a UNICODE string (converts to TCHAR)
CString(LPCWSTR lpsz);
// subset of characters from an ANSI string (converts to TCHAR)
CString(LPCSTR lpch, int nLength);
// subset of characters from a UNICODE string (converts to TCHAR)
CString(LPCWSTR lpch, int nLength);
// from unsigned characters
CString(const unsigned char* psz);
// Attributes & Operations
// get data length
int GetLength() const;
// TRUE if zero length
BOOL IsEmpty() const;
// clear contents to empty
void Empty();
// return single character at zero-based index
TCHAR GetAt(int nIndex) const;
// return single character at zero-based index
TCHAR operator[](int nIndex) const;
// set a single character at zero-based index
void SetAt(int nIndex, TCHAR ch);
// return pointer to const string
operator LPCTSTR() const;
// overloaded assignment
// ref-counted copy from another CString
const CString& operator=(const CString& stringSrc);
// set string content to single character
const CString& operator=(TCHAR ch);
#ifdef _UNICODE
const CString& operator=(char ch);
#endif
// copy string content from ANSI string (converts to TCHAR)
const CString& operator=(LPCSTR lpsz);
// copy string content from UNICODE string (converts to TCHAR)
const CString& operator=(LPCWSTR lpsz);
// copy string content from unsigned chars
const CString& operator=(const unsigned char* psz);
// string concatenation
// concatenate from another CString
const CString& operator+=(const CString& string);
// concatenate a single character
const CString& operator+=(TCHAR ch);
#ifdef _UNICODE
// concatenate an ANSI character after converting it to TCHAR
const CString& operator+=(char ch);
#endif
// concatenate a UNICODE character after converting it to TCHAR
const CString& operator+=(LPCTSTR lpsz);
friend CString AFXAPI operator+(const CString& string1,
const CString& string2);
friend CString AFXAPI operator+(const CString& string, TCHAR ch);
friend CString AFXAPI operator+(TCHAR ch, const CString& string);
#ifdef _UNICODE
friend CString AFXAPI operator+(const CString& string, char ch);
friend CString AFXAPI operator+(char ch, const CString& string);
#endif
friend CString AFXAPI operator+(const CString& string, LPCTSTR lpsz);
friend CString AFXAPI operator+(LPCTSTR lpsz, const CString& string);
// string comparison
// straight character comparison
int Compare(LPCTSTR lpsz) const;
// compare ignoring case
int CompareNoCase(LPCTSTR lpsz) const;
// NLS aware comparison, case sensitive
int Collate(LPCTSTR lpsz) const;
// NLS aware comparison, case insensitive
int CollateNoCase(LPCTSTR lpsz) const;
// simple sub-string extraction
// return nCount characters starting at zero-based nFirst
CString Mid(int nFirst, int nCount) const;
// return all characters starting at zero-based nFirst
CString Mid(int nFirst) const;
// return first nCount characters in string
CString Left(int nCount) const;
// return nCount characters from end of string
CString Right(int nCount) const;
// characters from beginning that are also in passed string
CString SpanIncluding(LPCTSTR lpszCharSet) const;
// characters from beginning that are not also in passed string
CString SpanExcluding(LPCTSTR lpszCharSet) const;
// upper/lower/reverse conversion
// NLS aware conversion to uppercase
void MakeUpper();
// NLS aware conversion to lowercase
void MakeLower();
// reverse string right-to-left
void MakeReverse();
// trimming whitespace (either side)
// remove whitespace starting from right edge
void TrimRight();
// remove whitespace starting from left side
void TrimLeft();
// trimming anything (either side)
// remove continuous occurrences of chTarget starting from right
void TrimRight(TCHAR chTarget);
// remove continuous occcurrences of characters in passed string,
// starting from right
void TrimRight(LPCTSTR lpszTargets);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -