📄 ch09.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 += '</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"> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1"> <TITLE>Teach Yourself Borland Delphi 4 in 21 Days -- Ch 9 -- Projects, the Code Editor, and the Code Explorer</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><CENTER><H1><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"></H1></CENTER><CENTER><H1><BR>Teach Yourself Borland Delphi 4 in 21 Days</H1></CENTER><CENTER><P><A HREF="../ch08/ch08.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch10/ch10.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><CENTER><H1>- 9 -</H1></CENTER><CENTER><H1>Projects, the Code Editor, and the Code Explorer</H1></CENTER><UL> <LI><A HREF="#Heading1">Everyone Needs a Project</A> <LI><A HREF="#Heading2">Using the Project Manager</A> <UL> <LI><A HREF="#Heading3">Project Groups</A> <LI><A HREF="#Heading4">The Project Manager Window</A> <LI><A HREF="#Heading5">Creating and Using Project Groups</A> <LI><A HREF="#Heading6">Building Projects or Project Groups</A> </UL> <LI><A HREF="#Heading7">Understanding Project Options</A> <UL> <LI><A HREF="#Heading8">The Forms Page</A> <LI><A HREF="#Heading9">The Application Page</A> <LI><A HREF="#Heading10">The Compiler Page</A> <LI><A HREF="#Heading11">The Linker Page</A> <LI><A HREF="#Heading12">The Directories/Conditionals Page</A> <LI><A HREF="#Heading13">The Version Info Page</A> <LI><A HREF="#Heading14">The Packages Page</A> </UL> <LI><A HREF="#Heading15">The Delphi Code Editor</A> <UL> <LI><A HREF="#Heading16">Basic Editor Operations</A> <LI><A HREF="#Heading17">Highlighting Text</A> <LI><A HREF="#Heading18">Specialized Editor Features</A> <LI><A HREF="#Heading19">Module Browsing</A> <LI><A HREF="#Heading20">The Code Editor Context Menu</A> <LI><A HREF="#Heading21">Changing the Editor Options</A> </UL> <LI><A HREF="#Heading22">The Code Explorer</A> <UL> <LI><A HREF="#Heading23">The Code Explorer Context Menu</A> <LI><A HREF="#Heading24">Navigating a Unit</A> <LI><A HREF="#Heading25">Adding Code Using the Code Explorer</A> <LI><A HREF="#Heading26">Code Explorer Options</A> </UL> <LI><A HREF="#Heading27">Summary</A> <LI><A HREF="#Heading28">Workshop</A> <UL> <LI><A HREF="#Heading29">Q&A</A> <LI><A HREF="#Heading30">Quiz</A> <LI><A HREF="#Heading31">Exercises</A> </UL></UL><P><HR SIZE="4"><CENTER><H1></H1></CENTER><P>Today you learn more about the Delphi IDE and how it all works together to createreal-world working programs. Specifically you learn about</P><UL> <LI>Projects and the Project Manager <P> <LI>The Code Editor <P> <LI>The Code Explorer</UL><P>It will be a long day, but a rewarding one.</P><P><H2><A NAME="Heading1"></A>Everyone Needs a Project</H2><P>On Day 4, "The Delphi IDE Explored," you were introduced to Delphi projectsand found out a little about how projects work. In this section, I cover projectsin detail. Projects are a fact of life with Delphi. You cannot create a program withouta project. The project makes sure that everything works together to create a workingapplication. The following sections talk about</P><UL> <LI>The Project Manager <P> <LI>Project groups <P> <LI>The Project Options dialog box</UL><H2><A NAME="Heading2"></A>Using the Project Manager</H2><P>At some point, every project needs some management. Maybe you must add a new sourceunit to the project, or maybe you must remove a source unit. You might need to addanother type of file to the project, such as a binary resource file. You add andremove units and other project files through the Project Manager.</P><P><H3><A NAME="Heading3"></A>Project Groups</H3><P>On Day 4, I said that a project is a collection of files that work together tocreate a stand-alone executable file or DLL. That's the definition of a project asfar as the Delphi IDE is concerned. In the real world, you might have a differentkind of project, such as a job that you have to complete.</P><P>A large project might include one or more executable files and several DLLs. Becausesome projects consist of more than a single executable program, Delphi enables youto group several Delphi projects together and deal with them as a single unit. Thisunit is called a <I>project group</I>.</P><P><H4>Why Use Project Groups?</H4><P>You might be wondering what advantage project groups provide. Project groups giveyou the following:</P><UL> <LI>Better control over a complete software project. <P> <LI>The ability to work on a DLL and a test EXE for the DLL at the same time. <P> <LI>The ability to build (compile and link) a group of projects all at one time. <P> <LI>The ability to have several projects open at one time and to easily switch between open projects. <P> <LI>A way to organize related projects.</UL><P>A project that creates a single executable file doesn't need a project group.A single project can hardly be considered a group, right? In the case of a singleproject, the concept of a project group is out of place.</P><P>But imagine for a moment a program that includes an EXE and a single supportingDLL. Both the DLL and the EXE go together. Usually, if you are working on the DLL,you will want the EXE present so that you can immediately test any changes you maketo the DLL. In this scenario, a project group makes perfect sense because the EXEand DLL go everywhere together.</P><P>You can create a project group that contains these two individual projects andsave it. When you want to work on either the application or the DLL, you can openthe project group rather than an individual project. When you open the project group,both the EXE project and the DLL project are displayed. You can work on either theDLL or the EXE in the Code Editor and switch back and forth between them any timeyou want. Figure 9.1 shows the Project Manager window with this type of project groupopen.</P><P><A HREF="javascript:popUp('28670901.gif')"><B>FIGURE 9.1.</B></A><B> </B><I>TheProject Manager window showing a project group.</I></P><P>Another reason to have a project group is so that you can group related projects.That probably sounds like it doesn't make much sense, so let me explain. Here atTurboPower Software we have a product called Async Professional, which is a collectionof serial communications components. These components include three main categories:basic serial communications, faxing, and TAPI. We include dozens of sample programswith Async Professional covering each of these three categories.</P><P>Given that scenario, we could create a project group for all of our faxing examples,one for all of our TAPI examples, and one for all of our basic serial communicationsexamples. Our users could then open the TAPI Examples project group and have allthe TAPI examples in one neat package. The entire project group could be built atone time, thereby saving the time and aggravation of opening and building each projectindividually. In this case, the projects don't work together like a DLL and EXE do,but the projects are related, so the concept of a project group makes just as muchsense.</P><P><H4>The Active Project</H4><P>In any project group there is always an active project. The active project isdisplayed in the Project Manager in bold type. In Figure 9.1, the active projectis the project called TestDll. The active project is the project that will be builtwhen you choose Make or Build from the Project menu on the Delphi main menu.</P><P>These menu items are modified each time a project is made the active project.For example, if the active project is called Project1, the menu items will be calledMake Project1 and Build Project1. If a project called PictView is made the activeproject, these two menu items will be called Make PictView and Build PictView.</P><P>The active project also has significance when a new form or a new unit is addedusing the Project Manager. When you create a new form using the Project Manager,the new form will be added to the active project regardless of which node in theProject Manager is currently selected. The active project is also the project towhich new forms or units are added if you add new elements via the Delphi main menuor the Delphi toolbar.</P><P>You can make a project the active project in one of several ways. One way is toselect any item in the project node that you want to make the active project andclick the Activate Selected Project button on the top of the Project Manager. Anotherway is to simply double-click the project node itself. Finally, you can choose Activatefrom the project node context menu to activate a particular project.</P><P><H3><A NAME="Heading4"></A>The Project Manager Window</H3><P>The Project Manager in Delphi 4 is brand-new. The Project Manager concept is notnew to Delphi 4, but the current implementation is much better than the previousProject Manager. The Project Manager is the central controller for all of your projectsand your program groups. It enables you to add files to a project, delete files froma project, view a unit or form, add projects to the project group, change the orderof projects, and more. To display the Project Manager, choose View|Project Managerfrom the main menu or press Ctrl+Alt+F11.</P><P>The Project Manager window contains a tree view control that displays up to fourlevels. Those levels are as follows:</P><UL> <LI>The project group <P> <LI>The projects within the project group<BR> <BR> <LI>Forms and other files within the project <LI>Individual form files and units under the form node</UL><P>Naturally, the individual nodes can be collapsed or expanded as with any treeview control. The Project Manager nodes have icons that indicate whether the nodecontains a project, an individual file, a form, or a form/unit pair. Refer to Figure9.1 to see the different icons and levels that the Project Manager displays.</P><BLOCKQUOTE> <P><HR><strong>NOTE:</strong> In previous versions of Delphi, the Project Manager showed the path to any units as well as the unit filename. The Delphi 4 Project Manager does not show the path and filename in the same way. To see the path and filename, click on a unit in the Project Manager window and the Project Manager status bar will show the full path and filename for the unit (refer to Figure 9.1). <HR></BLOCKQUOTE><H4>The Project Manager Context Menus</H4><P>Most of the Project Manager's work is done through the Manager's context menus.There are four separate context menus for the Project Manager. The following sectionsdescribe each of the context menus.</P><P><B>The Project Group Context Menu</B></P><P>The project group context menu is the context menu you see when you right-clickthe project group node at the top of the Project Manager tree. Table 9.1 lists theproject group context menu items that appear on this menu.</P><P><H4>TABLE 9.1. THE PROJECT GROUP CONTEXT MENU ITEMS.</H4>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -