⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chxd.htm

📁 VC使用所有细节的逻列
💻 HTM
📖 第 1 页 / 共 2 页
字号:

<P>Verifies the integrity of allocated memory.</P>

<TR>

<TD>

<P>AfxDoForAllClasses()</P>

<TD>

<P>Calls a given iteration function for all classes that are derived from <font color="#008000">CObject</font> and that incorporate run-time type checking.</P>

<TR>

<TD>

<P>AfxDoForAllObjects()</P>

<TD>

<P>Calls a given iteration function for all objects that were derived from <font color="#008000">CObject</font> and that were allocated with the <font color="#008000">new</font> operator.</P>

<TR>

<TD>

<P>afxDump</P>

<TD>

<P>A global <font color="#008000">CDumpContext</font> object that enables a program to send information to the debugger window.</P>

<TR>

<TD>

<P>AfxDump()</P>

<TD>

<P>Dumps an object's state during a debugging session.</P>

<TR>

<TD>

<P>AfxEnableMemoryTracking()</P>

<TD>

<P>Toggles memory tracking.</P>

<TR>

<TD>

<P>AfxIsMemoryBlock()</P>

<TD>

<P>Checks that memory allocation was successful.</P>

<TR>

<TD>

<P>AfxIsValidAddress()</P>

<TD>

<P>Checks that a memory address range is valid for the program.</P>

<TR>

<TD>

<P>AfxIsValidString()</P>

<TD>

<P>Checks string pointer validity.</P>

<TR>

<TD>

<P>afxMemDF</P>

<TD>

<P>A global variable that controls memory-allocation diagnostics. Can be set to <font color="#008000">allocMemDF</font>, <font color="#008000">DelayFreeMemDF</font>, or <font color="#008000">checkAlwaysMemDF</font>.</P>

<TR>

<TD>

<P>AfxSetAllocHook()</P>

<TD>

<P>Sets a user-defined hook function that is called whenever memory allocation is performed.</P>

<TR>

<TD>

<P>afxTraceEnabled</P>

<TD>

<P>A global variable that enables or disables TRACE output.</P>

<TR>

<TD>

<P>afxTraceFlags</P>

<TD>

<P>A global variable that enables the MFC reporting features.</P>

<TR>

<TD>

<P>ASSERT</P>

<TD>

