Presentations on the delphi programming language. Presentation on the topic "Basics of working in the Delphi environment"


The code editor window (Unit1.pas) creates the source text of the module of the application being developed. Each editable file is on a separate page, which can be accessed by clicking on its tab. The form designer window (Form1) is where the form is designed. Why are the necessary elements placed on the form from the Component Palette? The Object Inspector window displays the object properties and events for the current Form1. It can be displayed using the View/Object Inspector command or by pressing a key. The Object Inspector window has 2 tabs: Properties and Events. Form Designer Window Code Editor Window Object Inspector Window


Dpr Main project file!!.Dfm Shape file!!.Pas Pascal module file!!.Res Resource files!(created on first save).Opt Project parameters file.~* Backup files.Dcr Delphi Component Resource !.Dcu Compiled module file.Dsm Intermediate code.Dll Dynamic library files.Dsk Workspace configuration.Exe Executable files File extensions Required files for the application to run


Example of a simple application Creating a new application begins with Delphi automatically offering an empty window - Form1. The application interface consists of components that you can select from the Component Palette, place them on the form, and change their properties. Selecting a component in the Palette is done by clicking on the desired component, for example, a Button, and then clicking on the form. The selected component will appear on it. After placing the component on the form, Delphi automatically makes changes to the module file, i.e. the line is added: The appearance of the component is determined by its properties, which are available in the Object Inspector window when the component is selected on the form.


The Object Inspector window displays the names of all properties and their values. Properties are attributes that define how components display and function when the application runs. You can change property values ​​directly in the Inspector, and the corresponding component is immediately changed. Let's give our button a different title: write in the line Caption - About Form Some properties of the Button: Cursor:TCursor - mouse image when hovering over the button (for example: crHandPoint) Default:Boolean - the button is pressed using the Enter key, if the value Default=True Font: TFont - font Height:Integer - button height in pixels Width:Integer - button width in pixels Left:Integer - horizontal coordinate of the upper left corner. Top:Integer - vertical coordinate of the upper left corner.


In order for a button to respond to any event, you must specify an event handling procedure that will be called when this event occurs. To do this, double-click in the OnClick event area (or double-click on the About Form button), as a result Delphi automatically creates a handler procedure template in the form module. var About: Tabout; begin About:=TAbout.Create(self); About.Show; end; Now, when you click on the About Form button, another form called About will appear, which we will describe in the Unit2 module. Let's write it in the procedure


Let's describe the second form in Unit2.pas. In the main menu, select the item File / New / Form. Set this form to Caption and Name - About. Place a Button on the form with the title Close and a Label component, which is simple text that is not edited when the program is executed. The text is entered in the Caption field. Some properties of Label AutoSize:Boolean - automatic correction of the Label size, depending on the text of the label. Aligment: TАligment - the method of text alignment inside the component, can take the following values: - taLeftJustify - left alignment - taCenter - text centering - taRightJustify - right alignment edge WordWrap:Boolean - automatic wrapping of words to another line Transparent:Boolean - transparent or filled inscription. The shading color is set by the Color property. Label


When you click the Close button, we will make the About form close. procedure TAbout.Button1Click(Sender: TObject); begin Close; end; Our Unit2 module looks like When you click the About Form button of the first form, the second form is displayed on the screen, which was previously invisible. Because From the Unit1 module the operation with the second form is carried out, then in the implementation section of the Unit1 module we will place the code uses Unit2. Or File/Use Unit…


In order to save the project, in the main menu, select the item File / Save Project As... Saving the project Let's give our project the name Project1 The compilation process is started using the command: Project / Compile Compiling the project to obtain an application can be performed at any stage of project development. This is useful for checking the appearance and correct functioning of individual form components, as well as for checking the generated code. Once the project is compiled, an application executable file is created with the name of the project file. Compilation


Launching a project You can run a project from the Delphi environment and from the Windows environment. From the Delphi environment it is carried out using the Run / Run command or by pressing the key. Note You cannot run a second copy of the application while the application is already running. You can continue developing the project only after the application is completed. When an application loops (freezes), it must be terminated using Delphi using the Run / Program Reset command or by pressing the + keys



Municipal educational institution

Secondary school No. 1

With. Obsharovki

DELPHI. Introduction to the programming system

Development by computer science teacher Vyacheslav Aleksandrovich Maksimov.


Delphi. Main characteristics of the product.

Delphi is a combination of several important technologies:

  • High-performance compiler to machine code
  • Object-oriented component model
  • Visual (and, therefore, high-speed) construction of applications from software prototypes
  • Scalable tools for building databases

Object-oriented model of software components

The main focus of this model is Delphi is done to maximize code reuse. This allows developers to build applications very quickly from pre-prepared objects, and also gives them the ability to create their own objects for the environment Delphi. There are no restrictions on the types of objects that developers can create. Indeed, everything in Delphi is written in the same language, so developers have access to the same objects and tools that were used to create the development environment. As a result, there is no difference between the objects supplied by Borland or third parties and the objects you can create.


Rapid development of a working application from prototypes

The Rendzu game program was assembled from ready-made pieces in a working day, with most of the time devoted to preening and embellishment.


Application development

Screen Saver in the form of a jumping clock was also made at Delphi in a very short time. Now this watch adorns almost every IBM-compatible machine


Who is Delphi for?

First of all Delphi designed for professional developers of corporate information systems

Delphi is intended not only for professional programmers.

Apply Delphi teachers, doctors, university professors, businessmen, all those who use a computer for a purely applied purpose.


Library of visual components

This object library includes standard user interface objects, data management objects, graphics objects, media objects, dialog and file management objects, DDE and OLE management.


Delphi: a customizable development environment

palette component .

Components are grouped on palette pages by their functions. For example, the components that represent Windows "common dialogs" are all located on a palette page called "Dialogs". .

Delphi allows developers to customize the environment for maximum convenience. You can easily change the component palette, toolbar, and also customize syntax highlighting.

Note that in Delphi you can define your group of components and place it on the palette page, and if the need arises, rearrange components or remove unused ones.

From this palette

component

you can choose

components,

from which you can

build applications.

Components include

into ourselves as visual,

and logical components.

After launch Delphi

in the top window

horizontally

icons are located

component palettes.

If the cursor

delayed for

one of the icons,

under her in

yellow rectangle

a hint appears

palette page called “Dialogs”


Smart Editor

Editing programs can be done using recording and executing macros, working with text blocks, customizable key combinations and color highlighting of lines.


Object Inspector

This tool is a separate window where you can set the values ​​of properties and events of objects (Properties & Events) during program design.


Project Manager.

Allows the developer to view all modules in the corresponding project and provides a convenient mechanism for project management. The Project Manager shows file names, time/date of selected forms, etc. You can immediately get to the text or form by simply clicking on the corresponding name.


Object navigator

Shows

library

available objects

Implements

navigation

according to you

application.

You can see

hierarchy

objects,

precompiled

modules in the library,

list of global

names of your code.


Database application development

Delphi allows

use

library of visual

component for fast

creating reliable applications,

which are easily expandable

to applications with architecture

client-server.

In other words, you can create an application

working with a local InterBase server,

and then use the created application,

connecting to a remote SQL server via SQL-Links.


Delphi is primarily a development environment based

on using the component.

So you can add completely new components

to the component palette.

You can create components internally Delphi ,

or introduce components created as controls

VBX or OLE 2.0, or you can use components

written in C or C++ as dll.


Hardware and software requirements

Windows 3.1 and higher

27 Mb of disk space for minimum configuration

50 Mb of disk space for normal configuration

processor 80386, or better 80486


  • . Many developers around the world are already firmly focused on using Delphi as a tool that allows you to create highly efficient client-server applications. Moreover, the list of ready-made, professionally executed applications is so large that it is not possible to list it completely in this presentation. Range developed using Delphi software products are also amazing - from gaming programs to the most powerful banking systems.

  • DELPHI. Subtleties of programming. Vasily Kucherenko.- M: “Educational book plus”, 2000, -192 p.
  • Let's study DELPHI. A. Zhukov. PETER. 2002.

Slide 2

1. Basics of working in the Delphi environment. Topic outline:

1. Stages of software development. 2. The concept of a visual development environment. 3. Basic principles of object-oriented programming (OOP). 4. Screen view in the Delphi environment, the purpose of the main elements of the environment interface, the operating procedure. 5.Components Edit (Editor), Label (Inscription), Button (Button). 6. Basics of the Pascal programming language. 7. Organization of data input/output. An example of creating a simple application.

Slide 3

1. Stages of software development.

Statement of the problem. Construction of a mathematical model. Development of algorithms and work scenarios. Selecting a development environment. User interface design. Writing event handlers (procedures) and functions in program modules. Debugging and testing. Implementation, operation and modification.

Slide 4

2. The concept of a visual development environment.

Delphi is a visual environment for software development. The visual environment allows you to see and design the appearance of the program being created (interface) already at the development stage. The visual environment is built on OOP principles. To write program text in Delphi, the Object Pascal programming language is used.

Slide 5

3. Basic principles of OOP.

The main concept in OOP is an object. Object formula: Object = Data + Programs An object contains data and programs for processing this data. Objects are the building blocks for creating programs.

Slide 6

Each object has a set of properties and methods. A property is some characteristic of an object (color, size, position, etc.). Properties can take values ​​and participate in expressions. A method is the “ability” of an object to perform various operations (paint, enlarge, change, etc.), i.e. subroutines.

Slide 7

Each object has its own name. Form of accessing the properties and methods of an object: Object_name.Name of property_or_method Example of accessing a property: Button1.Color:= Green; An example of calling a method: Button1.Paint(Green);

Slide 8

3. Basic principles of OOP:

1. Encapsulation – the ability to combine data and operations into one. 2. Inheritance – the ability to create new derived classes based on existing ones. 3. Polymorphism – the ability to modify methods in derived classes.

Slide 9

4. Screen view in the Delphi environment, the purpose of the main elements of the environment interface, the operating procedure.

Launch the Delphi environment. Show the main elements of the Delphi environment interface: - Title bar, menu; - Toolbar; - Start window; - Palette of components; - “Object Inspector” window; - Form; - “Text Editor” window; - Other windows and panels may be displayed.

Slide 10

The component palette is a “warehouse” of Delphi components and consists of many sections (pages). A component is an object built into the Delphi environment.

Slide 11

In the Object Inspector window, the Properties page displays the properties of the active (selected) component and can be changed.

Slide 12

The Events page displays a list of events that can occur on the component and the handlers assigned to them. An event handler is a procedure written in Object Pascal.

Slide 13

The form is the basis of the application being created, the main object. Components are installed on it.

Slide 14

Basic properties of the form: Caption – title of the form. Color – color of the form. Width, Height – width, height in pixels. Left, Top – coordinate of the upper left corner. The properties Color, Width, Height, Left, Top are available for almost all visual components.

Slide 15

In the “Text Editor” window, the texts of program modules are displayed and edited:

Slide 16

5. Components Edit (Editor), Label (Inscription), Button (Button).

The Edit component allows you to display and edit (if enabled) a row of data.

Slide 17

Basic properties of the Edit component: Text – contains the displayed data string. Font – properties (parameters) of the line font. ReadOnly – if True, then the line cannot be edited. Name – program identifier (designation) of the component; all components have this property.

programming using one of the most common rapid application development systems - Delphi Using this training course, you can independently master the basics of object-oriented programming in Delphi. To expand your knowledge, a number of tutorials and reference books on Delphi are attached to the course. The series contains 13 presentations: OOP in Delphi – 1: Introduction to the Borland Delphi programming system. Objects (components) and their properties and OOP methods in Delphi – 2: The first program in Delphi, saving and compiling OOP in Delphi – 3: Programmatically changing the properties of OOP objects in Delphi – 4: Conditions in Delphi. Creating a simple OOP test in Delphi - 5: Elements of input and output of information. Exception handling OOP in Delphi – 6: Program screensaver and timer element OOP in Delphi – 7: Programming your toy OOP in Delphi – 8: Program menu, status bar, dialogs OOP in Delphi – 9: Creating your own OOP text editor in Delphi – 10 : Databases in Delphi OOP in Delphi – 11: Calculator in Delphi. Handling exceptional situations OOP in Delphi – 12: Creating an OOP testing system in Delphi – 13: Graphics in Delphi.

Delphi uses the Pascal Object programming language, so it is better to first learn regular Pascal and work in TurboPascal, and then move on to Delphi - it will be very easy to switch, because the syntax of the language remains unchanged. It is advisable to study OOP in Delphi in senior specialized classes - the number of hours allocated to computer science there is quite enough to master the basics of OOP in Delphi

The series of presentations “OOP in Delphi” is dedicated to object-oriented programming with
using one of the most common rapid application development systems - Delphi
Using this training course, you can independently master the basics of object-based
oriented programming in Delphi. To expand your knowledge, attached to the course
a number of tutorials and reference books on Delphi
The series contains 13 presentations:
OOP in Delphi – 1: Introduction to the Borland Delphi programming system. Objects
(components) and their properties and methods
OOP in Delphi – 2: First Delphi program, saving and compiling
OOP in Delphi - 3: Programmatically changing object properties
OOP in Delphi - 4: Conditions in Delphi. Creating a Simple Test
OOP in Delphi – 5: Elements of information input and output. Exception Handling
OOP in Delphi – 6: Program splash screen and timer element
OOP in Delphi – 7: Programming your toy
OOP in Delphi – 8: Program menu, dialogs
OOP in Delphi – 9: Creating your own text editor
OOP in Delphi – 10: Databases in Delphi
OOP in Delphi – 11: Calculator in Delphi. Exception Handling
OOP in Delphi – 12: Creating a testing system
OOP in Delphi – 13: Graphics in Delphi
Delphi uses the Pascal Object programming language, so it is better to first learn regular Pascal and work in Turbo Pascal, and then
and switching to Delphi - it will be very easy to switch, because the syntax of the language remains unchanged.
It is advisable to study OOP in Delphi in senior specialized classes - the number of hours allocated to computer science there is quite
enough to master the basics of OOP in Delphi

Object –
oriented
programming on
DELPHI - 1
@ Krasnopolyansk school No. 1 Domnin Konstantin Mikhailovich 2006

DELPHI - 1
In this lesson:
Getting to know the system
Borland Delphi programming.
Objects (components) and their properties
Questions:
1. Introduction
2. Working window of the program
3. Delphi components
4. Objects and their properties

1. Introduction

Introduction
Delphi is a modern and powerful object-oriented system
rapid application development, allowing you to create the most
simple (educational, game applications) and complex database programs
data and enterprise management
Programming in Delphi is a fun process that you can
compare with assembling mosaics, children's blocks, construction sets, where the role
these cubes will be played by objects (buttons, labels, Edit – s and others
components)
Like in a constructor, we place these elements on our form,
Moreover, each element (object) has its own properties, which
we can manage
In addition, objects have their own methods - they are able to respond to
certain events (pressing a button, key...), in this case there will be
what we wrote in the code for processing this event will be executed
In this lesson we will get acquainted with the Delphi - 7 working window and, some of its common
used components (objects) and their properties

2. Working window
Delphi
Object-oriented programming in DELPHI - 1

Delphi working window
System
drop-down menus and
component panels
This is the window in which we
we'll write code
programs
Object Inspector
(here we will be
change properties and
object behavior)
This is our uniform
which we will be
place objects

Delphi working window

Drop down menu system
containing functions for working with
files, project, settings
programs, etc.
(as in MS OFFICE)

Delphi working window
Let's start with the menu and component panel:
Standard toolbar
allowing the production of frequently used
actions with files, projects, forms

Delphi working window
Let's start with the menu and component panel:
Component panel of our
application containing
grouped tabs
objects
Standard and
most often
used
elements
Additional tab
elements that are now
open, below we see
elements that
this tab contains
Dialogues tab,
which we will too
use
As we work, we will use components from other panels as well.

3. Components
Delphi
Object-oriented programming in DELPHI - 1

Delphi components


1. STANDARDS tab
Frame - frame. On par with
form serves as a container
to accommodate others
components. Unlike
forms can be placed in
component palette, creating
component parts
MainMenu - main menu
programs. Component
capable of creating and
serve complex
hierarchical menus like
for example, in MS Word and others
office programs, which has become
design standard
programs

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
PopupMenu -
auxiliary or local
menu. Usually this is the menu
appears in a separate window
after right click
mice.
Label
- label. This component
used to place in
caption window.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
Edit
- input line.
Intended for input,
display or
editing one
text string.
Memo - multiline
text editor.
Used to enter and/or
display multiline
text.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
Button - command button.
OnClick event handler
this component is usually
used for implementation
some command.
CheckBox - independent
switch. Mouse click
on this component in
running program
changes its logical
property Checked.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
RadioButton
- dependent
switch. Usually
unites at least
with another one like that
component into the group. Click
by switch leads to
automatic
earlier release
selected switch in
same group
ListBox - selection list.
Contains a list of suggested
options (options) and gives
opportunity
check the current
choice. .

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
ComboBox
combo list
choice. Represents
combination of pick list and
text editor
ScrollBar - strip
management. Represents
be vertical or
horizontal stripe,
reminiscent of stripes
scrolling along the sides of the Windows window.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
GroupBox - group
elements. This component
used for grouping
several related
the meaning of the components.
RadioGroup - group
dependent switches.
Contains special
properties for maintenance
several related
dependent switches.

Delphi components
Let's take a closer look at the components on the panel tabs
(naturally, to begin with, only the basic and frequently used ones)
1. STANDARDS tab
Panel - panel. This
component, like GroupBox,
serves to unite
several components.
Contains internal and
outer edge that
allows you to create effects
“depression” and “convexity”.
Actiontist - list of actions.
Serves for centralized
program reactions to actions
user selection related
one of a group of similar
control elements such as
menu options, pictographic
buttons, etc.

Delphi components
1. ADDITIONAL tab

DrawGrid -
BitBtn-
command button with
inscription and
pictogram.
StringGrid - a table of strings. This
the component has powerful
opportunities for presentation
text information in a tabular
form.
free
table. Unlike
StringGrid cells
this component
may contain
arbitrary
information, including
including drawings.

Delphi components
1. ADDITIONAL tab
(Let's consider only some of the components we need)
ColorBox
Image - drawing.
This component
intended for
display
drawings
-
special
ComboBox option
to select one
from system
flowers
Chart - diagram. This
component makes it easy to create
special panels for
graphical representation
data.

Delphi components
Additionally, we will need some components from the tabs
Win32, Dialogs, System, Data Access
In view of the many components, we will limit their consideration here, with
further work with Delphi you will definitely need reference books and
electronic textbooks on Delphi, which are attached to this course

4. Objects and theirs
properties
Object-oriented programming in DELPHI - 1

Objects and their properties
Let's start with the main object of any application - the form.
Let's fire up Delphi and look at the properties
forms in the object inspector
The Object Inspector contains two tabs:
Parameters (here we change the properties
object)
Events (here we define when
upon the occurrence of which event will it be fulfilled?
our code)
Properties and events for objects, in
in particular for the form, a lot. IN
as part of our course we will look at
only simple and widely used

Objects and their properties
1. Align property (form alignment on the screen)
Align -
property,
defining position
forms on the screen. For example,
if we select this property
equal to the value of alClient, then
the form will take up the entire screen
Try setting the Align property
different values ​​and see how
the appearance and position of the form will change to
screen. To do this, click the button
"Run" on the toolbar
(or F9 key)
When considering the following
properties also try changing
values, run project (F9),
to see how it reflects
changing a property on a form (or
another object)

Objects and their properties
2. AlfaBlend property (object transparency)
AlfaBlend – turns on and off the transparency of the form
AlfaBlendValue – allows you to set the degree of transparency
Set the AlfaBlend property to True and the
AlfaBlendValue – value 100, run (F9), and the form
becomes transparent
3. AutoScroll property (automatic
scroll bar appears)
When enabled (true), the form will automatically display
scroll bar if the size of objects exceeds
mold dimensions
4. Property AutoSize(automatic
setting the form size)
When enabled (true), the form dimensions are automatically adjusted to fit
sizes of objects on it

Objects and their properties
5. BorderIcons property (type of icons in the form header)
Setting these properties allows us to enable or disable
buttons for working with the window on our form
For example, if the biMinimize property is set to False, then
our window will not have a button to minimize the window (it will
unavailable)
6. The BorderStyle property determines the appearance
the borders of our window
For example, the value bsSingle makes the border thin, and the value
bsNone makes the form have no border at all (this is often
used when creating screensavers for programs)

Objects and their properties
7. Caption property (defines the title of the program window)
If you enter the word Calculator here, then
it automatically fits into
window title
8. The Color property defines the color
our form
On the right side there is
a set of flowers that
can be opened and selected
necessary.
If you are not satisfied with this
set, make it double
right mouse click
parts of the property and select
the color you want

Objects and their properties
9. Enabled property (object availability)
If the property is false, the object will be unavailable (inactive)
10. Font property (font settings)
Here you can change the size, color and writing of the test on
objects
11. FormStyle property (form style)
Defines the style of the form. For example, if this property
give the value fsStayOnTop, then the form dimensions cannot be
change, clinging to its boundaries
12. Icon property (program window icon)
Defines an icon in the program window,
which you can choose from
available or draw yourself

Objects and their properties
13. VertScrollBar property (defines
presence and type of vertical stripe
scrolling
14. Visible property (determines the visibility
object)
If the property value is true, then the object is visible, and if
false – the object is not visible
14. VindowState property (defines the status of the program window when
its launch)
Depending on the value of this property, the program window can be launched in a maximized position.
Full screen (maximized), minimized (minimized) or normal view
So, we looked at some properties of objects (in particular shapes) and
tried them in action. Similarly for each object (buttons, Edit,
Memo, Timer...) have their own properties that have a lot in common and
some differences

Objects and their properties
Now let’s look at what events form objects can respond to.
To do this, let's place a BUTTON on our form. How
do this?
We look for the STANDARDS tab in the Delphi panel, on it
element BUTTON (Button), click on it, and then
Click on the form and a button appears
Change the Caption property of the button to EXIT
Now let's go to the EVENTS tab
facilities inspector
Main event for many objects, and
especially for a button - this is a mouse click on
him OnClick
Double click on the white area of ​​this
properties and you will see a window with the program code:
close
Insert a close statement between the words begin and end, then
run the program (F9) and press the button - the button works,
those. when the button click event occurs, the
window closing code (close)

Delphi components
In addition to the most applicable click event
button exists and many others, for example event
hovering the mouse over the OnMouseMove object
With these events and their processing we
let's get acquainted with ours in the process of working
course

RESULTS OF THE LESSON:
In this lesson we got acquainted with the system
Borland Delphi programming, Objects (components) and
their properties
IN NEXT LESSON:
OOP in Delphi - 2:
First Delphi program, saving and compiling
You will learn how to save and compile a project,
create your first program, learn to read the source
module code

Domnin Konstantin Mikhailovich
E-mail:
2006