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

📄 ape.htm

📁 Using Visual C++ 6.0 一本关于Visual C++ 6.0基本编程应用的书籍。
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<P>For example, if you want to keep a sorted list, the functions that insert new
items into the list must be able to compare two Truck objects or two Employee objects
to decide where to put a new Truck or Employee. You implement CompareElements() for
the Truck class or Employee class, and then the collection class code can use this
function to decide where to put new additions to the collection.</P>
<P>
<H4>Table E.3&#160;&#160;Collection Class Helper Functions</H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT"><B>Function</B></TD>
		<TD ALIGN="LEFT"><B>Description</B></TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">CompareElements()</TD>
		<TD ALIGN="LEFT">Checks elements for equality</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">ConstructElements()</TD>
		<TD ALIGN="LEFT">Constructs new elements (works similar to a class constructor)</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">DestructElements()</TD>
		<TD ALIGN="LEFT">Destroys elements (works similar to a class destructor)</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">DumpElements()</TD>
		<TD ALIGN="LEFT">Provides diagnostic output in text form</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">HashKey()</TD>
		<TD ALIGN="LEFT">Calculates hashing keys</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">SerializeElements()</TD>
		<TD ALIGN="LEFT">Saves or loads elements to or from an archive</TD>
	</TR>
</TABLE>

<H2><A NAME="Heading4"></A>CString Formatting and Message-Box Display</H2>
<P>If you've done much Visual C++ programming, you know that MFC features a special
string class, called CString, that makes string handling under C++ less cumbersome.
CString objects are used extensively throughout MFC programs and are discussed in
Appendix F. There are times when CString is not the right class, though, such as
when dealing with strings in a resource's string table. These global functions, which
replace format characters in string tables, provide the CString Format() capability
for resource strings. There's also a global function for displaying a message box.</P>
<P>
<H4>Table E.4&#160;&#160;CString Formatting and Message-Box Functions</H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT"><B>Function</B></TD>
		<TD ALIGN="LEFT"><B>Description</B></TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxFormatString1()</TD>
		<TD ALIGN="LEFT">Replaces the format characters (such as %1) in a string resource with a given string</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxFormatString2()</TD>
		<TD ALIGN="LEFT">Replaces the format characters %1 and %2 in a string resource with the given strings</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxMessageBox()</TD>
		<TD ALIGN="LEFT">Displays a message box</TD>
	</TR>
</TABLE>

<H2><A NAME="Heading5"></A>Data Types</H2>
<P>The most commonly used constants are those that define a portable set of data
types. You've seen tons of these constants (named in all uppercase letters) used
in Windows programs. You'll recognize many of these from the Windows SDK. Others
are included only as part of Visual C++. You use these constants exactly as you would
any other data type. For example, to declare an unsigned integer variable, you'd
write something like this:</P>
<P>
<PRE>UINT flag;
</PRE>
<P>Table E.5 lists the most commonly used data types defined by Visual C++ for Windows
95/98 and NT. Searching in the help index on any one of these types will lead you
to a page in the online help that lists all the data types used in MFC and the Windows
SDK.</P>
<P>
<H4>Table E.5&#160;&#160;Commonly Used Data Types</H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT"><B>Data Type</B></TD>
		<TD ALIGN="LEFT"><B>Description</B></TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">BOOL</TD>
		<TD ALIGN="LEFT">Boolean value</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">BSTR</TD>
		<TD ALIGN="LEFT">32-bit pointer to character data</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">BYTE</TD>
		<TD ALIGN="LEFT">8-bit unsigned integer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">COLORREF</TD>
		<TD ALIGN="LEFT">32-bit color value</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">DWORD</TD>
		<TD ALIGN="LEFT">32-bit unsigned integer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">LONG</TD>
		<TD ALIGN="LEFT">32-bit signed integer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">LPARAM</TD>
		<TD ALIGN="LEFT">32-bit window-procedure parameter</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">LPCRECT</TD>
		<TD ALIGN="LEFT">32-bit constant RECT structure pointer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">LPCSTR</TD>
		<TD ALIGN="LEFT">32-bit string-constant pointer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">LPSTR</TD>
		<TD ALIGN="LEFT">32-bit string pointer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">LPVOID</TD>
		<TD ALIGN="LEFT">32-bit void pointer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">LRESULT</TD>
		<TD ALIGN="LEFT">32-bit window-procedure return value</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">POSITION</TD>
		<TD ALIGN="LEFT">The position of an element in a collection</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">UINT</TD>
		<TD ALIGN="LEFT">32-bit unsigned integer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">WNDPROC</TD>
		<TD ALIGN="LEFT">32-bit window-procedure pointer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">WORD</TD>
		<TD ALIGN="LEFT">16-bit unsigned integer</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">WPARAM</TD>
		<TD ALIGN="LEFT">32-bit window-procedure parameter</TD>
	</TR>
</TABLE>

<H2><A NAME="Heading6"></A>Diagnostic Services</H2>
<P>When you have written your program, you're far from finished. Then comes the grueling
task of testing, which means rolling up your sleeves, cranking up your debugger,
and weeding out all the gotchas hiding in your code. Luckily, Visual C++ provides
many macros, functions, and global variables for incorporating diagnostic abilities
into your projects. By using these tools, you can print output to a debugging window,
check the integrity of memory blocks, and much more. Table E.6 lists these valuable
diagnostic macros, functions, and global variables. Many are discussed in Chapter
24, &quot;Improving Your Application's Performance,&quot; and Appendix D, &quot;Debugging.&quot;</P>
<P>
<H4>Table E.6&#160;&#160;Diagnostic Macros, Functions, and Global Variables</H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT"><B>Symbol</B></TD>
		<TD ALIGN="LEFT"><B>Description</B></TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxCheckMemory()</TD>
		<TD ALIGN="LEFT">Verifies the integrity of allocated memory.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxDoForAllClasses()</TD>
		<TD ALIGN="LEFT">Calls a given iteration function for all classes that are derived from CObject and
			that incorporate runtime type checking.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxDoForAllObjects()</TD>
		<TD ALIGN="LEFT">Calls a given iteration function for all objects derived from CObject and allocated
			with the new operator.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">afxDump</TD>
		<TD ALIGN="LEFT">A global CDumpContext object that enables a program to send information to the debugger
			window.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxDump()</TD>
		<TD ALIGN="LEFT">Dumps an object's state during a debugging session.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxEnableMemoryTracking()</TD>
		<TD ALIGN="LEFT">Toggles memory tracking.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxIsMemoryBlock()</TD>
		<TD ALIGN="LEFT">Checks that memory allocation was successful.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxIsValidAddress()</TD>
		<TD ALIGN="LEFT">Checks that a memory address range is valid for the program.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxIsValidString()</TD>
		<TD ALIGN="LEFT">Checks string pointer validity.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">afxMemDF</TD>
		<TD ALIGN="LEFT">A global variable that controls memory-allocation diagnostics. It can be set to allocMemDF,
			DelayFreeMemDF, or checkAlwaysMemDF.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">AfxSetAllocHook()</TD>
		<TD ALIGN="LEFT">Sets a user-defined hook function that is called whenever memory allocation is performed.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">afxTraceEnabled</TD>
		<TD ALIGN="LEFT">A global variable that enables or disables TRACE output.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">afxTraceFlags</TD>
		<TD ALIGN="LEFT">A global variable that enables the MFC reporting features.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">ASSERT</TD>
		<TD ALIGN="LEFT">Prints a message and exits the program if the ASSERT expression is FALSE (see Chapter
			24).</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">ASSERT_VALID</TD>
		<TD ALIGN="LEFT">Validates an object by calling the object's AssertValid() function.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">DEBUG_NEW</TD>
		<TD ALIGN="LEFT">Used in place of the new operator to trace memory-leak problems (see Chapter 23).</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">TRACE</TD>
		<TD ALIGN="LEFT">Creates formatted strings for debugging output (see Chapter 23).</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">TRACE0</TD>
		<TD ALIGN="LEFT">Same as TRACE but requires no arguments in the format string.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">TRACE1</TD>
		<TD ALIGN="LEFT">Same as TRACE but requires one argument in the format string.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">TRACE2</TD>
		<TD ALIGN="LEFT">Same as TRACE but requires two arguments in the format string.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">TRACE3</TD>
		<TD ALIGN="LEFT">Same as TRACE but requires three arguments in the format string.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">

⌨️ 快捷键说明

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