?? apa.htm
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1"> <META NAME="GENERATOR" Content="Symantec Visual Page Mac 1.1"> <TITLE>Teach Yourself Visual C++® 5 in 24 Hours -- Appendix A -- The Developer Studio IDE</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><H1 ALIGN="CENTER"><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM"BORDER="0"><BR><FONT COLOR="#000077">Teach Yourself Visual C++® 5 in 24 Hours</FONT></H1><CENTER><P><A HREF="../ch24/ch24.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../apb/apb.htm"><IMGSRC="../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><H1 ALIGN="CENTER"><FONT COLOR="#000077">- Appendix A -<BR>The Developer Studio IDE</FONT></H1><P>This appendix covers some basic information about the Developer Studio IntegratedDevelopment Environment.<H2><FONT COLOR="#000077"><B>What Is the Developer Studio Editor?</B></FONT></H2><P>Developer Studio includes a sophisticated editor as one of its tools. The editoris integrated with the other parts of Developer Studio; files are edited in a DeveloperStudio child window. You use the Developer Studio editor to edit C++ source filesthat will be compiled into Windows programs. The editor supplied with Developer Studiois similar to a word processor, but instead of fancy text-formatting features, ithas features that help make writing source code easy.<H3><FONT COLOR="#000077"><B>Why Use the Developer Studio Editor?</B></FONT></H3><P>You can use almost any editor to write C++ source code, but there are severalreasons to consider using the editor integrated with Developer Studio. The editorincludes many features that are found in specialized programming editors.<UL> <LI>Automatic syntax highlighting colors keywords, comments, and other source code in different colors.<BR> <BR> <LI>Automatic "smart" indenting helps line up your code into easy-to-read columns.<BR> <BR> <LI>Emulation for keystrokes used by other editors helps if you are familiar with editors such as Brief and Epsilon.<BR> <BR> <LI>Integrated keyword help enables you to get help on any keyword, MFC class, or Windows function just by pressing F1.<BR> <BR> <LI>Drag-and-drop editing enables you to easily move text by dragging it with the mouse.<BR> <BR> <LI>Integration with the compiler's error output helps you step through the list of errors reported by the compiler and positions the cursor at every error. This enables you to make corrections easily without leaving Developer Studio.</UL><H3><FONT COLOR="#000077"><B>Using the Developer Studio Editor</B></FONT></H3><P>The easiest way to learn about the Developer Studio editor is to edit a file andrun through a few common actions, such as creating a new source file, saving andloading files, and using a few keyboard commands.<H4><FONT COLOR="#000077">Editing a New Source File</FONT></H4><P>To edit a new source file, click the New Text File icon on the toolbar. The NewText File icon looks like a blank piece of paper with a yellow highlight in one corner.You can also open a new source file using the menu by following these steps:<DL> <DD>1. Select New from the File menu. This displays the New dialog box, which enables you to create a new text file, project, or other type of file.<BR> <BR> 2. Select the Files tab. Several different types of files will be displayed. Select the C++ Source File icon in the list box.<BR> <BR> 3. Click OK to close the New dialog box and open the new file for editing.</DL><P>Each of the preceding methods creates an empty source file ready for editing.Type the source code from Listing A.1 into the new file.<H4><FONT COLOR="#000077">TYPE: Listing A.1. A minimal C++ program.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>// This is a comment</TT><TT>int main()</TT><TT>{</TT><TT> return 0;</TT></FONT></PRE><P><TT>}</TT> The source code in Listing A.1 is a legal C++ program, although itdoesn't actually do anything. As you typed the source code into the editor, the colorsfor some of the words should have changed. This is called syntax highlighting, andit's one of the features of Developer Studio's editor.</P><P>The first line in Listing A.1 begins with <TT>//</TT>, which is used to mark thebeginning of a single-line comment in a C++ program. By default, comments are coloredgreen by the Developer Studio editor. In contrast, <TT>int</TT> and <TT>return</TT>are colored blue to indicate that they are C++ keywords.</P><P>Another editor feature is called <I>smart indenting</I>. This feature automaticallyarranges your text as you type, applying formatting rules to your text as each wordor line is entered into the editor. For example, enter the source code from ListingA.2 into the text editor. Press Return at the end of each line, but do not add spacesor tabs. As each line is typed, the editor rearranges the text into a standard formatfor you.<H4><FONT COLOR="#000077">TYPE: Listing A.2. A simple C++ class declaration.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>class CFoo</TT><TT>{</TT><TT> int nFoo;</TT><TT> int nBar;</TT><TT>public:</TT><TT> CFoo();</TT></FONT></PRE><P><TT>}</TT> The source code provided in this book follows the same formatting conventionused by the Developer Studio editor. Although some coding styles might be more compact,this style is very easy to read.<H4><FONT COLOR="#000077">Saving a Source File</FONT></H4><P>To save the contents of the editor, click the Save icon on the toolbar. The Saveicon looks like a small floppy disk. You can also press Ctrl+S or select Save fromthe File menu.</P><P>When updating an existing source file, you don't see a dialog box, and no furtheraction is needed on your part. The existing file is updated using the current contentsof the editor. If you save a new file, you see the Save As dialog box, and you mustchoose a location and filename for the new source file. Save the contents of ListingA.2 in the <TT>C:\</TT> directory using the name <TT>CFoo.cpp</TT>. After savingthe file, close <TT>CFoo.cpp</TT> by selecting Close from the File menu.</P><P>To save a file under a new name, select Save As from the File menu or press F12.Enter the new path and filename using the Save As dialog box as described previously.<H4><FONT COLOR="#000077">Opening an Existing Source File</FONT></H4><P>To open an existing source file, click the Open icon on the toolbar. The Openicon looks like a folder that is partially open. You can also press Ctrl+O or selectOpen from the File menu. Any of these methods brings up the File Open dialog box.</P><P>To open the <TT>CFoo.cpp</TT> file for editing, pop up the File Open dialog boxand navigate to the <TT>C:\</TT> directory. Select the <TT>CFoo.cpp</TT> file andclick the button labeled Open. The <TT>CFoo.cpp</TT> file is loaded into the editor.<H4><FONT COLOR="#000077">Using Editor Commands</FONT></H4><P>As discussed in the first hour, a large set of editing commands is available fromthe keyboard. Although most editor commands are also available from the menu or toolbar,the following commands are frequently used from the keyboard:<UL> <LI>Undo, which reverses the previous editor action, is performed by pressing Ctrl+Z on the keyboard. The number of undo steps that can be performed is configurable in the Options dialog box.<BR> <BR> <LI>Redo, which is used to reverse an undo, is performed by pressing Ctrl+Y.<BR> <BR> <LI>LineCut, which removes or "cuts" the current line and places it on the Clipboard, is performed by pressing Ctrl+L.<BR> <BR> <LI>Cut removes any marked text from the editor and places it on the Clipboard. This command is performed by pressing Ctrl+X.<BR> <BR> <LI>Copy copies any marked text to the Clipboard but unlike the Cut command, doesn't remove the text from the editor. If no text is marked, the current line is copied. This command is performed by pressing Ctrl+C.<BR> <BR> <LI>Paste copies the Clipboard contents into the editor at the insertion point. This command is performed by pressing Ctrl+V.</UL><P>This is only a small list of the available keyboard commands. To see a completelist, select Keyboard from the Help menu.<H2><FONT COLOR="#000077"><B>What Is InfoViewer?</B></FONT></H2><P>InfoViewer is the online help system integrated into Developer Studio. Usually,the indexes used by the InfoViewer are copied to your hard disk, and the actual databaseremains on the CD. This spares a great deal of hard disk space. If you would liketo speed up InfoViewer, run Visual C++ setup again and install InfoViewer to thehard disk. Select a custom installation procedure and make sure you check the InfoViewerbox.<H3><FONT COLOR="#000077"><B>Why Use InfoViewer?</B></FONT></H3><P>Because Visual C++ is not sold with a documentation set, InfoViewer is the onlydocumentation that is included with the product. Although the online documentationis also available from Microsoft in book form, it costs you extra.</P><P>InfoViewer has several advantages over hard-copy documentation:<UL> <LI>It is fully searchable. There's a saying, "You can't search dead wood," and it applies perfectly to the difference between hard copy documentation and Developer Studio's InfoViewer. Suppose you're having a problem with a list box control. In a few seconds, you can search the entire documentation set, including the MSDN library if you have it, and immediately begin looking up relevant information.<BR> <BR> <LI>You can add annotations. You can add Post-it notes to your hard-copy documentation too, but InfoViewer's annotations are guaranteed to stick to the page.<BR> <BR> <LI>You get context-sensitive help that brings up InfoViewer when you press the F1 key. When's the last time you pressed F1 and had a book fall off the bookshelf and open to the correct page?<BR> <BR> <LI>InfoViewer is completely integrated into Developer Studio. One of the tabs in the project workspace window displays the InfoViewer table of contents. The current topic is displayed in a Developer Studio child window.<BR> <BR> <LI>Last, but not least, you can always print out a hard copy when needed, and you don't even need a copying machine.</UL><H3><FONT COLOR="#000077"><B>Using InfoViewer</B></FONT></H3><P>You interact with the InfoViewer help system in two windows:<UL> <LI>The contents pane is displayed in the project workspace window.<BR> <BR> <LI>The information topic is an MDI child window.</UL><H4><FONT COLOR="#000077">Getting Context-Sensitive Help</FONT></H4><P>To get context-sensitive help from InfoViewer, press F1. You select a topic basedon the current window and cursor position, and you see the InfoViewer window containingcontext-sensitive help. If you press F1 while editing a source file, help is providedfor the word under the cursor. If there is more than one possible help topic, yousee a list of choices.</P><P>Open a new document for editing, as described earlier in this chapter, and enterthe source code provided in Listing A.3.<H4><FONT COLOR="#000077">TYPE: Listing A.3. Testing InfoViewer's context-sensitivehelp.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>int main()</TT><TT>{</TT><TT> return 0;</TT></FONT></PRE><P><TT>}</TT> Every word in this example has a help topic. To get context-sensitivehelp, move the cursor to any word in Listing A.3 and press the F1 key. The help topicis displayed in a dockable window next to your source code. To return the windowsto their original sizes and hide the InfoViewer window, press Escape.<H4><FONT COLOR="#000077">Searching for Help Using a Keyword</FONT></H4><P>To search the InfoViewer keyword list, open the Search dialog box by selectingSearch from the Help menu or by right-clicking in the InfoViewer window. The Searchdialog box enables you to select a help topic by entering a keyword. The keywordlist box scrolls as you make your entry, which is helpful when you're not quite surehow to spell a keyword.</P><P>The Search dialog box also enables you to create a query in order to find a topic.You can use a query to search the entire contents, a subset of the contents, or theresults of the last query. The last option is useful when you're narrowing the scopeof a search. You can apply the query to the entire contents of InfoViewer or to onlythe titles of each topic.</P><P>A query can be as simple as a single word, or it can be used to look for wordsthat are adjacent or close to each other. You can use the <TT>AND</TT>, <TT>OR</TT>,<TT>NEAR</TT>, and <TT>NOT</TT> operators to create queries. Operators aren't requiredto be capitalized, although it helps to set off the operator from your search items.For example, to find all the topics where the words <I>dialog</I> and <I>tab</I>are close to each other, use the following query:</P><PRE><FONT COLOR="#0066FF"><TT>dialog NEAR tab</TT></FONT></PRE><P>To look for topics where the word <I>main</I> is found but exclude any topicsthat contain the word <I>WinMain</I>, use the following query:</P><PRE><FONT COLOR="#0066FF"><TT>main NOT WinMain</TT></FONT></PRE><H4><FONT COLOR="#000077">Browsing Through the Contents Window</FONT></H4><P>A third way to use InfoViewer is to browse through the contents pane in the projectworkspace window. The contents pane displays the titles for every available topic,arranged in an easy-to-use tree view.</P><P>When the InfoViewer contents tree is completely collapsed, the contents pane displaysthe titles for the top level of the available topics. The titles displayed at thetop level are somewhat like the titles of a series of books; the icon even lookslike a book. When the book icon is closed, a plus sign appears next to the book title,indicating that the book can be opened to display its contents. Click the plus signto open the book icon and expand the contents tree to display the contents of theopen book. Topics are represented by icons that look like a page of text. To displaythe selected topic, click the topic icon; the InfoViewer topic window opens. Clickingthe plus sign also changes the plus sign to a minus, which you can click to closethe book.</P><CENTER><P><HR><A HREF="../ch24/ch24.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../apb/apb.htm"><IMGSRC="../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><BR><BR><IMG SRC="../button/corp.gif" WIDTH="284" HEIGHT="45" ALIGN="BOTTOM" ALT="Macmillan Computer Publishing USA"BORDER="0"></P><P>© <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. Allrights reserved.</CENTER></BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -