Features of working with interfaces in Delphi. Best IT solutions for business Windows should not exceed screen sizes

only for the result

strict adherence to deadlines

Transparency

project execution

technical support as a gift

Programming, revision of advice on 1C

How we are working

1. We discuss the problem over the phone. In the presence of remote access- show on the screen of your computer.

2. We estimate the work in rubles, if the project is large, if not - the approximate number of hours.

3. We get the job done.

4. You accept work in your program, if there are any shortcomings, we correct them.

5. We issue an invoice, you pay.

Cost of work

1. All work is divided into 3 categories: consultation, updating a typical configuration, developing or programming a new report, processing, buttons, etc.

3. For work more than 10 hours, a technical assignment with a description and cost of work is preliminarily drawn up. Work begins after agreeing on the terms of reference with you.

Technical support

1. If you find any errors in previously accepted works, within 3 months, we correct them free of charge.

2. For regular customers, we correct any shortcomings in our work free of charge throughout the year.

Programs to manage your business.

Buy 1C: Enterprise

We are an official dealer of 1C, you can purchase various software products and licenses. In addition to buying a "box", we will help you set up the program, advise and make basic settings.

  • Accounting
  • Store automation
  • Wholesale
  • Installation assistance and initial setup included in the package!
  • Fine tuning of configurations for the needs of the customer, development of new modules in the absence of the necessary functions in the standard configuration.
1c accounting 1C: Trade Management 1C: Retail 1C: Salary and Personnel Management
From 3300 rub. From 6700 rub. From 3300 rub. From 7400 rub.

Server provision.

Instant setup server + 1C.

Don't have a server? It doesn't matter, we'll pick up and quickly set up a server in the "cloud". For a small fee, you get a very reliable solution.

  • Availability 24/7
  • No need to keep your own system administrator(the savings will cover your server costs).
  • Quick setup and installation of 1C on the server, in 3 days you will already have a fully working system.
  • At any time you can move to local server if the solution doesn't suit you.

SMS from your 1C

Do you want customers to know about promotions, discounts on time? Customers not returning? Customize sending SMS straight from 1C!

Our company will be able to quickly set up sending SMS to your customers directly from 1C. Examples of events that can be automated:

  • Thanks for the purchase and the accrual of bonuses immediately after the next purchase.
  • Accrual of bonuses to the card as a gift for a birthday \ for another significant or holiday.
  • Notification of goods arrival at the warehouse.
  • Expiration of gift bonuses.
  • Notification of the receipt of an advance payment and reservation of goods.
  • Address with details of how to get to the store / office, phone numbers.
  • Etc.

Settings in 1C can be done by our specialists or our employees. You can get acquainted with the tariffs on the SMS tariffs page.

  • Guarantee SMS delivery, money is withdrawn only for delivered SMS.
  • Separate billing for each SMS.
  • Balance replenishment in different ways.
  • View the history of all sent SMS at any time.
  • The sender's name instead of the digital number on the message recipient's phone.

Creation interface the user is reduced to choosing from the palette of components the Delphi components necessary for the program to work, serving interface management as well interface displaying information, and transferring them to the Form with subsequent layout.

The user interface you create should use standard elements familiar to users and provide maximum convenience. All this is ultimately determined by such a criterion as the effectiveness of the interface - the maximum result with minimum effort.
Principles of creation user-friendly interface are known. As the most general principles while creating user interfaces there are three main points to consider:

  1. The program should help to complete the task, not become that task.
  2. When working with the program, the user should not feel like a fool.
  3. The program must work in such a way that the user does not think the computer is a fool.
The first principle- this is the so-called "transparency" of the interface. The user interface should be intuitive, easy to learn, and not create problems for the user that he will have to overcome in the process. Use standard, without undue decoration components, use the familiar, used similar programs control techniques and you will reach the performance criteria first principle.

Second principle is to neglect intellectual abilities users. From my own experience, I know that often users not only do not know how to work at a computer, but are simply afraid to do something on their own. Therefore, the user interface should be as friendly as possible.
Moreover, the fears of users are often justified, because the cost of the program, and the computer itself, cannot be compared with the cost, for example, of a database created by many years of efforts. That is why the programmer, when creating the user interface, must always build in the program "protection from the fool" - from wrong actions and user input of incorrect data. But some programmers get too carried away with such protection, make it too intrusive, and as a result, the program's work resembles the famous "step to the left, step to the right is considered an escape"! And what a programmer creates as a solution to a problem begins to create problems by itself.
To comply second principle there is no need to allow the program to "correct" the user's actions and to indicate what exactly he should act, driving it into a narrow framework. Also, you should not get too carried away with the display of informational prompts, especially dialog messages, this distracts the user from work. Better yet, provide for the ability to disable prompts.

The third principle is to create a program with the highest possible "mental" ability. Despite the rapid development computer technology, even widespread programs can only conditionally be called having artificial intelligence. They interfere with the user experience by displaying dialog boxes with stupid questions that cause confusion even in the simplest situations. As a result, users exclaim in their hearts: "Well, this machine is stupid!"
I am personally annoyed by the constant questions of almost everyone text editors about whether to keep the changed text, although the original and the current text do not differ in any symbol. Yes, I was typing something, but then I returned everything back, really you can't figure it out! I have to check to see if I messed up anything.

Try to adhere to the following rules:

Standard interface elements
Use standard for of this element interface components. Having met your program, the user will not waste time getting to know each other, but will immediately start working - this is one of the signs of a professionally made program.
Small palette of tools
Try not to use too much a large number of various components. And of course, having used one standard component somewhere in one place, in a similar case, also use it.
Equal spacing between controls
Place interface elements at the same distance from each other. Components scattered around give the impression of an unprofessional product. Conversely, careful placement of buttons, radio buttons, check boxes and other components that make up the interface on the Form is a sign of quality work.
TabOrder. "Correct" order
TabOrder is the order in which the screen cursor moves through the controls when a key is pressed Tab... In a correctly written program, the cursor moves following the logic of the user's work with the program. When creating a program, the programmer often changes components, removes some, and adds others as needed. As a result, in the finished program, the cursor jumps randomly along the Form. After completing the program, do not forget to configure TabOrder.
Font selection
Just leave the fonts alone. Delphi's own default fonts are suitable for any system your program can run on. Use bold only to highlight important elements. Application of the same italic and especially underlining which the user might mistake for a hyperlink is bad form.
Choice of colors
As for the colors of interface elements, just like in the case of fonts, it is better to leave them as standard, by default. Delphi uses the Windows system palette, and the user, by changing it, can easily customize the colors for themselves.
Alternative control
A professionally made program should be able to be controlled not only with a mouse, but also with a keyboard. There should be no functions available for execution only with the mouse (drawing in graphic editors does not count!). For the most used functions, you should provide "hot keys" for their quick access.
Interface Bricks
As for specific elements of the user interface, the quality of user interaction with the program depends on:
  • compliance of the control element with the task it is performing;
  • rules according to which the control element operates.
    This page discusses the rules for creating some interface elements.
And now I want to show what tools Delphi offers for managing components on a Form, their relative position and the behavior of the cursor when a key is pressed. Tab.

In order to arrange the components in the correct order relative to each other, first it is necessary to highlight them... You can simply drag the mouse around the area on the Form that contains the selected components. Or by holding " Shift", point with the same mouse to each component to be selected. Repeated clicking with the mouse on the selected component (when pressed Shift") deselects it.

The selected components can be manipulated as a whole - they can be moved around the Form, assigned values ​​to the same properties, copied (for installation, for example, on another Form), even deleted.

Now right-click on one of the components, and from the "pop-up" menu select Position -> Align ... A dialog box appears allowing you to adjust the horizontal and vertical position of the components in the group. For example, let's say we need to left-align our four buttons and have equal distance vertically. To do this, select the radio buttons Horizontal: Left sides and Vertikal: Space equally.

By selecting the item Center, we will arrange the components so that their centers are located on the same line horizontally or vertically, and the point Center in window moves components to the center of the window, also horizontally or vertically.

In the same menu, the line Tab O rder ... causes the appearance of a dialog box that controls the movement of the cursor over interface elements when a key is pressed Tab... When the Form appears on the screen, the cursor will naturally be on the component located on the first line of the dialog box. And then it will move down the list. In the dialog box, two blue up and down arrows control the position of the selected component. Highlight required component, use the arrows to move to the desired line in the list, and so on.

When selecting a menu item Control -> a submenu appears, consisting of two items:

  • Bring to Front
  • Send to back
These are component methods that are also available programmatically. Button1.SendToBack moves the button to the "background" and Button1.BringToFront- bring to Front". That is, if one component is positioned on top of another, these methods swap them. The cases in which this can be applied are fairly obvious.

Object-oriented programming (OOP), in addition to the concept of a class, also provides for the fundamental concept of an interface.

What is an interface and what are the features of working with it in the Delphi programming language?

Interface is a semantic and syntactic construct in program code used to specify the services provided by a class or component (Wikipedia).

In fact, the interface defines a list of properties and methods that should be used when working with the class that implements this interface, as well as their signature (name, data type, accepted parameters (for procedures and functions), etc.). Thus, a class that implements a particular interface must necessarily implement all of its components. Moreover, in strict accordance with how they are described in it.

Interfaces are often compared with abstract classes, but despite the similarity, this comparison is not entirely correct. In abstract classes, at least control over the visibility of members is available. At the same time, no scopes are defined for interfaces.

Interfaces allow you to make the architecture more flexible, since they unify access to a particular functionality, and also allow you to avoid a number of problems associated with class inheritance (interfaces can also be inherited from one another).

To declare an interface in Delphi, use the interface keyword. This is the same keyword that defines the section of the module that can be accessed from outside (between keywords interface and implementation). However, when declaring an interface, a different syntax is used, similar to class declarations.

Delphi / Pascal

IMyNewInterface = interface procedure InterfaceProc; end;

IMyNewInterface = interface

procedure InterfaceProc;

end;

Thus, the syntax of the interface declaration itself does not fundamentally differ from other programming languages ​​(the features of the syntax based on Pascal do not count). At the same time, the implementation of the interfaces has a number of characteristic features.

The point is that Delphi interfaces were originally introduced to support COM technology. Therefore, the IInterface interface, which in Delphi is the ancestor for all other interfaces (a kind of analogue of TObject), already contains three basic methods for working with this technology: QueryInterface, _AddRef, _Release. As a result, if a class implements any interface, then it must implement these methods without fail. Even if this class is not designed to work with COM.

Due to this feature of the IInterface interface, in Delphi, the use of interfaces, in most cases, leads to the addition of deliberately unused capabilities to the class.

There is a library class TInterfaceObject, which already contains the implementation of these methods and, when inheriting from it, there is no need to implement them yourself. But since Delphi does not support multiple class inheritance, its use often only causes additional difficulties in the design and implementation of the already required functionality.

All this led to the fact that, despite all the possibilities provided by interfaces, their practical use in Delphi almost did not go beyond working with COM.

Optimized to work mainly with this technology, interfaces, or rather the functionality and architectural constraints they add without fail, do not justify themselves when solving other problems.

Therefore, many Delphi programmers are still, in fact, deprived of a powerful and flexible tool for developing application architecture.

This article is based on the questions on the forums: "How can I return a string from a DLL?", "How to transfer and return an array of records?", "How to transfer a form to a DLL?"

So that you don't waste half your life trying to figure it out, in this article I will bring everything on a silver platter.

The topics of this article have already been touched upon in this blog to varying degrees, but in this article they are collected in a bunch, the rationale is given. In short, a link to this article can be thrown at those who develop DLLs.

Important note: the article needs to be read consistently... Code examples are provided only as examples, at each step (paragraph) of the article, the code of examples is added with new details. For example, at the very beginning of the article there is no error handling, the "classic" methods are indicated (such as using GetLastError, sdtcall conventions, etc.), which are replaced with more adequate ones in the course of the article. This is done for the reason that the "new" ("unusual") constructions do not raise questions. Otherwise, for each example, you would have to insert a note of the form: "this is discussed in that paragraph below, but that is in this one." In any case, at the end of the article there is a link to the ready-made code, written taking into account everything said in the article. You can just take it and use it. And the article explains why and why. If you are not interested in "why and why" - scroll down to the conclusion and the link to download the example.

One and the most strengths The Delphi programming environment is its open architecture, thanks to which Delphi allows a kind of metaprogramming, allowing you to “program the programming environment”. This approach takes Delphi to a qualitatively new level of application development systems and allows you to embed additional tools that support almost all stages of application systems creation. Such a wide range of possibilities is opened up thanks to the concept of so-called open interfaces implemented in Delphi, which is the link between the IDE (Integrated Development Environment) and external tools.

This article focuses on the Delphi open interfaces and provides an overview of the capabilities they represent. Delphi defines six open interfaces: Tool Interface, Design Interface, Expert Interface, File Interface, Edit Interface, and Version Control Interface. It is unlikely that within the framework of this article we would be able to illuminate in detail and illustrate the capabilities of each of them. The Delphi source codes will help you to understand the issues under consideration more thoroughly, since the developers have provided them with detailed comments. Declarations of classes representing public interfaces are contained in the corresponding modules in the ... \ Delphi \ Source \ ToolsAPI directory. The Design Interface (DsgnIntf.pas module) provides tools for creating property editors and component editors.

Property and component editors are a topic worthy of a separate discussion, so we just recall that the property editor controls the behavior of the Object Inspector when trying to change the value of the corresponding property, and the component editor is activated when double click with the left mouse button on the image of the component placed on the form. Version Control Interface (VCSIntf.pas module) is intended for creating version control systems. Since version 2.0, Delphi supports the integrated version control system Intersolv PVCS, so in most cases there is no need to develop your own system. For this reason, we will also skip the Version Control Interface. File Interface (FileIntf.pas module) allows you to override the working file system of the IDE, which makes it possible to choose your own way of storing files (in Memo fields on the database server, for example). Edit Interface (the EditIntf.pas module) provides access to the source code buffer, which allows you to analyze and generate code, determine and change the cursor position in the code editor window, and control the syntax highlighting of the source text.

Special classes provide interfaces to the components placed on the form (defining the component type, getting references to parent and child components, accessing properties, passing focus, deleting, etc.), to the form itself, and to the project resource file. Edit Interface also allows you to identify the so-called modular notifiers that determine the reaction to events such as changing the source text of a module, modifying a form, renaming a component, saving, renaming or deleting a module, changing a project resource file, etc. Tool Interface (ToolIntf. pas) provides a means for developers to get general information about the state of the IDE and performing actions such as opening, saving and closing projects, and individual files, creating a module, getting information about the current project (the number of modules and forms, their names, etc.), registering file system, organization of interfaces to individual modules, etc. In addition to modular notifiers, the Tool Interface defines add-in notifiers that notify about events such as opening / closing files and projects, loading and saving the desktop project file, adding / excluding project modules, installing / uninstalling packages, compiling a project. Unlike modular notifiers, add-in notifiers allow you to cancel the execution of some events.

In addition, the Tool Interface provides a means of accessing the main menu of the Delphi IDE, allowing you to build additional items into it. Expert Interface (module ExptIntf.pas) is the basis for creating Expert Advisors - software modules embedded in the IDE to extend its functionality. An example of an expert is the Delphi Database Form Wizard, which generates a form to view and change the contents of a database table. Once you've defined the expert class, you need to make sure Delphi “knows” about our expert. To do this, it must be registered by calling the RegisterLibraryExpert procedure, passing it an instance of the expert class as a parameter. As an illustration, let's create a simple esStandard-style Expert Advisor, which, when the corresponding Delphi menu item is selected, displays a message that it is running. As you can see from the above table, the esStandard style requires six methods to be overridden:

In order for the expert to be “activated”, select the Component / Install Component ... menu item, select in the Browse dialog the module containing the expert (in our case, exmpl_01.pas), click OK, and after compiling the dclusr30.dpk package in the main Delphi menu, in the Help section, the item Simple Expert 1 should appear, when selected, the information message “Standard Expert started!” appears. Why Delphi puts the expert menu item in the Help section remains a mystery. If you do not like the fact that the menu item appears wherever Delphi, and not where you want, the following option is possible: create an expert in the add-in style, which excludes the automatic creation of the menu item, and add the menu item "manually" using the Tool Interface. This will allow you to set the location of the new item in the main menu in any way.

To add a menu item, the TIToolServices class - the basis of the Tool Interface - and the TIMainMenuIntf, TIMenuItemIntf classes that implement interfaces to the IDE's main menu and its items are used. The TIToolServices class ToolServices is instantiated by the IDE itself when it is initialized. Note that the developer is solely responsible for releasing the interfaces to the Delphi main menu and items. Along the way, let's complicate the functional load of the expert: when activating its menu item, it will issue a certificate about the name of the project opened in this moment in the environment: In this example, the centerpiece is the AddIDEMenuItem function, which adds a menu item to the Delphi IDE's main menu. As parameters, it receives the text of the new menu item, its identifier, the identifier of the item before which the new item is inserted, the symbolic representation of the key, which, together with with the Ctrl key can be used for quick access to the new item, and an event handler corresponding to the selection of a new item. We've added a new menu item to the View section before the Watches item.

Now let's get acquainted with notifiers. Let's define an add-in notifier that tracks the moments of closing / opening projects and adjusting the field storing the name accordingly active project(we will omit the implementation of the methods that have not undergone changes compared to the previous example): To implement the notifier, we have defined the TAddInNotifier class, which is a descendant of TIAddInNotifier, and overlapped the FileNotification method. The IDE will call this method every time an event occurs that the add-in notifier is able to respond to (each such event is denoted by a corresponding constant of type TFileNotification). The Expert field in the TAddInNotifier class is used for feedback with an expert (method TAddInNotifier.FileNotification). In the destructor of the expert, the registration of the notifier is removed and the notifier is destroyed. Now let's illustrate the use of modular notifiers. Let's create an add-in Expert Advisor that issues messages about each act of saving the project file (we will not present the implementation of methods already familiar to us for brevity): In this example, the add-in Expert monitors the events corresponding to the opening / closing of projects.

Each time a project is opened, a modular notifier corresponding to the project file is registered. In terms of implementation, modular notifiers are similar to add-in notifiers: we define a TModuleNotifier class that is a descendant of TIModuleNotifier and override its Notify and ComponentRenamed methods. The IDE calls the Notify method when certain events related to this module are raised; within this method the reaction to this or that event is defined. The ComponentRenamed method is called when the name of a component on a module form has changed. Please note that we do not use this method, but we must override it, otherwise when the name of the component changes, the abstract method of the base class will be called, which leads to unpredictable consequences.

Registering a modular notifier is a bit more complicated than registering an add-in notifier: first we get the module interface (TIModuleInterface), and then we register the notifier using the module interface. When the project is closed, the registration of the modular notifier is unregistered (again using TIModuleInterface) and the notifier is destroyed. Finally, we'll show you how you can determine the position of the cursor in the code editor window. Let's create an Expert Advisor that, upon selecting the appropriate menu item, would display a message containing the name of the active file and the position of the cursor in it (the implementation of only methods essential for this example is shown): To determine the position of the cursor, we must receive the following sequence of interfaces: modular interface (TIModuleInterface); code editor interface (TIEditorInterface); the interface of the module view in the editor window (TIEditView).

If the file with the source text (* .pas) is active when the expert menu item is selected, then a message is displayed containing the name of the active file and the current position of the cursor in it. If a non-pas-file is active, then the message is not displayed. The GetCurrentFile method of the TIToolServices class is used to get the name of the active file. This concludes the review of ways to use open interfaces. The CD-ROM contains the source code for all of the examples provided. The CD-ROM also contains a more complex and detailed example containing an add-in expert that allows the user to bookmark the source code of Delphi modules. A quick guide to installing and using the Bookmark Expert is contained in the bkmrks97.htm file. So, this article outlines open interfaces and provides examples of their use. Once again, we will repeat: thanks to the availability of the source code of the open interfaces, you can easily figure out the details that interest you. We hope that the variety of opportunities provided by open interfaces, will give you more than one bold and useful idea.