190 likes | 425 Views
Delphi 4. Introduction to IDE Overview of Delphi Programs Visual Programming. Overview of I ntegrated D evelopment E nvironment. Using Delphi from Windows Main window Form Designer Window Object Inspector Window Code Editor Window Project Manager Creating a Delphi project.
E N D
Delphi 4 Introduction to IDE Overview of Delphi Programs Visual Programming
Overview of Integrated Development Environment • Using Delphi from Windows • Main window • Form Designer Window • Object Inspector Window • Code Editor Window • Project Manager • Creating a Delphi project
Main Window • Menu Line • Toolbar • Left: Speed buttons for Menu commands • Right: Component palette • Components which can be chosen to insert into the user interface you are designing. • You insert components into the Form Designer Window (right hand window)
Object Inspector Window:Properties Page Properties: Attributes of component, e.g. • Caption -- text for title bar • Enabled -- mouse and keyboard input • WindowState -- initially displayed maximized, minimized, or normal • Active Control -- which visual component initially has the focus (user can tab or use mouse to change)
Object Inspector: Events Page Event: user input (e.g. user selects the component) • Double click an event -- e.g. OnClick • Write the code to handle that event in the skeleton procedure provided in the Code Editor Window
Saving and Running a Delphi Project • Save each Form unit with an appropriate name (PAS is automatic extension for the code file, DFM for visual resources automatically saved) • Save Project (DPR is automatic extension for the project module) • Compile & Run (DCU files created for units, EXE file created for program)
Programs and Units • Main program. • Units • Interface -- defines data and subprograms available to client units and program • Implementation -- local variables for unit and detailed implementation of subprograms
Object-Oriented programming • Class: a type, which contains data and methods(operations) associated with that data. • Descendent Class: a type which inherits data and methods from its ancestor class. • Object: an instance of a class (variable declared as that type)
Controlled Access to Data and Methods of a Class TClassName = Class public {data and methods available to instances and descendent classes} protected {those available to descendent classes, not to instances} private {those not available to either} end;
Visual Programming • Form design • Object-oriented code generation • Event-driven programming • Components • Secondary Forms • Modal dialog boxes • Modeless dialog boxes
Form Design and Code Generation • You begin with a main form; Delphi generates • main program • skeleton declaration of descendent class for main form • You select and position components; Delphi generates • classes as fields of main form
Event Driven Programming Flow of control is in hands of user -- by mouse and keyboard events. • For a chosen component, you double-click on one of its event handlers. • Delphi generates • a method in the form class in interface • a skeleton method in implementation • You supply code in event handler.
Components: Toolbars Several groups of components are available: • Standard • Additional • two database groups • Dialogs • System
Notable Standard Components • menus • Label • EditBox (single line input) • Memo (multiple line input) • Button • CheckBox (yes/no on each choice) • ListBox (scrollable list -- select one) • ScrollBar
Other Notable Components • Additional • BitButton • SpeedButton • StringGrid • Dialogs • OpenDialog, SaveDialog (for file speed button) • System • Timer (invisible -- triggers timed event)
Component Classes • Windowed -- inherit Microsoft Windows controls, can have focus, e.g. • TForm • TMemo • Non-windowed, e.g. • TLabel • Non-Visual, e.g. • TTimer
Secondary Forms Select File|New Form to generate. (Note: a new unit is generated for each form.) • Modeless dialog boxes • user can click outside the box • Modal dialog boxes • must be closed before user can access other pre-existing windows • include call to dialog box’s ShowModal method in its button click handler
Assignment • Begin exploring Delphi 4, using • on-line documentation • Quick Start • Optional “Teach Yourself Delphi 4 in 21 Days” • Create a project of your choosing to show what you learned this week. • Turn in • source code listing • executable code on disk