delphi - delphi user's guide - delphi for windows

466 1.2K 0
delphi - delphi user's guide - delphi for windows

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Introduction 1 Delphi for Windows Copyright Agreement Introduction Delphi represents a brand new way to develop applications for Windows. It combines the speed and ease of use of a visual development environment with the power, flexibility, and reusability of a fully object-oriented language, the world’s fastest compiler, and leading-edge database technology. As a result, Delphi lets you build sophisticated client/server applications in record time. Delphi includes support for creating stand-alone executable (.EXE) and dynamic-link library (.DLL) files and local or networked database applications, as well as client/ server applications. Installing Delphi Delphi and its installation program are both Windows applications, so you must already have Windows running to install Delphi. The installation program creates directories as needed and copies files from the distribution disk to your hard drive. The installation program is largely self-explanatory. The following steps tell you all you need to know to install Delphi. ■ To install Delphi, 1 Start Windows if it is not already running on your computer. 2 Insert the Delphi CD into your CD-ROM drive. 3 Use Program Manager’s File|Run menu command or File Manager to run \INSTALL\SETUP.EXE from the Delphi CD. 4 Follow the instructions presented by the installation program. When the installation program finishes its work, it offers you the option of reading the README.TXT file, which contains important last-minute information about Delphi. It’s a good idea to read README.TXT before running Delphi for the first time. Delphi User’s Guide 2 Delphi User’s Guide Documentation overview Delphi includes complete documentation to help you learn to use the product quickly and effectively. The Delphi documentation consists of three parts: • Printed manuals • Online Help • Interactive Tutors Using this manual • Part I, “Getting started with Delphi,” introduces you to the kinds of tasks you’ll perform when designing and testing applications in Delphi. • Part II, “Fundamental skills,” presents concepts and techniques you’ll use in developing robust and sophisticated Delphi applications. These skills are discussed in the context of creating simple but functional examples. • Part III, “Programming topics,” discusses the language you’ll use to write your applications, how to work with objects, and how to write robust applications by handling exceptions. • Part IV, “Sample applications,” presents several complete sample applications, demonstrating most of the tasks you’ll perform when writing your own applications. Reference material on Delphi and its component library appear in online Help. The Delphi Component Writer’s Guide and Database Application Developer’s Guide are also printed separately. They contain information on how to create your own components for use in Delphi, and how to create database applications, respectively. Using Help Delphi’s online Help provides a superset of the information presented in the printed manuals. Use online Help to find • Specific procedural information regarding programming tasks in Delphi • The language definition of Object Pascal • Reference material for the Visual Component Library and the Run-Time Library Using Interactive Tutors Delphi provides seven Interactive Tutors to help you get up and running quickly: • A “quick tour” overview of the Delphi programming environment • A short lesson on how to create a simple application • A lesson on how to add components to a form • A lesson on setting component properties • A lesson on creating and modifying event handlers Introduction 3 • A lesson on creating a simple database application • A lesson on creating a more sophisticated database application Manual conventions The printed manuals for Delphi use the typefaces and symbols described in Table Intro.1 to indicate special text. Contacting Borland The Borland Assist program offers a range of technical support plans to fit the different needs of individuals, consultants, large corporations, and developers. To receive help with this product send in the registration card and select the Borland Assist plan that best suits your needs. North American customers can register by phone 24 hours a day by calling 1-800-845-0147. For additional details on these and other Borland services, see the Borland Assist Support and Services Guide included with this product. Table Intro.1 Typefaces and symbols in these manuals Typeface or symbol Meaning Monospace type Monospaced text represents text as it appears onscreen or in Object Pascal code. It also represents anything you must type. [ ] Square brackets in text or syntax listings enclose optional items. Text of this sort should not be typed verbatim. Boldface Boldfaced words in text or code listings represent Object Pascal reserved words or compiler options. Italics Italicized words in text represent Object Pascal identifiers, such as variable or type names. Italics are also used to emphasize certain words, such as new terms. Keycaps This typeface indicates a key on your keyboard. For example, “Press Esc to exit a menu.” ■ This symbol indicates the beginning of a procedure. The text that follows describes a set of general steps for performing a specified kind of task. ➤ This symbol indicates a specific action you should take, such as a step in an example. 4 Delphi User’s Guide Part I, Getting started with Delphi 5 Part I Part I Getting started with Delphi The single chapter making up this part, “Introducing Delphi,” introduces the Delphi integrated development environment (IDE), and discusses basic concepts and techniques for creating Delphi applications. 6 Delphi User’s Guide Chapter 1, Introducing Delphi 7 Chapter 1 Chapter 1 Introducing Delphi Delphi is a component-based application development environment supporting rapid development of highly efficient Microsoft Windows-based applications with a minimum of coding. Many of the traditional requirements of programming for Windows are handled for you within the Delphi class library, shielding you from complicated, or merely repetitive programming tasks. Delphi provides design tools such as application and form templates, so you can quickly create and test your application prototype. Then, by using Delphi’s rich component set and intuitive code generation, you can turn your prototypes into robust applications that fit your business needs. Delphi’s database tools enable you to develop powerful desktop database and client/ server applications and reports. You can view “live” data at design time, so you know immediately whether your query results are what you want. This chapter introduces the following topics: • The Delphi programming environment • Elements of the Delphi interface • The Delphi development model • Overview of Delphi projects • Setting environment preferences The Delphi programming environment This section briefly describes the elements of the Delphi programming environment. You can also learn about Delphi by • Running the “A Quick Look at Delphi” Computer-based Training (choose Help| Interactive Tutors from the Delphi menu bar) • Viewing Help topics (choose Contents, or Topic Search from the Help menu) 8 Delphi User’s Guide • Choosing context-sensitive help ( F1 ) for a particular part of the interface. Starting Delphi You can start Delphi the same way you start any Windows-based application: • Double-click the Program Item for DELPHI.EXE that was created by the Install program. • Use File Manager to locate and double-click the DELPHI.EXE file (if you performed a default installation, this file is located in your DELPHI\BIN directory). • Choose Run from the Program Manager File menu, and specify the path to DELPHI.EXE. • Start Delphi from the command line: WIN DELPHI (assuming Windows is in your path statement). Figure 1.1 The Delphi programming environment Elements of the Delphi interface The elements of the Delphi programming environment were designed to provide you with the tools you need to quickly and intuitively develop high-performance Component palette (Standard page shown; additional component pages available by selecting page tabs) SpeedBar Object Inspector Object selector Form Properties page tab Events page tab Code Editor Chapter 1, Introducing Delphi 9 applications. This section briefly describes each element. For more information, choose Programming Environment from the contents screen of online Help. Elements visible upon starting Delphi While many elements are visible as soon as you start Delphi, some others are not visible until needed, or until you activate them through menu commands or other actions. This section describes those interface elements that you can see right away when you start Delphi. Form Forms are the focal point of nearly every application you develop in Delphi. You use the form like a canvas, placing and arranging components on it to design the parts of your user interface. Components are the building blocks of Delphi applications. They appear on the Component palette, displayed in the top right-hand part of the screen (see Figure 1.1). You can think of a form as a component that can contain other components. Your application’s main form and its components interact with other forms and their components to create your application interface. The main form is your application’s main interface; other forms can include dialog boxes, data entry screens, and so on. You can resize the form and move it anywhere on your screen. A form includes standard features such as • Control menu • Minimize and maximize buttons • Title bar • Resizeable borders You can change these features, as well as other properties of the form by using the Object Inspector to edit the form during design time—the time during which you are designing, rather than running, your form. Properties define a component’s appearance and behavior. Form tools Forms created in Delphi can be reused among Delphi projects, and can also be saved as dynamic-link libraries (DLLs) so you can load them into projects built with other applications such as C++, Paradox, dBASE, Visual Basic, and PowerBuilder. Delphi provides several development tools that make generating productive forms and reports easier than ever: 10 Delphi User’s Guide • Project Templates provide a selection of several application designs that you can use as a starting point when building your own applications. You can save your own projects as Project Templates. • Form Templates enable you to choose from an array of predesigned forms when developing your user interface. You can save your own forms as Form Templates. • Project Experts develop projects for you based on your specified preferences, according to general project categories. • Form Experts develop custom forms for you based on your specified preferences. For example, the Database Form Expert generates a form that displays data from an external database (for more information, see the book Building Database Applications with Delphi). For more information about creating forms, see Chapter 3; for more information about working with projects, see Chapter 4. Component palette Components are the elements you use to build your Delphi applications. They include all the visible parts of an application, such as dialog boxes and buttons, as well as those that aren’t visible while the application is running, such as system timers or Dynamic Data Exchange (DDE) servers. Delphi components are grouped functionally on the different pages of the Component palette. For example, components that represent the Windows common dialog boxes are grouped on the Dialogs page of the palette. You can create your own custom components and install them onto the Component palette, making the Delphi environment fully extensible. There is no difference in usability between the components you create yourself and those that ship with Delphi. You can also install Visual Basic (VBX) controls and third-party components. And the Component palette itself is configurable and scrollable, so you can select how you want components to be displayed in the palette. The specific components provided with Delphi are discussed in Chapter 2 and in online Help under the search word “Component Palette.” For information about how to configure the palette, see Chapter 2. Components (Standard-page components shown; additional components available by clicking the page tabs) Placeholders for additional components Right scroll arrow Page tabsPointer Left scroll arrow [...]... window Bitmap-editing window The Delphi Image editor is a design tool that you can use to create and edit bitmaps, icons, and cursors for display in your application You can use any Windowscompatible bitmap, icon, or cursor—those in the Image Library shipped with Delphi, those you create in the Image editor, or third-party images you import for use in Delphi Note s For more information about the Delphi Image... of the form As you add components and event handlers to the form, the form’s type declaration expands to include the declarations for each component and method For an illustration of this, try the following: 1 Arrange Form1 and Unit1 on your screen so that both are visible (resize the form if necessary) 26 Delphi User’s Guide 2 Scroll in the Code Editor window until the type declaration for Form1 is... Inspector to generate an event handler for the form, or any component you have on the form When you do so, Delphi generates and maintains parts of the code for you For example, the following code is the initial “framework” event handler that Delphi generates for the OnClick event of Button1 (the event that occurs when the button is clicked) on Form1: procedure TForm1.Button1Click(Sender: TObject); begin... Tools|Image Editor The Delphi development model This section describes the fundamental steps involved in developing your own custom projects with Delphi It’s also easy to quickly build prototypes by using Delphi templates and database design tools For more information on using Delphi templates and other rapid form design tools, see Chapter 3 of this book For more information on developing forms to access... unit (.PAS) file and one associated form (.DFM) file The PAS file contains the Object Pascal source code for the form, and the DFM file contains binary code that stores the “image” of the form Together these two files make up the form For every additional form in a project, there will be a PAS and DFM file The project (.DPR) file For each application you develop in Delphi, there is one project (.DPR)... edit the form file as text by directly opening it in the Code Editor The type declaration in the DFM file Just as Delphi generates an instance variable for the form, it also generates an instance variable, or field, for every component you add to the form In this case, though, the form contains the component, so the component declaration appears inside the form’s type declaration The same is true for methods... introduces you to the “core” files in a Delphi project It discusses the following topics: • • • • The project (.DPR) file The unit (.PAS) file The form (.DFM) file Source code for units without forms When you first start Delphi, a blank project named Project1 opens Figure 1.5 A default Delphi project Form Unit source code page tab (Code Editor is behind the form) A blank Delphi project initially contains... new project 14 Delphi User’s Guide For the full-fledged applications you’ll write once you’re more familiar with Delphi, you’ll perform the additional step of debugging your code Debugging code is discussed in Chapter 8 Designing a form Designing forms is as simple as arranging objects in a window If you’re familiar with a graphical user interface (GUI) environment such as Windows, then you already know... clause Form identifiers Compiler directive As you add new forms or units to your project, Delphi automatically adds the appropriate code to the DPR file Chapter 1, Introducing Delphi 23 The uses clause in the DPR file To illustrate how Delphi maintains the project file, you can view the code Delphi generates when you add a new form to the project ® Try the following: 1 View the project file for Project1... Choose File|New Form, and accept the Blank Form option 3 View the DPR file again by clicking the Project1 page tab in the Code Editor Here’s what you should see: Figure 1.7 Modified project file source code New form identifier New unit file name New unit identifier Delphi added the identifier for the new unit, Unit2, its file name, UNIT2.PAS, and the identifier for its associated form, Form2 The unit . important last-minute information about Delphi. It’s a good idea to read README.TXT before running Delphi for the first time. Delphi User’s Guide 2 Delphi User’s Guide Documentation overview Delphi. concepts and techniques for creating Delphi applications. 6 Delphi User’s Guide Chapter 1, Introducing Delphi 7 Chapter 1 Chapter 1 Introducing Delphi Delphi is a component-based application development. Help menu) 8 Delphi User’s Guide • Choosing context-sensitive help ( F1 ) for a particular part of the interface. Starting Delphi You can start Delphi the same way you start any Windows- based application: •

Ngày đăng: 16/04/2014, 11:14

Từ khóa liên quan

Mục lục

  • MAIN MENU

  • READER TIPS

  • TABLES

    • INTRO.1 Typefaces and symbols in these manuals

    • 2.1 Components on the Standard page

    • 2.2 Components on the Additional page

    • 2.3 Controls on the Data Access page

    • 2.4 Components on the Data Controls page

    • 2.5 Components on the Dialogs page

    • 2.6 Components on the System page

    • 2.7 Components on the VBX page

    • 2.8 Components on the Samples page

    • 2.9 AboutBox component properties

    • 3.1 MessageDlg parameters

    • 3.2 Alternate form settings

    • 3.3 Delphi's predefined bitmap button types

    • 3.4 Property settings for demonstrating ActiveControl

    • 3.5 FormStyle property settings

    • 3.6 Sample captions and their derived names

    • 3.7 Menu Designer SpeedMenu commands

    • 4.1 Design-time project files

Tài liệu cùng người dùng

Tài liệu liên quan