<P>Prints a message and exits the program if the assert expression is false. (See <A HREF="index24.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index24.htm" target="text">Chapter 24</A>, &#147;Improving Your Application&#146;s Performance.&#148;)</P>

<TR>

<TD>

<P>ASSERT_VALID</P>

<TD>

<P>Validates an object by calling the object's AssertValid() function.</P>

<TR>

<TD>

<P>DEBUG_NEW</P>

<TD>

<P>Used in place of the <font color="#008000">new</font> operator in order to trace memory-leak problems. (See <A HREF="index24.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index24.htm" target="text">Chapter 24</A>, &#147;Improving Your Application&#146;s Performance.&#148;)</P>

<TR>

<TD>

<P>TRACE</P>

<TD>

<P>Creates formatted strings for debugging output. (See <A HREF="index24.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index24.htm" target="text">Chapter 24</A>, &#147;Improving Your Application&#146;s Performance.&#148;)</P>

<TR>

<TD>

<P>TRACE0</P>

<TD>

<P>Same as TRACE but requires no arguments in the format string.</P>

<TR>

<TD>

<P>TRACE1</P>

<TD>

<P>Same as TRACE but requires one argument in the format string.</P>

<TR>

<TD>

<P>TRACE2</P>

<TD>

<P>Same as TRACE but requires two arguments in the format string.</P>

<TR>

<TD>

<P>TRACE3</P>

<TD>

<P>Same as TRACE but requires three arguments in the format string.</P>

<TR>

<TD>

<P>VERIFY</P>

<TD>

<P>Like ASSERT, but VERIFY evaluates the assert expression in both the Debug and Release versions of MFC. If the assertion fails, a message is printed and the program halted only in the Debug version.</P></TABLE>

<H3><B>Exception Processing</B></H3>

<P>One of the newest elements of the C++ language is <I>exceptions</I>, which give a program greater over control over how errors are handled. (See <A HREF="index26.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index26.htm" target="text">Chapter 26</A>, &quot;Exceptions, Templates, and the Latest Additions 
to C++.&quot;) Before exceptions were part of the language, MFC developers used macros to achieve the same results. Now that exceptions are firmly established in Visual C++, a number of functions make it easier to throw exceptions of various types. These 
macros and functions are listed in Table D.7.</P>

<P><B>Table D.7&#151;Exception Macros and Functions</B></P>

<TABLE BORDER>

<TR>

<TD>

<P><I>Symbol</I></P>

<TD>

<P><I>Description</I></P>

<TR>

<TD>

<P>AfxAbort()</P>

<TD>

<P>Terminates an application upon a fatal error.</P>

<TR>

<TD>

<P>AfxThrowArchiveException()</P>

<TD>

<P>Throws an archive exception.</P>

<TR>

<TD>

<P>AfxThrowDAOException()</P>

<TD>

<P>Throws a <font color="#008000">CDaoException</font>.</P>

<TR>

<TD>

<P>AfxThrowDBException()</P>

<TD>

<P>Throws a <font color="#008000">CDBException</font>.</P>

<TR>

<TD>

<P>AfxThrowFileException()</P>

<TD>

<P>Throws a file exception.</P>

<TR>

<TD>

<P>AfxThrowMemoryException()</P>

<TD>

<P>Throws a memory exception.</P>

<TR>

<TD>

<P>AfxThrowNotSupportedException()</P>

<TD>

<P>Throws a not-supported exception.</P>

<TR>

<TD>

<P>AfxThrowOleDispatchException()</P>

<TD>

<P>Throws an OLE automation exception.</P>

<TR>

<TD>

<P>AfxThrowOleException()</P>

<TD>

<P>Throws an OLE exception.</P>

<TR>

<TD>

<P>AfxThrowResourceException()</P>

<TD>

<P>Throws a resource-not-found exception.</P>

<TR>

<TD>

<P>AfxThrowUserException()</P>

<TD>

<P>Throws an end-user exception.</P>

<TR>

<TD>

<P>AND_CATCH</P>

<TD>

<P>Begins code that will catch specified exceptions not caught in the preceding TRY block.</P>

<TR>

<TD>

<P>AND_CATCH_ALL</P>

<TD>

<P>Begins code that will catch all exceptions not caught in the preceding TRY block.</P>

<TR>

<TD>

<P>CATCH</P>

<TD>

<P>Begins code for catching an exception.</P>

<TR>

<TD>

<P>CATCH_ALL</P>

<TD>

<P>Begins code for catching all exceptions.</P>

<TR>

<TD>

<P>END_CATCH</P>

<TD>

<P>Ends CATCH or AND_CATCH code blocks.</P>

<TR>

<TD>

<P>END_CATCH_ALL</P>

<TD>

<P>Ends CATCH_ALL code blocks.</P>

<TR>

<TD>

<P>THROW</P>

<TD>

<P>Throws a given exception.</P>

<TR>

<TD>

<P>THROW_LAST</P>

<TD>

<P>Throws the most recent exception to the next handler.</P>

<TR>

<TD>

<P>TRY</P>

<TD>

<P>Starts code that will accommodate exception handling.</P></TABLE>

<H3><B>Using Message-Map Macros</B></H3>

<P>Windows is an event-driven operating system, which means that every Windows application must handle a flood of messages that flow between an application and the system. MFC does away with the clunky <font color="#008000">switch</font> statements that 
early Windows programmers had to construct in order to handle messages and replaces those statements with a message map. A <I>message map</I> is nothing more than a table that matches a message with its message handler. (See <A HREF="index04.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index04.htm" 
target="text">Chapter 4</A>, &quot;Messages and Commands.&quot;) In order to simplify the declaration and definition of these tables, Visual C++ defines a set of message-map macros. Many of these macros, which are listed in Table D.8, will already be 
familiar to experienced MFC programmers.</P>

<P><B>Table D.8&#151;Message-Map Macros</B></P>

<TABLE BORDER>

<TR>

<TD>

<P><I>Macro</I></P>

<TD>

<P><I>Description</I></P>

<TR>

<TD>

<P>BEGIN_MESSAGE_MAP</P>

<TD>

<P>Begins a message-map definition.</P>

<TR>

<TD>

<P>DECLARE_MESSAGE_MAP</P>

<TD>

<P>Starts a message-map declaration.</P>

<TR>

<TD>

<P>END_MESSAGE_MAP</P>

<TD>

<P>Ends a message-map definition.</P>

<TR>

<TD>

<P>ON_COMMAND</P>

<TD>

<P>Begins a command-message message-map entry.</P>

<TR>

<TD>

<P>ON_COMMAND_RANGE</P>

<TD>

<P>Begins a command-message message-map entry that maps multiple messages to a single handler.</P>

<TR>

<TD>

<P>ON_CONTROL</P>

<TD>

<P>Begins a control-notification message-map entry.</P>

<TR>

<TD>

<P>ON_CONTROL_RANGE</P>

<TD>

<P>Begins a control-notification message-map entry that maps multiple control IDs to a single handler.</P>

<TR>

<TD>

<P>ON_MESSAGE</P>

<TD>

<P>Begins a user-message message-map entry.</P>

<TR>

<TD>

<P>ON_REGISTERED_MESSAGE</P>

<TD>

<P>Begins a registered user-message message-map entry.</P>

<TR>

<TD>

<P>ON_UPDATE_COMMAND_UI</P>

<TD>

<P>Begins a command-update message-map entry.</P>

<TR>

<TD>

<P>ON_UPDATE_COMMAND_UI_RANGE</P>

<TD>

<P>Begins a command-update message-map entry that maps multiple command-update messages to a single handler.</P></TABLE>

<H3><B>Run-Time Object Model Services</B></H3>

<P>Frequently in your programs you need access to information about classes at run-time. MFC supplies a macro for obtaining this type of information in a <font color="#008000">CRuntimeClass</font> structure. In addition, the MFC application framework 
relies on a set of macros to declare and define runtime abilities (such as object serialization and dynamic object creation). If you've used AppWizard at all, you've seen these macros used in the generated source-code files. If you're an advanced MFC 
programmer, you may have even used these macros yourself. Table D.9 lists the run-time macros and their descriptions.</P>

<P><B>Table D.9&#151;Run-Time Services Macros</B></P>

<TABLE BORDER>

<TR>

<TD>

<P><I>Macro</I></P>

<TD>

<P><I>Description</I></P>

<TR>

<TD>

<P>DECLARE_DYNAMIC</P>

<TD>

<P>Used in a class declaration to enable run-time class information access.</P>

<TR>

<TD>

<P>DECLARE_DYNCREATE</P>

<TD>

<P>Used in a class declaration to allow the class (derived from <font color="#008000">CObject</font>) to be created dynamically. Also, allows run-time class information access.</P>

<TR>

<TD>

<P>DECLARE_OLECREATE</P>

<TD>

<P>Used in a class declaration to allow object creation with OLE automation.</P>

<TR>

<TD>

<P>DECLARE_SERIAL</P>

<TD>

<P>Used in a class declaration to allow object serialization, as well as run-time class information access.</P>

<TR>

<TD>

<P>IMPLEMENT_DYNAMIC</P>

<TD>

<P>Used in a class implementation to enables run-time class information access.</P>

<TR>

<TD>

<P>IMPLEMENT_DYNCREATE</P>

<TD>

<P>Used in a class implementation to allow dynamic creation of the object and run-time information access.</P>

<TR>

<TD>

<P>IMPLEMENT_OLECREATE</P>

<TD>

<P>Used in a class implementation to enable object creation with OLE.</P>

<TR>

<TD>

<P>IMPLEMENT_SERIAL</P>

<TD>

<P>Used in a class implementation to allow object serialization and run-time class information access.</P>

<TR>

<TD>

<P>RUNTIME_CLASS</P>

<TD>

<P>Returns a <font color="#008000">CRuntimeClass</font> structure for the given class.</P></TABLE>

<H3><B>Standard Command and Window IDs</B></H3>

<P>There are myriad standard messages that can be generated by a user of a Windows application. For example, whenever the user selects a menu command from a standard menu like File or Edit, the program sends a message. Each of these standard commands is 
represented by an ID. In order to relieve the programmer of having to define the dozens of IDs that are often used in a Windows application, Visual C++ defines these symbols in a file called AFXRES.H. Some of these IDs have obvious purposes (for example, 
<font color="#008000">ID_FILE_OPEN</font>), but many others are used internally by MFC for everything from mapping standard Windows messages to their handlers to defining string-table IDs to assigning IDs to toolbar and status-bar styles.</P>

<P>There are far too many of these identifiers to list here. However, if you're interested in seeing them, just load the AFXRES.H file from your Visual C++ installation folder.</P>

<p><hr></p>

<center>

<p><font size=-2>

&copy; 1997, QUE Corporation, an imprint of Macmillan Publishing USA, a

Simon and Schuster Company.</font></p>

</center>

</BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -