⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch08.htm

📁 delphi自学的好教材!特别适合刚刚起步学习delphi的人员!同样对使用者具有参考价值!
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<!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 8 -- Creating Applications in Delphi</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><CENTER><H1><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"></H1><H1><BR>Teach Yourself Borland Delphi 4 in 21 Days</H1></CENTER><CENTER><P><A HREF="../ch07/ch07.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch09/ch09.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>- 8 -</H1></CENTER><CENTER><H1>Creating Applications in Delphi</H1></CENTER><UL>	<LI><A HREF="#Heading1">Working with the Object Repository</A>	<UL>		<LI><A HREF="#Heading2">Object Repository Pages and Options</A>		<LI><A HREF="#Heading3">The Copy Button</A>		<LI><A HREF="#Heading4">Creating New Objects from the Object Repository</A>		<LI><A HREF="#Heading5">Adding Objects to the Object Repository</A>		<LI><A HREF="#Heading6">Adding Projects to the Object Repository</A>		<LI><A HREF="#Heading7">Object Repository Housekeeping</A>	</UL>	<LI><A HREF="#Heading8">Building Forms and Applications with the Wizards</A>	<UL>		<LI><A HREF="#Heading9">Using the Dialog Wizard</A>		<LI><A HREF="#Heading10">Creating Applications with the Application Wizard</A>	</UL>	<LI><A HREF="#Heading11">Adding Methods and Data Fields to Code</A>	<LI><A HREF="#Heading12">How Delphi Manages Class Declarations</A>	<LI><A HREF="#Heading13">Adding a Method to Your Code</A>	<UL>		<LI><A HREF="#Heading14">Adding a Class Data Field</A>		<LI><A HREF="#Heading15">Deleting Delphi-Generated Code</A>	</UL>	<LI><A HREF="#Heading16">Creating Component Templates</A>	<LI><A HREF="#Heading17">Using Resource Files</A>	<UL>		<LI><A HREF="#Heading18">Resources in Delphi</A>		<LI><A HREF="#Heading19">Compiling Resource Files</A>		<LI><A HREF="#Heading20">Linking Resource Files to Your Executable</A>		<LI><A HREF="#Heading21">A Sample Program Using Resources</A>	</UL>	<LI><A HREF="#Heading22">Using Packages</A>	<UL>		<LI><A HREF="#Heading23">What's a Package?</A>		<LI><A HREF="#Heading24">Static Linking Versus Dynamic Linking</A>		<LI><A HREF="#Heading25">Using Runtime Packages in Your Applications</A>		<LI><A HREF="#Heading26">Deploying Applications Using Packages</A>	</UL>	<LI><A HREF="#Heading27">Summary</A>	<LI><A HREF="#Heading28">Workshop</A>	<UL>		<LI><A HREF="#Heading29">Q&amp;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>Delphi provides a variety of tools that aid you in creating forms, dialog boxes,and applications. Today you learn about the following:</P><UL>	<LI>The Object Repository	<P>	<LI>The Dialog Wizard	<P>	<LI>The Application Wizard	<P>	<LI>Adding methods and data fields to your code	<P>	<LI>Component templates	<P>	<LI>Using resources in your Delphi applications	<P>	<LI>Packages</UL><P>For starters, I'll spend some time discussing the Object Repository, which iswhere Delphi stores any prebuilt forms, applications, or other objects for you toreuse.</P><P>Following that discussion, you meet the wizards. Wizards provide a series of dialogboxes that guide you step by step through the creation process. You provide the details,and Delphi builds the form or application based on the information you provided.The wizards are a powerful tool for rapid application development. Later in the dayI'll tell you how you can use resources in your Delphi applications. Finally, I'llclose the day by talking about packages in Delphi.</P><P><H2><A NAME="Heading1"></A>Working with the Object Repository</H2><P>The Object Repository is the means by which you can select predefined objectsto use in your applications.</P><P>The Object Repository enables you to do the following:</P><UL>	<LI>Choose a predefined application, form, or dialog box to implement in your application.	<P>	<LI>Add your own forms, dialog boxes, and applications to the Object Repository.	<P>	<LI>Add other objects to your application such as ASCII text files and additional	source code units.<BR>	<BR>		<LI>Manage data modules.	<P>	<LI>Create new components.	<P>	<LI>Create new packages.	<P>	<LI>Create new ActiveX controls or ActiveForms.	<P>	<LI>Invoke wizards to help you build a dialog box or an application.</UL><P>That's just a sampling of what the Object Repository provides. There are otherobjects you can create in addition to those listed here.</P><P><H3><A NAME="Heading2"></A>Object Repository Pages and Options</H3><P>The Object Repository is displayed automatically whenever you choose File | Newfrom the main menu. Figure 8.1 shows the Object Repository window as it initiallyappears when you choose File | New with no project open.</P><BLOCKQUOTE>	<P><HR><strong>NOTE:</strong> Strange as it might seem, the Object Repository is titled New Items,	and the Object Repository configuration dialog box is titled Object Repository. To	say that this is confusing is a bit of an understatement. <HR></BLOCKQUOTE><P><A HREF="javascript:popUp('28670801.gif')"><B>FIGURE 8.1.</B></A><B> </B><I>TheObject Repository window.</I></P><P>The Object Repository has several pages, each of which contains different objectsthat you can incorporate into your applications. As you can see from Figure 8.1,the New tab is what is initially selected when the Object Repository is displayed.Table 8.1 lists the Repository pages and a description of the items you find on eachpage.</P><P><H4>TABLE 8.1. THE OBJECT REPOSITORY PAGES.</H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT"><I>Page/Tab</I></TD>		<TD ALIGN="LEFT"><I>Description</I></TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">New</TD>		<TD ALIGN="LEFT">Enables you to create a new application, form, or unit for use in your application.			Also enables you to create advanced objects such as packages, DLLs, components, NT			service applications, Web server applications, and data modules.</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">ActiveX</TD>		<TD ALIGN="LEFT">Enables you to create new ActiveX controls, type libraries, COM objects, ActiveForms,			and other ActiveX objects.</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Multitier</TD>		<TD ALIGN="LEFT">Enables you to create CORBA and MTS objects and data modules (Client/Server version			only).</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Forms</TD>		<TD ALIGN="LEFT">Enables you to create standard forms from prebuilt forms such as an About box, a			dual list box, tabbed pages, or QuickReports.</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Dialogs</TD>		<TD ALIGN="LEFT">Presents choices of several basic dialog box types from which you can choose. Also			contains the Dialog Wizard.</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Projects</TD>		<TD ALIGN="LEFT">Displays full projects that you can choose from to initially set up an application.			Also contains the Application Wizard.</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Data Modules</TD>		<TD ALIGN="LEFT">Enables you to choose from data modules in your application.</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Business</TD>		<TD ALIGN="LEFT">Includes wizards for database forms, database Web applications, reports, and charts,			and a Decision Cube sample application.</TD>	</TR></TABLE><BLOCKQUOTE>	<P><HR><strong>NOTE:</strong> If you invoke the Object Repository when you already have a project	open, you will see an additional tab in the Object Repository. The tab will have	the name of your project on it. Clicking this tab will display a page that contains	all the objects currently in the project. This enables you to quickly reuse a form	or other object by simply selecting it from the Object Repository. <HR></BLOCKQUOTE><P>Across the bottom of each page you see three radio buttons. These buttons, labeledCopy, Inherit, and Use, determine how the selected object is implemented. Dependingon the object selected, some of the radio buttons (or all) might be disabled. Forexample, all three radio buttons are always grayed out when the New page is displayed.This is because Copy is the only option available for objects on this page, so Delphigrays out all choices and applies the Copy option automatically.</P><BLOCKQUOTE>	<P><HR><strong>NOTE:</strong> The Object Repository is sometimes called the Gallery. <HR></BLOCKQUOTE><P><H3><A NAME="Heading3"></A>The Copy Button</H3><P>When you choose the Copy radio button, Delphi creates a copy of the selected objectand places it in your application. At this point you are free to modify the objectin any way you choose. The original object in the Repository is not altered whenyou make changes to the new object in your application.</P><P>To illustrate, let's say you have an often used form (a form in the traditionalsense, not in the Delphi sense) printed on paper--a work schedule, for example. Let'ssay that you want to fill in that form with scheduling information. You wouldn'tmodify the original form because it would then be unusable for future reuse. Instead,you would put the original form in the copy machine, make a copy, and then returnthe original to some location for safekeeping.</P><P>You would then fill out the copy of the form as needed. Making a copy of an objectin the Repository works in exactly the same way. You are free to modify the copyin any way you choose and the original remains safely tucked away. Making a copyis the safest method of object usage.</P><P><H4>The Inherit Button</H4><P>The Inherit method of usage is similar to Copy, but with one important distinction:The new object is still tied to the base object. If you modify the base object, thenewly created object will be updated to reflect the changes made to the base object.The inverse is not true, however. You can modify the new object without it havingany effect on the base object.</P><P>To illustrate this type of object usage, consider the following scenario: Frequently,information managers create a spreadsheet in a spreadsheet program and use the contentsof that spreadsheet in a word-processing program to present a report.</P><P>They usually opt to link the data to the spreadsheet when pasting from the Clipboardor importing the spreadsheet into the word processor. That way, when changes aremade to the spreadsheet, the word-processing document is automatically updated toreflect the new data. In the same way, changes made to a base form will automaticallybe reflected in all forms inherited from the base form. Use the Inherit option whenyou want to have several forms based on a common form that might change at some point.Any changes in the base form will be reflected in all inherited forms.</P><P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -