📄 intro.htm
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<TITLE>Special Edition Using Visual C++ 5 - Introduction</TITLE>
<LINK REL="Next" HREF="ch01.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/ch01.htm" target="text">
<META NAME="GENERATOR" CONTENT="Internet Assistant for Microsoft Word 2.03z">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2>Introduction</H2>
<HR>
<P>
Visual C++ is a powerful and complex tool for building 32-bit
applications for Window 95 and Windows NT. These applications
are far larger and more complex than their predecessors for 16-bit
Windows, or older programs that did not use a graphical user interface.
Yet as program size and complexity has grown, programmer effort
has actually decreased, at least for programmers who are using
the right tools.</P>
<P>
Visual C++ is one of the right tools. With its code generating
Wizards it can produce the shell of a working Windows application
in seconds. The class library included with Visual C++, the Microsoft
Foundation Classes, has become the industry standard for Windows
software development in a variety of C++ compilers. The visual
editing tools make layout of menus and dialogs a snap. The time
you invest in learning to use this product will pay itself back
on your first Windows programming project.</P>
<H3>Who Should Read This Book?</H3>
<P>
This book will teach you how to use Visual C++ to build 32-bit
Windows applications, including database applications, Internet
applications, and applications that tap the power of the ActiveX
technology. That's a tall order, and to fit all that in less than
a thousand pages, some things had to go. This book will <B>not</B>
teach you:</P>
<UL>
<LI><B>The C++ programming language:</B> You should already be
familiar with C++. There are occasional mentions of relevent of
C++ and Object Oriented concepts. The introductory text, <I>C++
By Example</I>, is included on the CD.</P>
<LI><B>How to use Windows applications:</B> You should be a proficient
Windows user, able to resize and move Windows, double-click, and
recognize familiar toolbar buttons, for example.</P>
<LI><B>How to use Visual C++ as a C compiler:</B> If you already
work in C, you can use Visual C++ as your compiler, but new developers
should take the plunge to C++.</P>
<LI><B>Windows programming without MFC:</B> This too is OK for
those who know it, but not something to learn now that MFC exists.</P>
<LI><B>The internals of ActiveX programming:</B> This is referred
to in the ActiveX chapters, which tell you only what you need
to know to make it work.</P>
</UL>
<P>
You should read this book if you fit one of these categories:</P>
<UL>
<LI>You know some C++ and some Windows programming techniques,
and are new to Visual C++. You will learn the product much more
quickly than you would if you just tried writing programs.</P>
<LI>You've been working with previous versions of Visual C++.
Many times users learn one way to do things and end up overlooking
some of the newer productivity features.</P>
<LI>You've been working with Visual C++ 5.0 for a while and are
beginning to suspect you're doing things the hard way. Maybe you
are.</P>
<LI>You work in Visual C++ 5.0 regularly, and you need to add
a feature to your product. For tasks like Help, printing, and
threading, you'll find a "hand up" to get started.</P>
</UL>
<H3>Before You Start Reading</H3>
<P>
You will need a copy of Visual C++ 5.0, and need to have it installed.
The installation process is simple and easy to follow, so it's
not covered in this book.</P>
<P>
Before you buy Visual C++ 5.0, you'll need a 32-bit Windows operating
system: Windows 95, or Windows NT Server, or Workstation. That
means your machine will have to be reasonably powerful and modern:
say a 486 or better for your processor, at least 16M of RAM and
500M of disk space, and a screen that can do 800 x 600 pixel displays,
or even finer resolutions. The illustrations in this book were
all prepared at a resolution of 800 x 600 and, as you'll see,
there are times when things get a little crowded.</P>
<P>
Finally, you need to make a promise to yourself: that you will
follow along in Visual C++ as you read this book, clicking and
typing and trying things out. You don't need to type all the code
if you don't want to: it's all on the CD for you to look at. But
you should be ready to open the files and look at the code as
you go.</P>
<H3>What This Book Covers</H3>
<P>
A topic such as Windows programming in Visual C++ covers a lot
of ground. This book is split into learning chapters (1 to 28)
and appendixes (A to F). Be sure to look over the titles of the
appendixes now, and turn to them whenever you aren't quite sure
how to do something. They are:</P>
<UL>
<LI><A HREF="indexa.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/indexa.htm" target="text" >Appendix A</A>, "Windows Programming
Review and a Look Inside CWnd," covers the specifics of Windows
programming that are now hidden from you by MFC classes like CWnd.</P>
<LI><A HREF="indexb.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/indexb.htm" target="text" >Appendix B</A>, "The Developer
Studio User Interface," explains all the menus, toolbars,
editing areas on the screens, shortcuts, and so on that make up
the highly complicated and richly powerful interface between you
and Developer Studio.</P>
<LI><A HREF="indexc.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/indexc.htm" target="text" >Appendix C</A>, "Debugging,"
explains the extra menus, windows, toolbars, and commands involved
in debugging a running application.</P>
<LI><A HREF="indexd.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/indexd.htm" target="text" >Appendix D</A>, "MFC Macros and
Globals," summarizes the many preprocessor macros and global
variables and functions sprinkled throughout code generated by
the Developer Studio wizards.</P>
<LI><A HREF="indexe.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/indexe.htm" target="text" >Appendix E</A>, "Useful Classes,"
describes the classes used throughout the book to manipulate dates,
strings, and collections of objects.</P>
<LI><A HREF="indexf.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/indexf.htm" target="text" >Appendix F</A>, "What's On The
CD?," is self-explanatory.</P>
</UL>
<P>
Depending on your background and your willingness to poke around
under menus and in the online help, you may just skim these chapters
once and never return, or you may fill them full of bookmarks
and yellow stickies. While they don't work you through sample
applications, they will teach you a lot.</P>
<P>
The mainstream of the book is Chapters 1 through 28. Each chapter
teaches you an important programming task, or sometimes two closely
related tasks, like 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 that will be in almost
every Windows application; after that the tasks become less general.
Here's a quick overview of some of the work that is covered.</P>
<P>
<B>Dialogs and Controls</P></B>
<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 allow you to take advantage of
the learning time users have put in on other programs, and the
programming time developers have put in on the operating system,
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 <A HREF="index02.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index02.htm" target="text" >Chapter 2</A>, "Dialog
Boxes and Controls," and <A HREF="index03.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index03.htm" target="text" >Chapter 3</A>,
"Windows 95 Common Controls."</P>
<P>
<B>Messages and Commands</P></B>
<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. <A HREF="index04.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index04.htm" target="text" >Chapter 4</A>, "Messages and
Commands," explains the concept of messages and how MFC and
other aspects of Visual C++ lets you deal with them.</P>
<P>
<B>The View/Document Paradigm</P></B>
<P>
A <I>paradigm</I> is a model, a way of looking at things. The
designers of MFC chose to design the framework by using 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 a
lot of advantages to separating the view and the document, and
they are explained further in <A HREF="index05.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index05.htm" target="text" >Chapter 5</A>,
"Documents and Views." MFC provides classes from which
to inherit your document class and your view class, so that common
programming tasks like implementing scroll bars are no longer
your problem.</P>
<P>
<B>Drawing on the Screen</P></B>
<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 onto
the screen, no one will know what the program has done. A remarkably
large amount of the work is done automatically by your view classes
(one of the advantages of adopting the document/view paradigm),
but there will be times you have to do the drawing yourself. You
learn about device contexts, scrolling, and more in <A HREF="index06.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index06.htm" target="text" >Chapter 6</A>,
"Drawing on the Screen."</P>
<P>
<B>Printing on Paper</P></B>
<P>
Adding printing capabilities to your program is sometimes the
simplest thing in the world, because the code you use to draw
on the screen can be reused to draw on paper. But if there is
more than one page of information involved, things start to get
tricky. <A HREF="index07.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index07.htm" target="text" >Chapter 7</A>, "Printing and
Print Preview," explains all of this, plus mapping modes,
headers and footers, and more.</P>
<P>
<B>Persistence and File I/O</P></B>
<P>
Some good things are meant to be only temporary, like the display
of a calculator or an online chat window. But most programs can
save their documents to a file, and open and load that file to
recreate a document that has been stored. MFC makes this remarkably
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -