Delphi 7 Integrated Development Environment. Delphi Programming Environment

1. Introduction to the Delphi programming environment

1.1 Structure of the programming environment

Delphi– a system for rapid application development for the Windows operating system. Concept Delphi was implemented at the end of 1994, when the first version of the development environment was released. This software product is based on the concepts of object-oriented programming and a visual approach to building an application interface. Currently, the seventh version of the environment has been released. From version to version, developers improve the application development tools.

Delphi it is a combination of several important technologies:

o High-performance compiler to machine code

o Object-oriented component model

o Visual construction of applications from software prototypes

o Scalable tools for building databases

A Windows application is a special type of program that:

Ø Has a special executable file format (*.exe)

Ø Works only with Windows

Ø Usually works in a rectangular window on the screen

Ø Can run simultaneously with other Windows programs, including other instances of the same application

Ø DIV_ADBLOCK441">


The main components of Delphi are listed below:

1. Main window

2. Form Designer

3. Editor Window

4. Component Palette

5. Object Inspector

6. Directory (On-line help)

There are, of course, other important components of Delphi, such as the toolbar, the system menu and many others that are needed to fine-tune the program and programming environment. Let's consider the functions of each component.

Main window manages the application development process. It manages the files included in the application and does all the work involved in maintaining, compiling, and debugging them. The main window has

§ Main menu(MenuBar), located directly below the title bar of the main window and allows you to access all the functions of the development environment.

§ Toolbar(SpeedBar) provides quick access to most main menu commands. Located under the main menu.

§ Component Palette(Component Palette) provides access to visual components that can be placed on the form.

Delphi programmers spend most of their time switching between the Form Designer and the Source Editor Window (called the Editor for short).

Form Designer Delphi is so intuitive and easy to use that creating a visual interface becomes child's play. The form window represents a project of the Windows window of the future program. At first this window is empty. More precisely, it contains standard Windows interface elements - buttons for calling the system menu, maximizing, minimizing and closing the window, a title bar and an outlining frame. The entire working area of ​​the window is usually filled with coordinate grid points, which serve to organize the components placed on the form (you can remove these points by calling the corresponding settings window using the Tools | Environment options menu and unchecking the Display Grid switch on the window associated with the Preferences tab) . A significant part of the time the programmer is busy with an exciting activity that is reminiscent of working with a set of Lego construction parts: he “takes out” the required component from the component palette, like from a box of parts, and places it on the “typing field” of the form window, gradually filling the form with interface elements. Actually, it is in this process of filling out the form that the main highlight of visual programming lies. The programmer controls the contents of the window of the created program at any time and can make the necessary changes to it. Despite all the importance Form Designer, the place where programmers spend most of their time is Editor. Logic is the driving force of the program and Editor – the place where you “encode” it.

Component Palette - This is Delphi's greatest asset. It occupies the right side of the main window and has bookmarks that allow you to quickly find the required component. A component is understood as a certain functional element containing certain properties and placed by the programmer in the form window. With the help of components, the framework of the program is created, in any case, its external manifestations visible on the screen: windows, buttons, selection lists, etc. Palette Component allows you to select the desired objects to place them on the Form Designer. For use Palettes Component just click on one of the objects for the first time and then click on it a second time Form Designer. The object you select will appear on the projected window and can be manipulated with the mouse. Palette Component uses page-by-page grouping of objects. At the bottom Palettes there is a set of bookmarks - Standard, Additional, Dialogs, etc. If you click on one of the bookmarks, you can go to the next page Palettes Component. The principle of pagination is widely used in the Delphi programming environment and you can easily use it in your program.

On the left of Form Designer You can see Object Inspector. Any component placed on a form is characterized by a certain set of parameters: position, size, color, etc. Some of these parameters, for example, the position and dimensions of the component, can be changed by the programmer by manipulating the component in the form window. To change other parameters, use the Object Inspector window. This window contains two pages – Properties and Events. The properties page is used to set the necessary properties of the component, the Events page allows you to determine the component's reaction to a particular event. The set of properties displays the visible side of the component: position relative to the upper left corner of the form's working area, its size and color, font and text of the inscription on it, etc.; a set of events - its behavioral side: will the component respond to a mouse click or key press, how will it behave when it appears on the screen or when the window is resized, etc. Each page of the Object Inspector window is a two-column table, the left column contains the name of the property or event, and the right column contains the specific value of the property or the name of the subroutine [If you are not already familiar with this term, consider that a subroutine is simply a relatively small fragment of a program.] that processes the corresponding event. At the top of the Object Inspector window there is a drop-down list of all components placed on the form. Because the form itself is a component, its name is also included in this list.


Events page linked to Editor; if you double-click on the right side of any item, the code corresponding to this event will automatically be written to Editor, myself Editor will immediately receive focus, and you will immediately be able to add code to handle this event. The code window is intended for creating and editing program text. This text is compiled according to special rules and describes the algorithm of the program. A set of rules for writing text is called a programming language. The Delphi system uses the Object Pascal programming language, which is an expanded and improved version of the widely used Pascal language, first proposed by the Swiss scientist N. Wirth back in 1970 and improved by employees of the Borland Corporation (the languages ​​they created were called Turbo Pascal, Borland Pascal and Object Pascal). Initially, the code window contains minimal source code to ensure that the empty form functions properly as a full-fledged Windows window. While working on a project, the programmer makes the necessary additions to it to give the program the desired functionality. Since to create even simple programs you will need to create and modify (edit) program code, the following describes the basic techniques for working with the code window. Immediately after opening a new project, it will contain the minimum necessary lines of code to describe the form.

The last important part of the Delphi framework is Directory (on-line help). To access this tool, simply select Help and then Contents from the system menu. The screen will appear Directory. Directory is context-sensitive; When you press the F1 key, you will receive a hint corresponding to the current situation. For example, while in the Object Inspector, select a property and press F1 - you will receive help about the purpose of this property. If at any time while working in the Delphi environment there is ambiguity or difficulty, press F1 and the necessary information will appear on the screen.

1.2 Delphi project

The main program that uses modules written by the programmer is called project. A project may include forms, modules, project parameter settings, resources, graphical information, etc. All this information is stored in various files that are used in the main program, i.e., in the project.

Any project has at least six files associated with it. Three of them relate to project management from the environment and cannot be changed directly by the programmer. Below is a list of files that are required to be contained in the project.

· The main project file is initially called PROJECT1.DPR.

· The first program module (unit), which automatically appears at the beginning of work. The file is called UNIT1.PAS by default, but it can be called any other name, such as MAIN. P.A.S.

· The main form file, which is named UNIT1.DFM by default, is used to store information about the appearance of the main form.

· The PROJECT1.RES file contains an icon for the project and is created automatically.

· The file, which is called PROJECT1.DFO by default, is a text file for saving the settings associated with this project. For example, compiler directives set by the developer are stored here.

· The PROJECT1.CFG file contains information about the state of the workspace.

Of course, if you save the project under a different name, the name and files with the RES, DFO and CFG extensions will change. In addition, backup files (that is, files with extensions *.~df, *.~dp, *.~pa) are saved in the project. Since a project contains many files, it is recommended to create a separate directory for each project. All manipulations with files (saving, renaming, editing, etc.) are recommended to be performed only in the development environment.

After compiling the program, files with the extensions are obtained: DCU - compiled modules EXE - executable file

1.3 Environment main menu

Menu item “File”

New prompts you to select the type of new application

NewApplication starts a new project for a window application

New Form creates a new form and a module associated with it

Open Opens any module or just a text file if necessary. If the module describes a form, then this form will also appear on the screen.

Open Project opens an existing project.

Reopen opens a previously opened project

Save saves only the file being edited, but not the entire project.

Save As saves the edited file under a different name.

Save ProjectAs saves the project

Close deletes the current file from the Editor window.

Close All closes all project files

Figure 2

Menu item “Edit”

“Edit” contains commands Undo And Redo, which can be very useful when working in the editor to eliminate the consequences of incorrect actions, for example, if a desired piece of text is accidentally deleted.

Teams Cut, Copy, Paste and Delete- like all other Windows applications, but they can be applied not only to text, but also to visual components. Bring To Front, Send To Back, AlignAndSize are used to align and control the appearance of components on a form.

Menu item " View

Project manager allows you to see the contents of the project.

Object Inspector shows the Object Inspector window.

Paragraph menu "Project"

Add to Project allows you to add a form to a project.

Remove from Project removes the form from the project.

View Source shows the contents of the project file.

Syntax Check only checks the correctness of the program code, but does not update DCU files.

Menu item “Run”

RunF9 compiles and runs the application for execution

Program Reset removes the application from execution.

1.4 First Delphi application

Let's consider the process of building a simple application that works as follows. When you press the button, the message “Hello, world!” appears.

Procedure:

1. Launch Delphi. (Start/Programs/Borland Delphi 5 ) This automatically opens a new project for a windowed application with one main form and a module corresponding to this form.

2. Select the tab in the Component Palette Standard. and transfer components from the Component Palette to the form and TButton. To do this, move the mouse cursor over the components one by one, reading the prompts, until the TButton. Select it by clicking the left mouse button, and then move the pointer to the form and click on the mouse button again. The component placed on the form will have the name Button1 . In this case, the module text will look like

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

TForm1 = class(TForm)

Button1: TButton;

(Private declarations)

(Public declarations)

3. In order for any actions to occur when the button is clicked, you need to write an event handler Button1 Click. To do this, select on the form Button1 and double click on it. You will find yourself in the editing window.

4. Change the button click event handler to the following form:

procedure TForm1.Button1Click(Sender: TObject);

ShowMessage(‘Hello, world!");

end;

5. Save the Application by selecting the item in the main menu File -> Save All . The name of the project and the name of the software module must not be the same! It is recommended to create a separate directory for project files.

6. Launch your Application. To do this, select the item in the main menu Run-> Run , or press the key F 9 .

Unit1.pas"(Form1);

Application. Initialize;

Application. CreateForm(TForm1, Form1);

Each project has an associated global Application object, which encapsulates the properties and methods of a Windows application. In the project file, which the environment generates automatically, the methods of this object are called: initialization, form creation, application operation.

1.5 Security questions

1. Name the main components of the DELPHI environment and their purpose.

2. Name the composition and purpose of the system main menu items.

3. What is the purpose of a Site Inspector?

4. What are the main files that make up an application project?

5. How are components placed, moved, and resized on the form?

6. How to run an application from the DELPHI environment?

2. Visual Component Library (VCL)

2.1 VCL base class hierarchy

The visual component library includes many classes that you can use when developing applications. VCL is closely connected with the development environment (all visual components are located on the Component Palette) and allows you to quickly create an application interface. The many classes included in the visual component library are organized in a hierarchy. At the topmost level of the hierarchy is the TObject class, which is the ancestor of any class. From it, each class inherits mechanisms for creating and destroying a class instance. All classes of the visual component library are derived from a group of base classes that form the basis of the hierarchy.

The TComponent class is the most important class because it is the ancestor of visual components. It is endowed with the interaction of the component with the development environment, with the Component Palette and the Object Inspector. Thanks to these features, components begin to work already during the development of the application interface. Visual components can be divided into two groups: visible and invisible. Visible components are visible not only during interface design, but also while the application is running. Invisible components are not visible during program operation; they interact with resources or with other components. Invisible visual components can be generated directly from the TComponent class.

The TControl class is the direct ancestor of visible visual components and has corresponding properties and methods that control the appearance of the components. Visible components that have input focus, that is, have the ability to receive and process Windows messages (for example, from the keyboard), are derived from the TWinControl class.

2.2 Types of component properties. Changing Properties

Each component has its own set of characteristics or properties. For the user (programmer), a property looks like a simple field of some structure containing some value. However, unlike a “just” field, any change in the value of some property of a component immediately leads to a change in the visual representation of this component, since the property encapsulates the methods (actions) associated with reading and writing this field (which, in turn, include includes the necessary redrawing). Each component that is placed on the form has its reflection in the Object Inspector window. The Object Inspector has two “pages” - “Properties” and “Events” - where you can change the characteristics of a component.

There are several types of properties, depending on their “nature,” i.e., internal structure.

o Simple properties are those whose values ​​are numbers or strings. For example, the Left and Top properties accept integer values ​​that specify the position of the top left corner of a component or form. The Caption and Name properties are strings and define the title and name of the component or form.

o Enumerable properties are those that can take values ​​from a predefined set (list). The simplest example is a type property Boolean, which can take values True or False.

o Nested properties are those that support nested values ​​(or objects). The Object Inspector displays a “+” sign to the left of the name of such properties. Some properties, for example Font, have the ability to open a dialog box to change their values. To do this, just click the small button with three dots on the right side of the line of the Object Inspector showing this property.

Delphi allows you to easily manipulate component properties in both design time and run time. In design mode, properties are manipulated using the Forms Designer or the “Properties” page of the Object Inspector. For example, in order to change the Height and Width properties of a button, just “hook” the mouse on any corner of it and move it to the desired view. The same result can be achieved by simply inserting new values ​​for the Height and Width properties in the Object Inspector window.

On the other hand, in runtime mode, the user (programmer) has the opportunity not only to manipulate all the properties displayed in the Object Inspector, but also to manage a more extensive list of them, including properties of other classes that are not visual components and, therefore, not are displayed in the Object Inspector.

All changes to component property values ​​at runtime must be made by directly writing lines of code in Pascal. It is not possible to use the Object Inspector in runtime mode. However, it is quite easy to access component properties programmatically. All you need to do to change any property is write a simple line of code similar to the following:

MyComponent. Width:= 35;

The above line sets the component's Width to 35. If the component's Width property was not already 35 when this line of code was executed, you can see the component visually change its width.

So there is nothing magical about the Object Inspector. The Object Inspector is simply a convenient way to do in design mode what can be done programmatically in runtime. Moreover, as mentioned above, a component may have properties that are not displayed in the Object Inspector window.

The object-oriented language Pascal, which underlies Delphi, has as its base the principle of matching visual components with the things they represent. The Delphi developers set a goal that, for example, the representation of a Button component encapsulating some code would match the visual appearance of the button on the screen and be as close as possible to an actual button found on the keyboard. And it was from this principle that the concept of property was born.

If you change the Width and Height properties of a Button component, the button will change its width and height accordingly. In this case, after changing the Width property, there is no need to tell the object to redraw itself, although in normal programming this is exactly what should happen.

2.3 Some general properties of components

Let's look at some of the properties that each visual component has, as these properties are inherited from the base classes of the visual component library hierarchy. The TComponent class is the ancestor of all visual components and components receive the following properties from it.

Table 1 Properties of the TComponent class

Property

Purpose

component id

a four-byte integer property that the programmer can use at his discretion

All visible visual components are derived from the TControl class and inherit properties related to the location and appearance of the component. These properties can be divided into several groups.

Table 2 Component Size and Location

Property

Purpose

vertical location of the top left corner of the component

horizontal location of the top left corner of the component

component height

component width

Table 3 Alignment and scaling

Property

Purpose

aligning a component relative to the boundaries of its parent component

Alignment

aligning the label on the component

snapping a component to the sides of its parent component

Constraints

complex property that defines the maximum and minimum allowable dimensions of a component

AutoSize

a Boolean property that allows or disables automatic resizing of a component to match the size of its contents

Table 4 Appearance

Property

Purpose

component color

cursor view when hovering the mouse over a component

inscription on the component

complex property that determines the font type of the label

a boolean property that determines the visibility of a component

PopupMenu

Boolean property that allows or disables the use of a pop-up menu

a Boolean property that specifies the availability of a component

tooltip text that appears when the mouse cursor hovers on a component

ShowHint

a Boolean property that allows or disables the use of a tooltip

2.4 Events in Delphi

One of the key goals of a visual programming environment is to hide the complexity of Windows programming from the user. At the same time, however, I would like such an environment not to be simplified to such an extent that programmers lose access to the operating system itself.

Event-driven programming is an integral feature of Windows. Delphi provides full access to the substructure of events occurring in the Windows operating environment. On the other hand, Delphi makes it easier to program handlers for such events.

Objects from the Delphi visual component library (VCL), as well as objects in the real world, have their own set of properties and their own behavior - a set of responses to events that happen to them. The list of events for a given object to which it reacts can be viewed, for example, in the Object Inspector on the events page. (In fact, this page provides a list of properties that are references to event handler procedures.) Among the set of events for various objects from the VCL are events ported from Windows (for example, events that are generated by the mouse or keyboard) , and events generated as a result of running the application by changing the properties of objects).

The behavior of an object is determined by what handlers it has and for what events. Creating an application in Delphi consists of setting the properties of the objects used and creating event handlers.

Visual programming environmentDelphi. The Delphi programming environment consists of many visual and non-visual standard components that can significantly speed up the program development process. We will consider one of the most popular versions of Delphi 7. The working window of the program consists of five auxiliary windows (Fig. 3.1): the main window (1), the module list window (2), the program code window (3), the project form window (4 ), object inspector (5), object list window (6).

Rice. 3.1. Delphi7 working window.

Main window consists of a menu bar, a toolbar and a component palette. The component palette consists of 14 pages (Standard, Additional, Win32, System, etc.). To move a component onto a form, you must first click on the component and then on the form.

Module list window contains a list of all modules connected to the program.

IN program code window programs are directly written in the Object Pascal language. By default, the code window contains the text of an empty program that meets all the requirements of a Delphi program.

Window forms – this is the Windows window of the created program: menu, window sizes, headers, frames and any standard components. When running the created program, the user sees only the form.

Object Inspector contains two pages: Properties and Events. The properties page displays all the characteristics of the selected object. The events page displays all possible actions with the object.

Object list window contains a list of all components placed on the form.

Program structure in the environmentDelphi. A program in any programming language has a standard structure:<заголовок программы> <тело программы>. The program header in the Delphi environment contains the name of the main program module and the definition area of ​​all standard and non-standard program modules that are used by the environment to organize program execution. Let's look at the program template sections in the environment.

The title always begins with the word unit. Standard program name Unit1. To change the program name, simply save the program under the new name.

Chapter interface begins by listing the standard modules in the uses clause. For example, the SysUtils module is designed to use all standard functions in the language. The Delphi environment automatically inserts a list of required modules into the template of the program being developed. But there are modules that the user needs to enter manually. Further in the section interface under the heading type All data types created in the program are declared. Here under the heading private variables that are available only in this module are declared, and under the heading public– available in all program modules. A template of an empty program in the Delphi environment is presented in Figure 3.2.

Rice. 3.2. Blank Program Template in Delphi7

The declaration of types ends when the title of the next section appears in the program. In the example above, this is the var keyword. In this section, all variables will be declared according to the data types defined in the program. In the above template there is only one variable, Form1, which is an object of the declared class TForm1. From the line unit to the word implementation is the program title. After this word there are descriptions of all actions in the program. The first mandatory action is the $R directive, which ensures the combination of the form module and the program module into one project - the program. The end of the text of a program module is determined by the word end with a dot.

The Delphi environment creates a program from several files that configure the project for the environment, set compiler options, and other files. The largest file in size is a file with the exe extension, which is a ready-made program. Working files are files with the dpr and pas extensions. The file with the cfg extension provides configuration of project options. A file with the dof extension provides settings for compiler options. A file with the res extension is defined as a resource file. It also contains a standard project icon that the developer can replace. A file with the dcu extension is a translated module file. If there are several modules, they will be combined into a single project. The file with the dfm extension contains the characteristics of all standard form components.

Data types inDelphi 7 . When developing a program, each data option must be assigned to a specific data type. Each type has its own specific set of operations. You can work with data of a certain type only by creating variables of this type. The data type determines the format of values ​​that a variable of that type can accept. Data types are usually divided into simple, structured, dynamic, string and procedural. Simple types include real, date-time, integer, logical, character, and enumerable types. Structured types include arrays, records, sets, files, classes.

To write integers, the same data types are used (plus some of their own are added) as in Turbo Pascal 7.0, but only with different ranges of values ​​(Table 3.29).

Integer data type

Range of values

Size in bytes

2147483648…2147483647

Corresponds to integer type

2 63 …2 63 – 1

Corresponds to cardinal type

Table 3.29. Integer data types in Delphi7.

Often when creating programs it is necessary to convert a number to a string or vice versa. There are functions for this: StrToInt(s) and IntToStr(x), the first of which translates the string s to the number, the second is the number X per line.

Real (real) numbers are characterized by the presence of a decimal point in the notation of the number. The recording of such numbers is ensured with a certain accuracy, which determines the number of digits in the exponential notation of the number. Delphi 7 uses 6 real types (Table 3.30).

Real

data type

Maximum value

Number of digits

Size in bytes

9223337203685477.5807

Table 3.30. Real data types in Delphi7.

The highest performance is provided for the real type. To convert a real number to a string and vice versa, there are functions StrToFloat(s) and FloatToStr(x).

Boolean data type is the same as in Turbo Pascal 7.0. contains two variables: true and false. The use of logical variables can significantly improve the algorithm for solving problems by controlling some special options for solving the problem.

The string (string) and character (char) data types in Delphi 7 are similar to the same types in Turbo Pascal 7.0. There are 3 more string data types (Shortstring, Ansistring, Widestring), which differ in length and are used, as a rule, for compatibility with other versions.

The date-time type (TDateTime) is introduced for user convenience. In this case, date and time can be recorded in several forms.

Constants and arrays are written in the same way as in Turbo Pascal 7.0.

P The use of all the described data types, functions for working with them, and the process of creating specific programs will be discussed in the workshop.

Questions to consider:

1. In what language are programs written in the Delphi 7 environment?

2. What parts does the Delphi 7 working window consist of?

3. How many files does a program in Delphi 7 consist of?

4. What are the data types in Delphi 7?

5. How can data types of the same name differ in Turbo Pascal 7.0. and Delphi 7?

The Delphi visual programming system is very popular among a wide range of users: from non-specialists to system programmers developing complex applications and information systems.

Delphi allows you to quickly and easily develop powerful applications, including database applications. The system has advanced capabilities for creating a user interface, a wide range of functions, methods and properties for solving applied computational problems. The system has advanced debugging tools that facilitate application development. Traditionally, Delphi is classified as a rapid application development system. At the same time, this system has almost all the capabilities of a DBMS, such as Microsoft Access and Visual FoxPro. It allows you to conveniently create applications using software tools, visually prepare database queries, and directly write SQL queries to databases. In relation to working with databases, Delphi provides a wide range of tools and supports modern technologies, including multi-level client-server technology.

Like any similar programming system, Delphi is intended for program development and has two characteristic features: programs created with its help can run not only under Windows, and it itself belongs to the class of tools for accelerated program development. This acceleration is achieved due to two characteristic features of Delphi: visual design of forms and extensive use of a library of visual components.

Visual design of forms relieves the programmer from many aspects of developing the program interface, since Delphi automatically prepares the necessary software templates and the corresponding resource file. The programmer uses a special window, called a form window, as a prototype of the future program window and fills it with components that implement the necessary interface properties (various lists, buttons, scroll bars, etc.). After placing the next component on the form, Delphi automatically inserts a link to the component into the module associated with the form and corrects a special form description file with the DMF extension, which, after compilation, is converted into a Windows resource file.

The library of visual components provides the programmer with a huge variety of software templates created by Delphi developers, which are immediately or after simple configuration ready to work within your program. Object placement in Delphi involves a tighter relationship between objects and actual program code. Objects are placed into the generated form, and the code corresponding to the objects is automatically written to the source file. This code compiles to provide significantly better performance than the visual environment, which interprets information only during program execution. The use of components not only reduces program development time by many times, but also significantly reduces the likelihood of random software errors, from which, unfortunately, not a single large software project is protected.

None of the tools for accelerated program development are created without tools for running and debugging the newly created program. In Delphi, these tools are brought to perfection. You can start using the program and sequentially - operator by operator - monitor its execution according to the source text. At any time you can find out the current value of a variable and, if necessary, change it without recompiling the program.

The above two features of Delphi

1) visual design of forms

2) the use of a library of visual components reflects the great advantages of this language and are positive aspects in the process of further development and creation of a package of automated techniques.

The power and flexibility of the Delphi programming language is an undoubted advantage of Delphi, which distinguishes this programming system from other tools for program development. The core of the Delphi language is Pascal.

Delphi is distinguished from Visual Basic by its strict typing, which allows the compiler to detect many errors at the compilation stage, as well as tools for working with pointers. Delphi has the fastest optimizing compiler among products of its kind, allowing you to create fast and relatively compact programs.

The Delphi environment eliminates the need to program common Windows components such as labels, icons, and even dialog boxes. Delphi allows you to tailor dialog box components (such as Choose File and Save File) to the task at hand so that they work exactly as required by the application you are creating. There are also predefined visual and non-visual objects, including buttons, data objects, menus, and pre-built dialog panels. Using these objects, you can, for example, provide data entry with just a few mouse clicks, without resorting to programming. This is a visual implementation of the applications of CASE technologies in modern application programming.

When creating projects in a Windows environment using Delphi, the following benefits are observed: the need to re-enter data is eliminated; ensures consistency between the project and its implementation; development productivity and program portability increases.

Visual programming adds a new dimension to the creation of applications, making it possible to depict objects on the monitor screen before executing the program itself. Without visual programming, the rendering process requires writing a piece of code that creates the object in place. It was possible to see encoded objects only during program execution. With this approach, getting objects to look and behave the way you want becomes a tedious process that requires repeatedly fixing the code, then running the program and seeing what happens.

Thanks to visual development tools, you can work with objects, holding them in front of your eyes and getting results almost immediately. The ability to see objects as they appear during program execution eliminates the need for a lot of manual work that is typical of working in a non-visual environment—whether it is object-oriented or not. After an object is placed in the form of a visual programming environment, all its attributes are immediately displayed in the form of code that corresponds to the object as a unit executed during the operation of the program.

The Delphi environment includes a complete set of visual tools for rapid application development (RAD), supporting user interface development and connecting to corporate databases. VCL is a library of visual components that includes standard user interface building objects, data management objects, graphic objects, multimedia objects, dialogs and file management objects, DDE and OLE management. Delphi visual components are open to extension and rewriting.

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

The Delphi environment consists of four windows, managed as a multi-window application with a single document interface (Figure 1). Delphi's main window manages its associated windows - the Object Inspector, Forms, and Code Editor windows.

Figure 1 - Interface of the main windows of the Delphi environment

The main window (Figure 2) is the development management center. It contains a menu, a quick access panel (SpeedBag) and a palette of components. The menu bar allows you to control all windows of the development environment. The Quick Access Toolbar provides quick access to common operations. The component palette consists of several groups, each of which contains component icons. Having specified the required component in the palette, you can drag it (by clicking the mouse) into the form window. In this case, an active object is created, for which, using the object inspector, you need to set properties and describe reactions to events that will happen to this object when solving a problem.

Figure 2 - Main window

The Object Inspector window (Figure 3) is a multi-page window containing labeled Properties and Events pages. The Properties page displays the properties of objects located in the Form window. The events page displays the events to which form window objects react. The Object Inspector consists of two pages, each of which can be used to define the behavior of a given component. The first page is a list of properties, the second is a list of events. If you need to change anything related to a particular component, you usually do it in the Object Inspector. For example, you can change the name and size of a TLabel component by changing the Caption, Left, Top, Height, and Width properties.

You can use the tabs at the bottom of the Object Inspector to switch between the property and event pages. The Events page is linked to the Editor; If you double-click on the right side of any item, the code corresponding to this event will automatically be written to the Editor, the Editor itself will immediately receive focus, and you will immediately be able to add code for a handler for this event. This aspect of the Delphi programming environment will be discussed further later.

The Object Inspector allows you to determine the properties and behavior of objects placed on a form. The information in it changes depending on the object selected on the form. It's important to understand that each component is a real object, and you can change its appearance and behavior using the Object Inspector.

Delphi programmers spend most of their time switching between the Form Designer and the Source Editor Window (called the Editor for short). Let's tell you in more detail about each window of the Delphi environment.

The form window (form designer window) (Figure 4) contains components (objects) with the help of which the user sets and receives from the program all the information necessary to interact with the task during its execution.

Figure 3 - Object Inspector

The Form Designer in Delphi is where you create the visual interface of the program. It is so intuitive and easy to use that creating a visual interface becomes child's play. The Form Designer initially consists of one empty window, which you fill with whatever objects you select from the Component Palette. Despite the importance of the Form Designer, the place where programmers spend most of their time is the Editor. Logic is the driving force of the program and the Editor is where you “code” it.

Figure 4 - Form Designer

Despite the importance of the Form Designer, the place where programmers spend most of their time is the Editor.

The code editor window (Figure 5) allows you to type and edit the code of a program module in the Object Pascal language. This window is multi-page and allows you to navigate between program modules. Logic is the driving force of the program and the Editor is where you "code" it. In the Editor window you create program control logic.

Figure 5 - Editor Window

In the main window, it is customary to highlight three main selected elements (not counting the standard title bar):

Menu Bar (Menu System);

Component palette;

Quick access panel (SpeedBar).

The menu (Figure 6) provides a fast and flexible interface to the Delphi environment because it can be controlled by a set of hot keys.

Figure 6 - Menu bar

In this sense, designing in Delphi is not much different from designing in an interpretive environment, but after compilation we get code that runs 10 to 20 times faster than the same thing done using the interpreter.

This is also convenient because it uses words or short phrases that are more precise and understandable than icons or pictograms. You can use the menu to perform a wide range of tasks; most likely for the most common tasks such as opening and closing files, managing the debugger, or setting up the programming environment.

The Component palette (Figure 7) allows you to select the necessary objects to place them on the Form Designer. To use the Component Palette, simply click on one of the objects for the first time and then click on the Form Designer a second time. The object you select will appear on the projected window and can be manipulated with the mouse.

The Component palette uses page-by-page grouping of objects. At the bottom of the Palette there is a set of tabs - Standard, Additional, Dialogs, etc. If you click on one of the tabs, you can go to the next page of the Component Palette. The principle of pagination is widely used in the Delphi programming environment and you can easily use it in your program (the Additional page has components for organizing pages with tabs at the top and bottom).

Figure 7 - Component Palette

The SpeedBar (Figure 8) is located directly below the menu, to the left of the Component Palette. SpeedBar does a lot of what you can do through a menu. If you hold your mouse over any of the icons on the SpeedBar, you will see a tooltip appear explaining the purpose of that icon.

Figure 8 - SpeedBar

The last important part of the Delphi environment is the Reference (on-line help), (Figure 9). To access this tool, simply select Help from the system menu and then Delphi Help.

Figure 9 - Directory

The Picture Editor (Figure 10) works similarly to the Paintbrush program from Windows. You can access this module by selecting the menu item Tools | Image Editor.

Figure 10 - Picture Editor

Now we need to consider the elements that a Delphi programmer uses in everyday life. In addition to the tools discussed above, there are five tools that come with Delphi. These tools are: built-in debugger; external debugger (supplied separately); command line compiler; WinSight; WinSpector.

These tools are grouped into a separate category not because they are less important than others, but because they play a fairly abstract technical role in programming.

To become a strong Delphi programmer, you will need to understand how to use the Delphi debugger. The debugger allows you to step through the source code of a program, executing one line at a time, and open a viewing window (Watch), which will reflect the current values ​​of the program variables.

The built-in debugger, which is the most important of the five tools above, runs in the same window as the Editor. The external debugger does everything the built-in one does and then some. It is faster and more powerful than the built-in one. However, it is not as user-friendly, mainly due to the need to leave the Delphi environment.

An external compiler, called DCC.EXE, is useful mainly if you want to compile an application before debugging it in an external debugger. Most programmers will probably find it much easier to compile in Delphi than to try to create a program from the command line. However, there will always be a few originals who will feel happier using a command line compiler. But it is a fact - it is possible to create and compile a program in Delphi using only DCC.EXE and another program CONVERT.EXE, which will help create forms. However, this approach is inconvenient for most programmers.

WinSight and WinSpector are of interest primarily to experienced Windows programmers. This does not mean that a beginner should not run them and experiment with them at his own discretion. But these tools are secondary and are used for narrow technical purposes.

Of the two tools, WinSight is definitely the more useful. Its main function is to allow you to monitor the Windows messaging system. Although Delphi goes to great lengths to hide the complex details of this messaging system from inexperienced users, Windows is nonetheless an event-driven operating system. Almost all major and minor events in the Windows environment take the form of messages that are sent out with great intensity among various windows on the screen. Delphi gives you full access to Windows messages and allows you to respond to them as soon as needed. As a result, WinSight becomes a must-have for advanced users. WinSpector saves a record of the current state of the machine to a text file; You can view this file to find out what is going wrong in the program. This tool is useful when the program is in trial operation - you can get important information if the system crashes.

Thus, work in the Delphi environment is based on object-oriented technology and visualization of the program creation process. This technology supports the construction of programs by defining objects and performing actions on them. The visual environment frees the developer from the need to know many technical details, which allows him to concentrate on the essence of the problem being solved, reduces deadlines and improves the quality of work. Having familiarized yourself with the Delphi programming environment, having considered its obvious advantages - visual design of forms and the use of a library of visual components, you can use this OOP product to create a package of automated techniques.

I chose this programming environment because I know the Delphi programming language best and this language is taught in our college, in addition, this environment has a very convenient interface for development and supports all the functions that I will need when developing a system to create and edit tests.

The main emphasis of the Delphi model is to avoid using code as much as possible. 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 Delphi environment. There are no restrictions on the types of objects that developers can create. Indeed, everything in Delphi is written in it, 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 objects supplied by Borland or third parties and objects that can be created.

Rice. Visual Application Development Environment

The standard Delphi distribution includes basic objects that form a well-chosen hierarchy of 270 base classes. In Delphi, you can write equally well both applications to corporate databases and programs for measuring systems. Developing an interface in Delphi is a fairly simple task for a programmer.

Delphi provides a comprehensive class library - Visual Component Library (VCL), Borland Component Library (CLX), and Rapid Development Block (RAD) tools, including application and form templates, and wizards. Delphi object-oriented programming.

Among the non-standard improvements Borland made to object Pascal, properties and reloadability of procedures and functions (Overloading) should be noted.

The advantage of Delphi is its simplicity, speed and efficiency. Delphi has the fastest compiler of all. Another benefit is that Object-Pascal is easy to learn. The VCL library also allows programming in the Windows API environment. The programming model in Delphi is component-based, which allows you to use many already created components, create your own and use additional ones from others. The advantages include a fairly fast class browser and instant display of auto code completion hints.

The disadvantage of Delphi is that it has fewer functions than C++: it lacks templates, operator overloading, and an object model similar to C++. After using objects, they must be destroyed by calling the Free method. In C++, objects are destroyed automatically when they go out of scope. In addition, the growth of exe files generated by Delphi is noticeable.

Compiler built into Delphi provides translation of an Object Pascal program into object code, detects syntax errors, handles exception situations, allows debugging, performs linking and creates an executable module. In Delphi, compilation is done directly into machine code.

Features of CodeInsight technology in the code editor This is an intelligent editor that allows you to copy/paste, select from a list of reserved words, and indicate the type and location of syntax errors.

Delphi uses Encapsulation (combining records with procedures and functions), Inheritance (using an object to build a hierarchy of derived objects), Polymorphism (giving one name to an action that is passed up and down the hierarchy of objects) - traditional for OOP.

Visual Componentes Librares (VCL) - it is a hierarchy of 270 base classes. user interface building, data management objects, graphical objects, multimedia objects, dialogs and file management objects, DDE and OLE management

Borland Database Engine (BDE) - The operating system preprocessor provides access to database objects in Delphi based on SQL: Oracle, Sybase, Informix and InterBase format files. dbf, or. db (Paradox) or. mdb (Access).

The unique features of Delphi are that developers can add CASE tools, code generators, and authoring help, accessible through the Delphi menu.

Two-way tools technology provides a one-to-one correspondence between visual design and classical writing of program text. This means that the developer can always see code that matches what he built using visual tools and vice versa.

Object Inspector 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.

Object Pascal Foundation This is the Run-Time Type Information (RTTI) mechanism, i.e. information about types at the stage of program execution and properties of object types - classes, with the concept of property; as well as exception handling.

Event delegation means attaching code that handles the action of some interactive element, such as a button, that when clicked actually uses code delegation to associate the code with the onclick event.

Delphi Project Core Files this is PROJECT1. DPR, UNIT1. PAS, UNIT1. DFM - information about the form, PROJECT1. RES contains an icon for the project, PROJECT1. OPT by default is a text file for saving settings associated with a given project. After compiling the program, files with the extensions are obtained: DCU - compiled modules, EXE - executable file. Editor Options settings are saved in the DELPHI file. INI, which is located in the Windows directory.

Technology for editing program errors provides a transition to a code fragment that contains an error, in this case you need to place the cursor in the line with the error message and select the Edit source command from the context menu.

Warnings and hints appear when inaccuracies are detected in the program that are not errors; the compiler displays hints and warnings.

Run-time errors or exceptions.

Linker Options page allows you to select settings that directly affect the current project, these could be, for example, stack checking or range checking compiler directives.

Directories/Conditionals Options page makes it possible to expand the number of directories in which the compiler and linker look for DCU files.

Editor Options page allows you to customize the fine details of the Editor.

EditorOptions, EditorDisplay, and EditorColors settings pages allow you to change the colors and hotkeys used by the IDE.

Five main windows of the OOP programming environment Delphi:

Form Designer;

Source Editor Window;

palette Component (Component Palette);

Object Inspector;

reference book (On-line help).

Structured exception handling This is a system that allows the programmer, when an error (exceptional situation) occurs, to contact the program code prepared to handle such an error. This is done using directives that “guard” a piece of program code and define error handlers that will be called if something goes wrong in the “protected” piece of code.

Main Delphi components:

Edit component. Text allows you to read text from the Edit window

The TCheckBox component displays a line of text with a small window next to it.

The TRadioButton component allows you to select only one option from several.

The TListBox component is needed to display a scrollable list.

The TStringGrid component is used to present text data in the form of a table.

The TMainMenu component allows you to place the main menu in the program.

The TPopupMenu component allows you to create popup menus.

The TBitBtn component represents a button on which you can place an image.

The TDrawGrid component is used to present data of any type in the form of a table. Each table element is accessed through the CellRect property.

The TImage component displays a graphic image on a form. Accepts BMP, ICO, WMF formats. If you connect an image during program design, it will be compiled into an EXE file.

The TShape component is used to display simple graphic objects on a form: circle, square, etc.

Windows dialogs are organized by dialog components: OpenDialog - select a file, SaveDialog - save a file, FontDialog - configure the font, ColorDialog - select a color, PrintDialog - print, PrinterSetupDialog - configure the printer.

The System - TTimer page component is a timer; the OnTimer event is fired periodically after a period of time specified in the Interval property. The time period can be from 1 to 65535 ms.

The System page component - TFileListBox is a specialized ListBox that displays files from the specified directory (Directory property).

The System page component - TDirectoryListBox is a specialized ListBox that displays the directory structure of the current disk. In the FileList property, you can specify TFileListBox, which will automatically track the transition to another directory.

The System page component - TDriveComboBox is a specialized ComboBox for selecting the current drive. Has a DirList property in which you can specify a TDirectoryListBox, which will track the transition to another disk.

The System page component - TMediaPlayer is used to control multimedia devices (such as CD-ROM, MIDI, etc.). Designed as a control panel with buttons Play, Stop, Record, etc.

Integrated project development environment. Five main windows of the integrated development environment: main, form, code editing window, object inspector, browser.

A feature of the integrated development environment is the visual (and, therefore, high-speed) construction of applications from software prototypes.

Compiling, linking and running programs. The task of converting the source program into machine code is performed by a special program - a compiler.

The compiler performs two tasks sequentially:

1. Checks the source program text for syntax errors.

2. Creates (generates) an executable program - machine code.

When an error occurs in a program launched from Delphi, the development environment interrupts the program, as indicated by the word Stopped enclosed in brackets in the title bar of the main Delphi window, and a dialog box appears on the screen containing an error message and information about the type (class) of the error .

Compilation of a program that contains an algorithmic error completes successfully. During test runs, the program behaves normally, but when analyzing the result, it turns out that it is incorrect. In order to eliminate an algorithmic error, you have to analyze the algorithm and manually “scroll” its execution.

Data and expression types. Data types include integer, real, logical, string and character:

Shortint - 128-127 8 bits

Smallint - 32,768 - 32,767 16 bits

Longint - 2,147,483,648 - 2,147,483,647 32 bits

Int64 - 263 - 263 - 1 64 bits

Byte 0-255 8 bits, unsigned

Word 0-65 535 16 bits, unsigned

Longword 0 - 4 294 967 295 32 bit unsigned

universal integer type - Integer

universal real type - Real

Ansichar type is ANSI characters that correspond to numbers in the range from 0 to 255;

The widechar type is Unicode characters and corresponds to numbers from 0 to 65,535.

ObjectPascal also supports the most universal character type -

the shortstring type is a string statically allocated in computer memory with a length of 0 to 255 characters;

The Longstring type is a string dynamically allocated in memory, the length of which is limited only by the amount of free memory;

The WideString type is a string dynamically allocated in memory, the length of which is limited only by the amount of free memory. Every character in a WideString is a Unicode character

the string type is equivalent to the shortstring type.

Designing and initializing common controls involves using:

Drag-and-Dock connection interface;

Drag-and-Drop transfer interface;

improved scaling;

focus control;

mouse control;

Creating tooltips. If you hover the cursor, for example, over a button or palette component of the Delphi environment itself, a small brightly colored rectangle appears (a tooltip window), in which one line tells about the name of this element or the action associated with it. Delphi supports mechanisms for creating and displaying such shortcuts in created programs.

The technology for developing a program in Delphi for widespread use includes the following steps:

Specification (definition, formulation of requirements for the program).

Algorithm development.

Coding (writing an algorithm in a programming language).

Testing.

Creation of a help system.

Creating an installation disk (CD-ROM).

During the process of building an application, the developer selects ready-made components from the component palette. Even before compilation, he sees the results of his work - after connecting to the data source, you can see them displayed on the form, you can navigate through the data, present them in one form or another. The user can also add his own components to the library, which he develops in the Delphi environment.

The Delphi work screen (Delphi-6 version) has 4 main windows: the main Delphi window; form window Form1; the Object Inspector window and the Unit1 code editor window. pas

Features of the MySQL DBMS

MySQL is a free database management system (DBMS). MySQL is the property of Oracle Corporation, which acquired it along with the acquired Sun Microsystems, which develops and supports the application. Distributed under the GNU General Public License or its own commercial license. In addition, developers create functionality at the request of licensed users; it was thanks to this order that the replication mechanism appeared in almost the earliest versions.

MySQL is the solution for small and medium-sized applications. Included in the WAMP, AppServ, LAMP servers and in portable server builds Denver, XAMPP. MySQL is typically used as a server accessed by local or remote clients, but the distribution includes a back-end library that allows MySQL to be included in standalone programs.

The flexibility of the MySQL DBMS is ensured by support for a large number of table types: users can choose both MyISAM tables that support full-text search and InnoDB tables that support transactions at the individual record level. Moreover, the MySQL DBMS comes with a special EXAMPLE table type that demonstrates the principles of creating new table types.

Thanks to the open architecture and GPL licensing, new types of tables are constantly appearing in the MySQL DBMS.

The software I chose is simple and convenient, and it also has all the components that I will need when developing my own program, therefore, I chose these development environments.

Delphi programming environment interface

First of all, Delphi is intended for professional developers of corporate information systems. Perhaps we should clarify here what exactly is meant. It's no secret that some successful rapid application development (RAD) products work great when building fairly simple applications, but the developer faces unexpected challenges when trying to make something truly complex. It happens that a product reveals its inherent limitations only after some time has passed. Delphi has no such limitations. A good proof of this is the fact that Delphi itself is developed in Delphi. You can draw conclusions. However, Delphi is not just for professional programmers. I read letters in an electronic conference that were completely unexpected for me, where teachers, doctors, university professors, businessmen, all those who use a computer for a purely applied purpose, talked about how they purchased Delphi for Windows in order to quickly solve some problems. their tasks without involving outside programmers. In most cases they succeed. An amazing fact - Visual Basic Magazine awarded its award to Delphi for Windows. Business managers planning to allocate funds for the purchase of software products must be confident that the planned investment will pay off. Therefore, one of the assessed factors should be the question - is it easy to find a Delphi specialist and how much will his training cost, how much time will the specialist spend on mastering the product. The answer here is quite simple - any Pascal programmer can almost immediately master Delphi professionally. A specialist who has previously used other software products will have a more difficult time, but he will be able to write the very first working application within the first hour of working in Delphi.

Structure of the programming environment

The appearance of the Delphi programming environment is different from many of those that can be seen on Windows. For example, Borland Pascal for Windows 7.0, Borland C++ 4.0, Word for Windows, Program Manager - these are all MDI applications and look different than Delphi. MDI (Multiple Document Interface) - defines a special way to manage multiple child windows within one large window. If you use an SDI application like Delphi, you already know that before starting work it is better to minimize other applications so that their windows do not clutter the workspace. If you need to switch to another application, simply click on the Delphi system minimize button. Together with the main window, all other windows of the programming environment will be minimized, freeing up space for other programs to work.

Main components of the programming environment

The main components of Delphi are listed below:

  1. Form Designer
  2. Editor Window
  3. Component Palette
  4. Object Inspector
  5. Directory (On-line help)

Delphi's Form Designer is so intuitive and easy to use that creating a visual interface becomes child's play. The Form Designer initially consists of one empty window, which you fill with whatever objects you select from the Component Palette. Despite the importance of the Form Designer, the place where programmers spend most of their time is the Editor. Logic is the driving force of the program and the Editor is where you “code” it. The Component palette allows you to select the desired objects to place on the Form Designer. To use the Component Palette, simply click on one of the objects for the first time, and then click on the Form Designer a second time. The object you select will appear on the projected window and can be manipulated with the mouse. The Component palette uses page-by-page grouping of objects. At the bottom of the Palette there is a set of tabs - Standard, Additional, Dialogs, etc. If you click on one of the tabs, you can go to the next page of the Component Palette. The principle of pagination is widely used in the Delphi programming environment and you can easily use it in your program. (The Additional page has components for organizing pages with tabs at the top and bottom.) To the left of the Form Designer you can see the Object Inspector. Note that the information in the Object Inspector changes depending on the object selected on the form. It's important to understand that each component is a real object, and you can change its appearance and behavior using the Object Inspector. The Object Inspector consists of two pages, each of which can be used to define the behavior of a given component. The first page is a list of properties, the second is a list of events. If you need to change anything related to a particular component, you usually do it in the Object Inspector. For example, you can change the name and size of a TLabel component by changing the Caption, Left, Top, Height, and Width properties. The last important part of the Delphi environment is the Reference (on-line help). To access this tool, simply select Help and then Contents from the system menu. The Directory will appear on the screen. The directory is context-sensitive; When you press the F1 key, you will receive a hint corresponding to the current situation. For example, while in the Object Inspector, select a property and press F1 - you will receive help about the purpose of this property. If at any time while working in the Delphi environment there is ambiguity or difficulty, press F1 and the necessary information will appear on the screen.

Additional items

This section focuses on three tools that can be thought of as supporting tools for the programming environment:
Menu (Menu System);
Panel with buttons for quick access (SpeedBar);
Image Editor.
The menu provides a fast and flexible interface to the Delphi environment because it can be controlled by a set of “hot keys”. This is also convenient because it uses words or short phrases that are more precise and understandable than icons or pictograms. You can use the menu to perform a wide range of tasks; most likely for the most common tasks such as opening and closing files, managing the debugger, or setting up the programming environment. The SpeedBar is located directly below the menu, to the left of the Component Palette. SpeedBar does a lot of what you can do through a menu. If you hold the mouse over any of the icons on the SpeedBar, you will see that a tooltip will appear explaining the purpose of this icon. The Picture Editor works similarly to the Windows Paintbrush program. You can access this module by selecting the menu item Tools | Image Editor. Now we need to consider the elements that a Delphi programmer uses in everyday life.

Tools

In addition to the tools discussed above, there are five tools that come with Delphi. These tools:
Built-in debugger
External debugger (sold separately)
Command line compiler
WinSight
WinSpector
These tools are grouped into a separate category not because they are less important than others, but because they play a fairly abstract technical role in programming. To become a strong Delphi programmer, you need to know how to use the Delphi debugger. The debugger allows you to step through the source code of a program, executing one line at a time, and open a viewing window (Watch), which will reflect the current values ​​of the program variables. The built-in debugger, which is the most important of the five tools above, runs in the same window as the Editor. The external debugger does everything the built-in one does and then some. It is faster and more powerful than the built-in one. However, it is not as user-friendly, mainly due to the need to leave the Delphi environment.

Standard Components

To further familiarize yourself with the Delphi programming environment, you will need to talk about the composition of the first page of the Component Palette. The first page of the Component Palette contains 14 objects that are definitely important for use. Few people can live without buttons, lists, input windows, etc. for a long time. All these objects are as much a part of Windows as a mouse or a window. The set and order of components on each page are configurable. So, you can add new components to existing ones, change their quantity and order. The standard Delphi components are listed below with some comments on their use. When studying these components, it would be useful to have a computer handy to see how they work and how to manipulate them. TMainMenu allows you to put a main menu into a program. When you place a TMainMenu on a form, it looks like just an icon. Icons of this type are called "invisible components" because they are invisible during program execution. Creating a menu involves three steps: (1) placing a TMainMenu on the form, (2) calling the Menu Designer through the Items property in the Object Inspector, (3) defining the menu items in the Menu Designer. TPopupMenu allows you to create popup menus. This type of menu appears when you right-click the mouse. TLabel is used to display text on the screen. You can change the font and color of the label by double-clicking the Font property in the Object Inspector. You will see that this can be easily done while the program is running, with just one line of code. TEdit is a standard Windows input control. It can be used to display a short piece of text and allows the user to enter text while the program is running. TMemo is another form of TEdit. Involves working with large texts. TMemo can wrap words, save text fragments to Clipboard and restore them, and other basic editor functions. TMemo has a text limit of 32Kb, which is 10-20 pages. (There are VBX and “native” Delphi components, where this limit is removed). TButton allows you to perform some action when a button is pressed while the program is running. In Delphi everything is done very simply. By placing a TButton on the form, you can double-click it to create a template handler for the button's click event. Next, you need to fill in the blank with code (what needs to be written manually is underlined):

Procedure TForm1.Button1Click(Sender: TObject); begin MessageDlg("Are you there?", mtConfirmation, mbYesNoCancel, 0); end; TCheckBox displays a line of text with a small window next to it. You can put a checkmark in the box, which means that something is selected. For example, if you look at the compiler settings dialog window (menu item Options | Project, Compiler page), you can see that it consists mainly of CheckBoxes. TRadioButton allows you to select only one option from several. If you open the Options | Project and select the Linker Options page, you can see that the Map file and Link buffer file sections consist of RadioButton sets. TListBox is needed to display a scrollable list. A classic example of a ListBox in the Windows environment is selecting a file from the list in the File | menu item. Open many applications. The names of files or directories are located in the ListBox. TComboBox is very similar to ListBox, except that it allows you to enter information into a small input field on top of the ListBox. There are several types of ComboBox, but the most popular is the drop-down combo box, which can be seen at the bottom of the file selection dialog box. TScrollbar is a scroll bar that appears automatically in edit objects and ListBoxes when it is necessary to scroll text to view. TGroupBox is used for visual purposes and to tell Windows what order to move through components on a form (when you press the TAB key). TPanel is a control element similar to TGroupBox, used for decorative purposes. To use a TPanel, simply place it on the form and then place other components on top of it. Now when you move the TPanel, these components will also move. TPanel is also used to create the toolbar and status window. TScrollBox represents a place on a form that can be scrolled in vertical and horizontal directions. Until you explicitly disable this feature, the form itself acts the same. However, there may be times when you only need to scroll part of the form. In such cases, TScrollBox is used. This is the complete list of objects on the first page of the Component Palette. If you need additional information, select an object in the Palette and press the F1 key - a Reference Book will appear with a complete description of this object. The rest is related to building the user interface: placing objects on the form, setting their properties and writing event handlers. As well as creating applications that work with databases. So, it is obvious that the user is the closing link of the control system, i.e. the subject of control, and the program is the object of control. Rational organization of user labor is one of the most important factors determining the effective functioning of the system as a whole. Before the advent of operating systems of the Windows family, the user controlled without “seeing” the real object. Between the real control object and the user there was an information model of the object (means for displaying information). Therefore, the problem arose of designing not only means of displaying information, but also means of user interaction with the technical means of the program, i.e. the problem of designing a system called user interface.

Features of the Delphi programming environment

An analysis of the experience of introducing computer programs for educational purposes in schools, universities and various enterprises shows that an important factor hindering their widespread use is the incomplete compliance of the proposed material with the ideas and methods of teaching a particular discipline. Many educators show considerable caution in the use of educational programs and pedagogical software. The ideal solution to this problem is to fully take into account the requirements of the user (teacher), which is practically unattainable. Currently, the development of training and other educational programs is dominated by the interests and preferences of the manufacturer, that is, computer programmers. In the press and at conferences at various levels, the opinion has been expressed more than once that a modern teacher rather needs not a disk with a complete multimedia course on the subject, but some elementary building blocks that he could use as colorful illustrations of his ideas and methods and which fit more organically into would be in the tradition of using visual aids selected by the teacher for his lesson. In this regard, it seems advisable to create not finished educational products, but unique electronic construction kits - software tools (authored systems) for teachers to create their own applications. One such tool is Delphi. However, there is very little entry-level literature intended for mastering Delphi in relation to use in the educational process. Professional programmers are not interested in such tasks as a mini-calculator or an educational graphic editor - they would rather be given examples of working with databases using client-server technology. But the teacher doesn’t need this at all. Delphi can be learned and used on several levels: Working with visual lenses with virtually no programming. Using ready-made system components and writing your own program code based on them. Creating your own components in Pascal and including them in the Delphi components palette as standard. Development of complete Windows applications. For a school course, the first level is more than enough (second level problems can be solved in a specialized school course and in electives). Not so long ago, object- and event-oriented programming seemed very exotic to non-professionals. However, even after the arrival of Windows 95/98, this style of creating programs is not yet in actual demand in real school practice. I will give an example of conducting classes on creating Windows applications with groups of schoolchildren studying computer science in depth. The Delphi3 visual program design environment was chosen for the work. Students who began learning and using Delphi were already quite proficient in Windows 95 and applications. Therefore, the Delphi integrated development environment was perceived by students as completely natural. Designing forms with various visual components (well-known Windows controls) and working with the Object Inspector to set object properties aroused genuine interest among students. At the same time, the first applications were created in which the properties of objects could be changed programmatically. The figurative comparison used by the teachers was very vividly perceived: we design a Windows robot, create blanks for its parts, program its reactions to certain user actions, during the compilation process Delphi assembles the robot and puts it into operation. Now we need to determine whether the robot is successful, the way we wanted. Having received practical experience in constructing event-driven object-oriented programs, schoolchildren then, with the help of the teacher, reached the level of corresponding theoretical generalizations. A number of schoolchildren with an empirical thinking style successfully constructed very interesting applications, limiting themselves to the minimal use of basic control structures when developing procedures. At the same time, behind these structures they now saw not a means for organizing difficult-to-understand abstract calculations, but a means for teaching Windows a robot, that is, a means for solving a very interesting problem. Schoolchildren with a developed theoretical style of thinking, freed from the routine of organizing the Turbo Pascal interface and the rigid framework of its capabilities, went on to develop serious, developed projects using a variety of Delphi components and good development of procedural code. In my opinion, modern technologies for constructing Windows applications in Delphi are in many ways more accessible to schoolchildren than traditional programming, arouse great interest, contribute to the development of the student’s creative potential and have wonderful didactic opportunities.

Review of applications created in the Delphi environment

Requirements for visual programming environments

Basic requirements that the visual algorithm design environment must satisfy:

  1. The environment must be designed to run on the most popular modern operating system that supports a graphical user interface. This will make it possible to study the basics of algorithmization using a significant amount of computer equipment that is equipped in secondary schools. At the moment, these are operating systems of the Windows family from Microsoft.
  2. The environment must be designed to meet common standards for modern software products. This will ensure convenience and ease of working with environment controls: menus, toolbars, etc., and will provide an opportunity to strengthen the user’s basic skills in working with software.
  3. The environment should be simple and powerful. Ease of development and use of the environment, the ability to construct a wide class of algorithms using all currently available resources of multimedia computers.
  4. To provide algorithms, it is necessary to select a form that must satisfy two main criteria: to be visual and understandable to the user and to be convenient for implementation in the graphical shell of the operating system. In addition, the form of presentation, due to its capabilities, should be as close as possible to the content of the algorithm, and not to the syntax of algorithmic structures that is used in this presentation.
  5. The methods by which algorithms are constructed in the environment should be based on methods for creating software using modern development tools, which are based on the object approach and visualization. This, in our opinion, will enable students, if necessary, for example, when studying the basics of modern programming in classes with in-depth study of computer science or as an elective, to quickly master visual programming technology.
  6. One of the main tasks is to create an environment focused on highlighting the semantic content of the problem being solved, and not on studying the algorithmic structures of a specific representation. “Despite the fact that the development of each new algorithm requires its own approach, there are nevertheless certain general techniques and stages of this type of activity.” Therefore, the environment must implement the unification of algorithmic structures as constructions that are contained in any algorithms, and not just algorithms of a certain class. In the role of such unified structures, it is advisable to use the following standard algorithmic structures: following, branching, repeating and calling a subroutine.
  7. Actions that relate to solving a specific problem must be defined in semantic content and organized in the form of a separate block (subroutine). For example, if you need to play some sound file, then the meaning of this construction should be “play a sound file with a specific name.”
  8. In the environment, the structure of the algorithm must be represented in graphical form using a certain "graphical" syntax. Along with this, it is possible to use text syntax to designate identifiers and names of methods of graphical-visual objects. This kind of syntax cannot be "removed" completely, since it is external to the algorithmic representation. But such "external" syntax is based on concepts known to students from their own experience acquired in studying other school subjects, and its application should not cause significant difficulties.
  9. The environment must allow the user to freely change the syntax of text-character commands (where appropriate). For example, changing the arithmetic addition symbol “+” to some other one is hardly worth it from the point of view of clarity and unification, but choosing a name for the removal action in a character string - “erase” or “delete” - depends entirely on the user’s desire.
  10. As you know, each algorithm works with a specific set of data, which is processed using certain methods. Actually, an algorithm is the process of converting input data into output data. Therefore, there should be a clear distinction between data and processing methods. This does not contradict the procedural programming paradigm. It is enough just to recall the famous “formula” of N. Wirth “algorithms + data = program”. At the same time, it is logical to make the data strictly typed, as required by the rules of modern programming languages, and place it separately, for example in the form of a table, which can be quickly accessed at any time during the construction of the algorithm.

Methodology for creating educational applications

Today, creating any computer application, especially a computer science course, is unthinkable without a carefully thought-out development plan. Currently, there is a well-developed methodology for creating computer training systems. Like any design methodology, it includes a number of sequential stages. To create a training program you need:
Select program type. At this stage, the main goals and objectives of the program are determined, as well as the means of its implementation.
Collect suitable source materials - texts, reproductions and illustrations, audio recordings, videotapes, computer files. The completeness of the collected materials indicates readiness to implement the program and determines the level of its quality.
Write a script for the program and the teacher’s interaction with it, which determines the composition of all collected materials. All program logic is defined here. The script describes the relationships between the slides, the structure and changes on those slides, and the sound and video effects.
Process the collected materials on a computer, preparing them for inclusion in the training program, i.e. create and edit text, graphics, animation, video, and sound. It uses both standard tools of the operating system itself, as well as standard packages for text editing (Microsoft Word), computer graphics and animation (3D Studio, Adobe PhotoShop), video editing (Adobe Premiere), Web mastering (Microsoft FrontPage), as well as programs , supplied with audio and video cards.
Implement the scenario in the form of a working program, making the necessary changes to the materials and the scenario during trial operation. For non-programmer authors, the best option is to use visual programming tools such as Power Point from Microsoft Office, Macromedia Director, and Web mastering tools. Finally, professional programmers can use the programming systems Visual C++, Visual Basic, Delphi, Java, etc., but they will achieve optimal development time if they use them in addition to the systems listed above.
Prepare teaching materials for program users - teachers. Such materials are necessary because users of the program, as a rule, do not have the qualifications of its authors.

Practical part

Creation of simple educational programs.

Project "Color Selection"

Formation of color from individual components. TColor class, color constants, RGB function The colors of objects are formed by mixing three components - red (red), green (green) and blue (blue). The intensity of each color component can vary from 0 to 255. The combination (0, 0, 0) corresponds to black, and (255, 255, 255) to white. Almost every visual component has a Color property. Until now, we have chosen its value from a list of standard colors, but nothing prevents us from creating a color from individual components. To do this, we will use the RGB function: Color:= RGB (red, green, blue); You can also create your own color scheme by pre-preparing colors for various visual objects. But you can use these colors only when creating the corresponding object at the program execution stage (we'll talk about this a little later). To select colors, we will develop a project that allows you to easily change the color of the panel using scroll bars - objects of the TScrollBar class. Let's place a panel and three scroll bars on the form (they are also located on the standard tab). Each scroll bar will be responsible for the intensity of one of the three color components. The leftmost position of the slider should correspond to the minimum, and the rightmost position should correspond to the maximum intensity value. Let's set the property Min=0 for all stripes, and the Max property=2 5 5. Set up other properties: Kind - determines the placement of the strip - horizontal (sbHorizontal) or vertical (sbVertical); LargeChange—step of movement of the slider when clicking on the strip itself; SmallChange - step of moving the slider when clicking on the arrow; Position - the numerical equivalent of the position of the slider on the scroll bar,

Source:

You can download it immediately in a ZIP archive.

Program 1. "Color Selection"
The main event for the scroll bar is the movement of the slider (the OnChange event), and the method of movement does not matter. Let's write a separate procedure for changing the panel color:

Procedure SetPanelColor; var red, green, blue, k: word; begin red:= Form1. ScrollBar1.Position; if form1.rb1.Checked then begin k:=255 div 2; if (red>=0) and(red=0) and(green=0) and(blue and we will call it in response to moving the slider on any scroll bar: procedure TForm1.ScrollBar1Change(Sender: TObject); begin SetPanelColor; end ; procedure TForm1.ScrollBar2Change(Sender: TObject); begin SetPanelColor; end; procedure TForm1.ScrollBar3Change(Sender: TObject); begin SetPanelColor; end; Selecting a palette of 8 colors, we must change the position of the slider so that its movement is 0 or 255: procedure TForm1.RB1Click(Sender: TObject); begin Form1.Caption:="Palette of 8 colors; ScrollBar1.LargeChange:=255; ScrollBar1.SmallChange:=255; ScrollBar1.Position:=0; ScrollBar2.LargeChange:=255; ScrollBar2.SmallChange:=255; ScrollBar2.Position:=0; ScrollBar3.LargeChange:=255; ScrollBar3.SmallChange:=255; ScrollBar3.Position:=0; end; procedure TForm1.RB2Click(Sender: TObject); begin Form1. Caption:="Palette of 256 colors; ScrollBar1.LargeChange:=1; ScrollBar1.SmallChange:=1; ScrollBar1.Position:=0; ScrollBar2.LargeChange:=1; ScrollBar2.Position:=0; ScrollBar2.SmallChange:=1; ScrollBar3.LargeChange:=1; ScrollBar3.SmallChange:=1; ScrollBar3.Position:=0; end; The project is ready, we can launch and work with it. A design option for the project is shown in the figure:

This application can be used in computer science lessons to reinforce the material “Representing graphical information in a computer,” clearly showing that color is stored as a numeric code. The set includes palettes of 8 and 256 colors.

Components of the program:
Panel (Panel) for displaying color;
3 scroll bars (ScrollBar) for changing the color scheme (KZS or KKKZZZSS);
2 switches (RadioButton) for selecting a color palette;
3 text fields (Edit) for displaying the color code;
Button (BitBtn) to close the program.

mob_info