📄 fm.htm
字号:
them full of bookmarks and yellow stickies. Although they don't lead you through
the sample applications, they will teach you a lot.</P>
<P>The mainstream of the book is in Chapters 1 through 28. Each chapter teaches you
an important programming task or sometimes two closely related tasks, such as building
a taskbar or adding Help to an application. Detailed instructions show you how to
build a working application, or several working applications, in each chapter.</P>
<P>The first nine chapters cover concepts found in almost every Windows application;
after that, the tasks become less general. Here's a brief overview of some of the
work that is covered.</P>
<P>
<H3><A NAME="Heading4"></A>Dialogs and Controls</H3>
<P>What Windows program doesn't have a dialog box? an edit box? a button? Dialog
boxes and controls are vital to Windows user interfaces, and all of them, even the
simple button or piece of static text, are windows. The common controls enable you
to take advantage of the learning time users have devoted to other programs and the
programming time developers have put in on the operating system in order to use the
same File Open dialog box as everybody else, the same hierarchical tree control,
and so on. Learn more about all these controls in Chapters 2, "Dialogs and Controls,"
and 10, "Windows 95 Common Controls."</P>
<P>
<H3><A NAME="Heading5"></A>Messages and Commands</H3>
<P>Messages form the heart of Windows programming. Whenever anything happens on a
Windows machine, such as a user clicking the mouse or pressing a key, a message is
triggered and sent to one or more windows, which do something about it. Visual C++
makes it easy for you to write code that catches these messages and acts on them.
Chapter 3, "Messages and Commands," explains the concept of messages and
how MFC and other aspects of Visual C++ enable you to deal with them.</P>
<P>
<H3><A NAME="Heading6"></A>The View/Document Paradigm</H3>
<P>A <I>paradigm</I> is a model, a way of looking at things. The designers of MFC
chose to design the framework based on the assumption that every program has something
it wants to save in a file. That collection of information is referred to as the
<I>document</I>. A <I>view</I> is one way of looking at a document. There are many
advantages to separating the view and the document, explained further in Chapter
4, "Documents and Views." MFC provides classes from which to inherit your
document class and your view class, so that common programming tasks such as implementing
scrollbars are no longer your problem.</P>
<P>
<H3><A NAME="Heading7"></A>Drawing Onscreen</H3>
<P>No matter how smart your Windows program is, if you can't tell the user what's
going on by putting some words or pictures onscreen, no one will know what the program
has done. A remarkable amount of the work is automatically done by your view classes
(one of the advantages of adopting the document/view paradigm), but at times you
have to do the drawing yourself. You learn about device contexts, scrolling, and
more in Chapter 5, "Drawing on the Screen."</P>
<P>
<H3><A NAME="Heading8"></A>Printing on Paper</H3>
<P>Adding printing capabilities to your program is sometimes the simplest thing in
the world because the code you use to draw onscreen can be reused to draw on paper.
If more than one page of information is involved, though, things become tricky. Chapter
6, "Printing and Print Preview," explains all this, as well as mapping
modes, headers and footers, and more.</P>
<P>
<H3><A NAME="Heading9"></A>Persistence and File I/O</H3>
<P>Some good things are meant to be only temporary, such as the display of a calculator
or an online chat window. However, most programs can save their documents to a file
and open and load that file to re-create a document that has been stored. MFC simplifies
this by using archives and extending the use of the stream I/O operators >>
and <<. You learn all about reading and writing to files in Chapter 7, "Persistence
and File I/O."</P>
<P>
<H3><A NAME="Heading10"></A>ActiveX Programming</H3>
<P>ActiveX is the successor to OLE, and it's the technology that facilitates communication
between applications at the object level, enabling you to embed a Word document in
an Excel spreadsheet or to embed any of hundreds of kinds of objects in any ActiveX
application. ActiveX chapters include Chapters 13, "ActiveX Concepts,"
14, "Building an ActiveX Container Application," 15, "Building an
ActiveX Server Application," 16, "Building an Automation Server,"
and 17, "Building an ActiveX Control."</P>
<P>
<H3><A NAME="Heading11"></A>The Internet</H3>
<P>Microsoft recognizes that distributed computing, in which work is shared between
two or more computers, is becoming more and more common. Programs need to talk to
each other, people need to send messages across a LAN or around the world, and MFC
has classes that support these kinds of communication. The four Internet chapters
in this book are Chapter 18, "Sockets, MAPI, and the Internet," Chapter
19, "Internet Programming with the WinInet Classes," Chapter 20, "Building
an Internet ActiveX Control," and Chapter 21, "The Active Template Library."</P>
<P>
<H3><A NAME="Heading12"></A>Database Access</H3>
<P>Database programming keeps getting easier. ODBC, Microsoft's Open DataBase Connectivity
package, enables your code to call API functions that access a huge variety of database
files--Oracle, DBase, an Excel spreadsheet, a plain text file, old legacy mainframe
systems using SQL, whatever! You call a standard name function, and the API provided
by the database vendor or a third party handles the translation. The details are
in Chapters 22, "Database Access," and 23, "SQL and the Enterprise
Edition."</P>
<P>
<H3><A NAME="Heading13"></A>Advanced Material</H3>
<P>For developers who have mastered the basics, this book features some advanced
chapters to move your programming skills forward. You will learn how to prevent memory
leaks, find bottlenecks, and locate bugs in your code with the techniques discussed
in Chapter 24, "Improving Your Application's Performance."</P>
<P>Reuse is a hugely popular concept in software development at the moment, especially
with managers who see a chance to lower their development budget. If you'd like to
write reusable code and components, Chapter 25, "Achieving Reuse with the Gallery
and Your Own AppWizards," will take you there.</P>
<P>Often C++ programmers are so busy learning the basics of how to make programs
work that they miss the features that make C++ truly powerful. You will learn in
Chapter 26, "Exceptions and Templates," how to catch errors efficiently
and how to use one set of code in many different situations.</P>
<P>As user demands for high-performance software continue to multiply, developers
must learn entirely new techniques to produce powerful applications that provide
fast response times. For many developers, writing multithreaded applications is a
vital technique. Learn about threading in Chapter 27, "Multitasking with Windows
Threads."</P>
<P>Chapter 28, "Future Explorations," introduces you to topics that are
definitely not for beginners. Learn how to create console applications, use and build
your own DLLs, and work with Unicode.</P>
<P>
<H2><A NAME="Heading14"></A>Conventions Used in This Book</H2>
<P>One thing this book has plenty of is code. Sometimes you need to see only a line
or two, so the code is mixed in with the text, like this:</P>
<P>
<PRE>int SomeFunction( int x, int y);
{
return x+y;
}
</PRE>
<P>You can tell the difference between code and regular text by the fonts used for
each. Sometimes, you'll see a piece of code that's too large to mix in with the text:
You will find an example in Listing 0.1.</P>
<P>
<H4>Listing 0.1</H4>
<PRE>CHostDialog dialog(m_pMainWnd);
if (dialog.DoModal() == IDOK)
{
AppSocket = new CSocket();
if (AppSocket->Connect(dialog.m_hostname,119))
{
while (AppSocket->GetStatus() == CONNECTING)
{
YieldControl();
}
if (AppSocket->GetStatus() == CONNECTED)
{
CString response = AppSocket->GetLine();
SocketAvailable = TRUE;
}
}
}
if (!SocketAvailable)
{
AfxMessageBox("Can't connect to server. Please
¬ quit.",MB_OK|MB_ICONSTOP);
</PRE>
<PRE> }
</PRE>
<P>The character on the next-to-last line (¬) is called the <I>code continuation
character</I>. It indicates a place where a line of code had to be broken to fit
it on the page, but in reality the line doesn't break there. If you're typing code
from the book, don't break the line there--keep going. If you're reading along in
code that was generated for you by Visual C++, don't be confused when the line doesn't
break there.</P>
<P>Remember, the code is in the book so that you can understand what's going on,
not for you to type it. All the code is on the companion Web site as well. Sometimes
you will work your way through the development of an application and see several
versions of a block of code as you go--the final version is on the Web site. You'll
find the site by going to <A HREF="http://www.mcp.com/info"><B>www.mcp.com/info</B></A>
or <A HREF="http://www.gregcons.com/uvc6.htm"><B>www.gregcons.com/uvc6.htm</B></A>.</P>
<BLOCKQUOTE>
<P>
<HR>
<STRONG>TIP:</STRONG> This is a Tip: a shortcut or an interesting feature you might
want to know about.
<HR>
</P>
<P>
<HR>
<STRONG>NOTE:</STRONG> This is a Note: It explains a subtle but important point.
Don't skip Notes, even if you're the kind who skips Tips. n
<HR>
<P>
<HR>
<STRONG>CAUTION:</STRONG><B> </B>This is a Caution, and it's serious. It warns you
of the horrible consequences if you make a false step, so be sure to read all of
these that you come across.
<HR>
</BLOCKQUOTE>
<P>When a word is being defined or emphasized, it's in <I>italic</I>.<I> </I>The
names of variables, functions, and C++ classes are all in monospaced font. Internet
URLS and things you should type are in <B>bold</B>. Remember, an URL never ends with
punctuation, so ignore any comma or period after the URL.</P>
<P>
<H2><A NAME="Heading15"></A>Time to Get Started</H2>
<P>That about wraps up things for the introduction. You've learned what you need
to get started, including some advanced warning about the notations used throughout
the book. Jump right in, learn all about writing Windows applications with MFC, and
then get started on some development of your own! Good luck and have fun.</P>
<CENTER>
<H1></H1>
</CENTER>
<P>
<CENTER>
<P>
<HR>
<A HREF="../ch01/ch01.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> <BR>
</P>
<P>© <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. All
rights reserved.
</CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -