📄 ape.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function popUp(pPage) {
var fullURL = document.location;
var textURL = fullURL.toString();
var URLlen = textURL.length;
var lenMinusPage = textURL.lastIndexOf("/");
lenMinusPage += 1;
var fullPath = textURL.substring(0,lenMinusPage);
popUpWin = window.open('','popWin','resizable=yes,scrollbars=no,width=525,height=394');
figDoc= popUpWin.document;
zhtm= '<HTML><HEAD><TITLE>' + pPage + '</TITLE>';
zhtm += '<link rel="stylesheet" href="/includes/stylesheets/ebooks.css"></head>';
zhtm += '<BODY bgcolor="#FFFFFF">';
zhtm += '<IMG SRC="' + fullPath + pPage + '">';
zhtm += '<P><B>' + pPage + '</B>';
zhtm += '</BODY></HTML>';
window.popUpWin.document.write(zhtm);
window.popUpWin.document.close();
// Johnny Jackson 4/28/98
}
//-->
</SCRIPT>
<link rel="stylesheet" href="/includes/stylesheets/ebooks.css">
<TITLE>Special Edition Using Visual C++ 6 -- Appendix E -- MFC Macros and Globals</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
<CENTER>
<H1><IMG SRC="../button/que.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR>
Special Edition Using Visual C++ 6</H1>
</CENTER>
<CENTER>
<P><A HREF="../apd/apd.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../apf/apf.htm"><IMG
SRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A>
<HR>
</CENTER>
<CENTER>
<H1>- E -</H1>
</CENTER>
<CENTER>
<H1>MFC Macros and Globals</H1>
</CENTER>
<UL>
<LI><A HREF="#Heading1">Application Information and Management Functions</A>
<LI><A HREF="#Heading2">ClassWizard Comment Delimiters</A>
<LI><A HREF="#Heading3">Collection Class Helper Functions</A>
<LI><A HREF="#Heading4">CString Formatting and Message-Box Display</A>
<LI><A HREF="#Heading5">Data Types</A>
<LI><A HREF="#Heading6">Diagnostic Services</A>
<LI><A HREF="#Heading7">Exception Processing</A>
<LI><A HREF="#Heading8">Message-Map Macros</A>
<LI><A HREF="#Heading9">Runtime Object Model Services</A>
<LI><A HREF="#Heading10">Standard Command and Window IDs</A>
</UL>
<P>
<HR SIZE="4">
<CENTER>
<H1></H1>
</CENTER>
<P>When you're writing programs, you must use many types of data and operations again
and again. Sometimes, you have to do something as simple as creating a portable integer
data type. Other times, you need to do something a little more complex, such as extracting
a word from a long word value or storing the position of the mouse pointer. As you
might know, when you compile your program with Visual C++, many constants and variables
are already defined. You can use these in your programs to save time writing code
and to make your programs more portable and more readable for other programmers.
In the following tables, you'll have a look at the most important of these globally
available constants, macros, and variables.</P>
<P>Because there are so many constants, macros, and global variables, it is helpful
to divide them into the following ten categories. The next sections describe each
of these categories and the symbols they define:</P>
<UL>
<LI>Application information and management
<P>
<LI>ClassWizard comment delimiters
<P>
<LI>Collection class helpers
<P>
<LI>CString formatting and message-box display
<P>
<LI>Data types
<P>
<LI>Diagnostic services
<P>
<LI>Exception processing
<P>
<LI>Message maps
<P>
<LI>Runtime object model services
<P>
<LI>Standard command and window IDs
</UL>
<H2><A NAME="Heading1"></A>Application Information and Management Functions</H2>
<P>Because a typical Visual C++ application contains only one application object
but many other objects created from other MFC classes, you frequently need to obtain
information about the application in different places in a program. Visual C++ defines
a set of global functions that return this information to any class in a program.
These functions, listed in Table E.1, can be called from anywhere within an MFC program.
For example, you frequently need to get a pointer to an application's main window.
The following function call accomplishes that task:</P>
<P>
<PRE>CWnd* pWnd = AfxGetMainWnd();
</PRE>
<H4>Table E.1  Application Information and Management</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">AfxBeginThread()</TD>
<TD ALIGN="LEFT">Creates a new thread (see Chapter 27, "Multitasking with Windows Threads")</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxEndThread()</TD>
<TD ALIGN="LEFT">Terminates a thread</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxGetApp()</TD>
<TD ALIGN="LEFT">Gets the application's CWinApp pointer</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxGetAppName()</TD>
<TD ALIGN="LEFT">Gets the application's name</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxGetInstanceHandle()</TD>
<TD ALIGN="LEFT">Gets the application's instance handle</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxGetMainWnd()</TD>
<TD ALIGN="LEFT">Gets a pointer to the application's main window</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxGetResourceHandle()</TD>
<TD ALIGN="LEFT">Gets the application's resource handle</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxGetThread()</TD>
<TD ALIGN="LEFT">Gets a pointer to a CWinThread object</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxRegisterClass()</TD>
<TD ALIGN="LEFT">Registers a window class in an MFC DLL</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxRegisterWndClass()</TD>
<TD ALIGN="LEFT">Registers a Windows window class in an MFC application</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxSetResourceHandle()</TD>
<TD ALIGN="LEFT">Sets the instance handle that determines where to load the application's default
resources</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AfxSocketInit()</TD>
<TD ALIGN="LEFT">Initializes Windows Sockets (see Chapter 18, "Sockets, MAPI, and the Internet")</TD>
</TR>
</TABLE>
<H2><A NAME="Heading2"></A>ClassWizard Comment Delimiters</H2>
<P>Visual C++ defines a number of delimiters that ClassWizard uses to keep track
of what it's doing, as well as to locate specific areas of source code. Although
you'll rarely, if ever, use these macros yourself, you will see them embedded in
your AppWizard applications, so you might like to know exactly what they do. Table
E.2 fills you in.</P>
<P>
<H4>Table E.2  ClassWizard Delimiters</H4>
<P>
<TABLE BORDER="1">
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT"><B>Delimiter</B></TD>
<TD ALIGN="LEFT"><B>Description</B></TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_DATA</TD>
<TD ALIGN="LEFT">Starts and ends member variable declarations in header files that are associated
with dialog data exchange</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_DATA_INIT</TD>
<TD ALIGN="LEFT">Starts and ends dialog data exchange variable initialization in a dialog class's
constructor</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_DATA_MAP</TD>
<TD ALIGN="LEFT">Starts and ends dialog data exchange function calls in a dialog class's DoDataExchange()
function</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_DISP</TD>
<TD ALIGN="LEFT">Starts and ends Automation declarations in header files</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_DISP_MAP</TD>
<TD ALIGN="LEFT">Starts and ends Automation mapping in implementation files</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_EVENT</TD>
<TD ALIGN="LEFT">Starts and ends ActiveX event declarations in header files</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_EVENT_MAP</TD>
<TD ALIGN="LEFT">Starts and ends ActiveX events in implementation files</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_FIELD</TD>
<TD ALIGN="LEFT">Starts and ends member variable declarations in header files that are associated
with database record field exchange</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_FIELD_INIT</TD>
<TD ALIGN="LEFT">Starts and ends record field exchange member variable initialization in a record
set class's constructor</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_FIELD_MAP</TD>
<TD ALIGN="LEFT">Starts and ends record field exchange function calls in a record set class's DoFieldExchange()
function</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_MSG</TD>
<TD ALIGN="LEFT">Starts and ends ClassWizard entries in header files for classes that use message
maps</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_MSG_MAP</TD>
<TD ALIGN="LEFT">Starts and ends message map entries</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD ALIGN="LEFT">AFX_VIRTUAL</TD>
<TD ALIGN="LEFT">Starts and ends virtual function overrides in header files</TD>
</TR>
</TABLE>
<H2><A NAME="Heading3"></A>Collection Class Helper Functions</H2>
<P>Because certain types of data structures are so commonly used in programming,
MFC defines collection classes that enable you to get these common data structures
initialized quickly and manipulated easily. MFC includes collection classes for arrays,
linked lists, and mapping tables. (See Appendix F, "Useful Classes," for
more on these constructs.) Each of these types of collections contains elements that
represent the individual pieces of data that compose the collection. To make it easier
to access these elements, MFC defines a set of functions created from templates (see
Chapter 26, "Exceptions and Templates," for more on templates.) Table E.3
shows the functions, and you provide the implementation for each particular data
type.</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -