Creation of the koristuvach interface. Recommendations for how to create client interfaces in Delphi What is the interface in Delphi

Object-oriented programming (OOP), in addition to the class concept, also conveys fundamental concepts to the interface.

What is the interface and what are the features of working with it in the Delphi program?

Interface is a semantic and syntactic structure in program code that is used in the specification of services that are provided by a class or component (Wikipedia).

In essence, the interface signifies a transfer of power between the methods that must be victorious when working with the class, which interface implements, as well as their signature (name, data type, parameters that are received (for procedures and functions) ій) і etc.). Thus, a class that implements another interface can necessarily implement all its components. Moreover, in the same way, as in the new description.

Interfaces often align with abstract classes, but despite all the similarities, the alignment is not entirely correct. Abstract classes, at a minimum, control the visibility of members. At the same time, the visibility area is not assigned for interfaces.

Interfaces allow you to create a structured architecture that unifies access to other functionality, and also eliminates a number of problems associated with the decline of classes (interfaces can also settle down one way).

To introduce the Delphi interface, use the interface keyword. The keyword is a keyword that designates the section of the module to which calls can be accessed (between keywords interface and implementation). However, when the interface is deafened, a different syntax is introduced, similar to class declaring.

Delphi/Pascal

IMyNewInterface = interface procedure InterfaceProc;

end;

IMyNewInterface =interface

procedure InterfaceProc;

end;

On the right is that Delphi interfaces were initially introduced to support COM technology. Therefore, the IInterface interface, which in Delphi is the ancestor of all other interfaces (a kind of analogue of TObject), already contains three basic methods of working with this technology: QueryInterface, _AddRef, _Release. As a result, whenever a class implements any interface, it is obligated to implement its methods. Please note that this class is not intended for robot COM.

As a result of the peculiarity of the IInterface interface, Delphi has a variety of interfaces, in most cases, which lead to the addition of distinctly non-victory capabilities to the class.

There is a library class TInterfaceObject, which accommodates the implementation of these methods and, as a result, the need to implement them independently disappears. However, since Delphi does not support a significant decline in class, its stagnation often leads to additional complexity in the design and implementation of functionality that is no longer necessary.

All this has led to the point that, regardless of all the possibilities that one hopes for interfaces, they practical zastosuvannya Delphi didn't work with COM.

Being optimized for the work of the main rank of technology, interfaces, and more precisely, the addition of functionality and architecture by them in a comprehensive manner, with the highest other requirements, one cannot fulfill oneself.

Therefore, there are a lot of Delphi programs up to now, in fact, reducing the effort and little instrument for the development of software architecture.

only for the result

zhorstke dotrimannya terms

Serendipity

Vikonanny to the project

technical tips for gifts

Programming, additional consultation with 1C

How we do it

1. We discuss the problem by phone. If obvious remote access- Show it on the screen of your computer.

2. We estimate the work in rubles, because the project is great, because it takes about a few years.

3. We are choosing a robot.

4. You take over the work from your program, if there are shortcomings, we correct them.

5. We put up a rack, and you will cry.

Variety works

1. All robots are divided into 3 categories: consultation, updating the standard configuration, development and programming of a new call, processing, buttons, etc.

3. For work, technical specifications with a description and performance of the work are developed in advance for 10 years. Work begins after completion of the task from you.

Technical support

1. If you detect any problems in previously adopted robots, over a period of 3 months, we correct them without harm.

2. For regular clients, any shortcomings in our robots will be corrected without cost.

Programs for managing your business.

Add 1C:Enterprise

We are an official dealer of 1C, you can get a variety of software products and licenses from us. After purchasing the “box,” we will help you set up the program, provide consultation and detailed basic setup.

  • Accounting appearance
  • Automation for the store
  • Wholesale sales
  • Installation assistance cob adjusted included in the package!
  • Fine-tuning the configuration according to the needs of the controller, developing new modules on a daily basis necessary functions in the standard configuration.
1s Accounting 1C: Trade management 1C:Rozdrib 1C: Salary and Personnel Management
Price 3300 rub. Price 6700 rub. Price 3300 rub. 7400 rub.

Server name.

Instantly set up the server + 1C.

No server? It doesn’t matter, we’ll select and quickly set up the server at “Khmara”. For a small fee you will get a very reliable solution.

  • Availability 24\7
  • There is no need to trim with moisture system administrator(The savings cover the cost of your server).
  • Shvidka has set up and installed 1C on the server, after 3 days you will already have a working system.
  • Whether or not you can move to local server because decisions do not rule.

SMS from your 1C

Do you want your clients to find out about promotions and discounts as soon as possible? Clients won’t turn around? Set up SMS sending directly from 1C!

Our company can style terms set up sending SMS to your clients directly from 1C. Please see what can be automated:

  • Payments for purchases and bonuses are issued immediately after the final purchase.
  • Declaration of bonuses on the card as a gift on National Day before another significant or holy day.
  • Information about the storage of goods in the warehouse.
  • The term of gift bonuses has ended.
  • Information about the need to prepay and reserve the goods.
  • Addresses with details of directions to the store, telephone numbers.
  • I etc.

Customization in 1C can be done by our specialists or your own specialists. You can find out about the tariffs on the SMS tariffs page.

  • Guaranteed SMS delivery, extra money is charged per SMS.
  • Okrema tariffs for skin SMS.
  • Replenish the balance in different ways.
  • Review the history of all SMS messages sent at any time.
  • The contactor's name replaces the digital number of the contacted phone number.

The article was written based on the results of the analysis of programs written by young developers of our group.

We correctly arrange the sequence of component mixing

A lot of people, especially those who previously worked with DOS, have to switch between input fields not with a mouse, but with the help of an additional keyboard using the Tab key. Before that, it’s so rich, you can’t see the skin field as a target. Therefore, the order of mixing the components may be set correctly. There are both components in the middle of all container components (panels, GroupBoxes and the like), as well as the container components themselves, which are in the form of a decal.

The order of mixing of components in the middle of the container is determined by the power of the TabOrder. The first is the active component, each with a TabOrder of 0, the other with 1, until all components are sorted out. In addition, the component has the power of TabStop, which indicates that the component releases focus when the Tab key is pressed. If you need to prevent interference on any component, set TabStop = false. In this case, you can switch to this component only after further instructions.

Problems occur when players who have started to mix the song key in one program, follow the switch and continue to use it in others. Often this is not the case with 1C users, where you can use the Enter key to navigate through the entry fields. Well, ladies, our programs have such power to ask for anything. We set the KeyPreview power of the form to true and write the description for OnKeyPress:

Procedure TForm1.FormKeyPress (Sender: TObject; var Key: Char);
begin
if ord(key)=vk_Return then
Form1.SelectNext(PriemForm.ActiveControl, true, true);
end;

This sorter will ensure that you navigate through the form elements when you press Enter. Please note that this method works with buttons, because Pressing Enter on the drive button before it presses, while pressing Tab transfers the focus of inputting the next input to the component.

Standard buttons

These systems also make a loud sound, and in the dialog boxes of add-ons, you can usually use the Enter key to confirm your choice, and use the Esc key to click. Let's not be disappointed with them in our programs, because it's even easier to earn money. For a button that responds to Enter, set the Default power to true. For a button that responds to Esc, set the Cancel power to true. And that's all.

So no

Mustache dialog boxes In order to ask for the actions of the customer, you must use two buttons: confirm the action and cancel the action (So/Nor, Save/Save, etc.). Views can be accessed by closing the window using the [X] button next to the window title. It is unacceptable that there is only one button to confirm the action, and for the view it is necessary to close the window with the [X] button at the header or the possibility of view disappears during the day. The woman is confused, calling out a more logical question: how can you be convinced?

Also, don’t forget about what was said above in the paragraph “Buttons for cleaning”.

All dialog boxes will appear in the center of the screen

The center, and not there, they were created in the design mode. First of all, first and foremost, it automatically addresses the problem of different screen resolutions among different home users.

The problem is that the dialogue window is not modal, and the results of the client’s work in this window immediately require changes in the main window (for example, filtering a set of data, repainting graphs, etc.).

There is no harm in adjusting the size of the screen

Not at any time. It’s inappropriate if some of you are allowed to climb behind the screen. Qia vimoga stay within the permission of the screen in koristuvach, then. excuses like “Don’t stop supplying more separate buildings” will not work.

Correct change of dimensions of window elements

Window elements must correctly change their sizes or move when changing window sizes, maximizing the window, and updating the window after maximizing.

Everything is visible right away

Changing the size of the window will inevitably lead to the loss of window elements and will inevitably lead to the appearance of scrollers on the window itself. You can delimit the minimum dimensions of the window in such a way that all elements are visible and accessible. Since it is not possible to arrange components in such a way that they are all visible in the window, you can use bookmarks (like PageControl) to divide components into groups. As long as the screen is clear, you cannot skip the window.

Hint through, hide forever

For buttons, especially on toolbars (such as ToolBars), it is necessary to set a hint so that it is clear in the future that another button is needed.

Kolyorova gama

It’s not easy to mix up the components on the form for all the colors of the fun. This tires the eyes and increases the respect of the kristuvach. It doesn't look "cool". The color scheme is used in this case when it is necessary to turn the attention of the painter to the song element or the song part of the window. For example, paint a record with a light worm color for those that have proofs or, for example, a light green color for a record that has been verified successfully.

Visnovok

And even more good method, which allows you to find out some of the programs in the app and the zocrema interface. It’s simple: find a professional in your place and throughout the day try to work the way he works. Even better, if your correspondent is within reach (for example, he works with the same organization). So, sit down with him, or rather, instead of him, and try to work for him. Enter data, change it, output information, etc. If you don’t know how to earn money correctly, feed your moneymaker. Perform not just one or two operations of the same type, as in the setup mode, but 20-30, or even more different operations, in a different order. Forget to enter it or you will enter it incorrectly and you will be surprised how the program reacts. You will quickly improve the weak parts of your program.

The author of the article has automated the work of the primary commission at VNZ, and in the first year launched programs for 3-4 years per day, spending 3-4 years a day with the primary commission, registering applicants, remembering their personal data and providing them with information. This is about the development of experiences. And in Reshta working hours correcting the amends and shortcomings. Believe it or not, there are practically no problems with the coming fate. The same was true for the promotion of the personnel module.

In this manner, remember the handiness of the robot for handymen. May they find it easy and pleasant to work with your programs.

I have a problem with a Delphi class and C++ code. delphi dll demo, which exports a function that rotates an object.
My Delphi Dll code looks like this:

Library DelphiTest; // uses part.... type IMyObject = interface procedure DoThis(n: Integer); function DoThat: PWideChar; end; TMyObject = class(TInterfacedObject,IMyObject) procedure DoThis(n: Integer); function DoThat: PChar; end; // TMyObject implementation go here ... procedure TMyObject.DoThis(n: Integer); begins showmessage("You will find this method with "+intToStr(n) +"parameter"); end; function TMyObject.DoThat: PChar; start showmessage("You will find the DoThat function"); Result:= Pchar("Hello im Dothat"); end;

// Export DLL function:

Function CreateMyObject: IMyObject; stdcall;export; var txt: TextFile; begin AssignFile(txt,"C:\log.log"); Reset(txt); Writeln(txt, "hello"); Result:= TMyObject.Create; end; exports CreateMyObject;

In my C++ project, I named the IMyObject interface as follows:

Class IMyObject (public: IMyObject(); virtual ~IMyObject(); virtual void DoThis(int n) = 0; virtual char* DoThat() = 0; );

And my main function is like this:

Typedef IMyObject* (__stdcall *CreateFn)(); int main() ( HMODULE hLib; hLib = LoadLibrary(L"DelphiTest.dll"); assert(hLib != NULL); // pass !! CreateFn pfnCreate; pfnCreate = (CreateFn)GetProcAddress((HINSTANCE)hLi "); if (pfnCreate == NULL) ( DWORD errc = GetLastError(); printf("%u\n", errc); // it gets error 127 ) else( printf("success load\n"); ) IMyObject* objptr = pfnCreate(); objptr->DoThis(5);

Whose application I'm trying to get rid of when I'm trying to get rid of access to the exported function. pardons in a row:
IMyObject* objptr = pfnCreate();

You can tell me what's wrong with my butt.
And, if possible, there is some kind of working method for accessing the Delphi class (DLL) with C++ code.

Decision

The first problem is a call for methods. The Delphi interface is a wikilist register, which is specific to Delphi wikis. Vikoristannya stdcall For example, for interface methods.

There's a problem with C++. Your C++ interface is guilty of being like IUnknown. In addition, it is not guilty of invalidating a constructor or destructor.

Moreover, your Delphi code is exported by PWideChar, which is not mapped to char* , but mapped to wchar_t* .

Looking further, turning PChar, this is obviously working because your implementation turns the literal. If you have more serious code, you will probably want to create a row that is dynamically positioned, and at this point your design will be short-changed.

Recall that it is necessary to create the file completely system disk You must be an administrator with elevated rights. This is also another potential point of the mind.

I realize that there are other blessings, and that’s all I know before.

gateway interface The buyer is reduced to choosing from a palette of components of the necessary robots and programs, Delphi components, services interface management, as well as interface displaying information and transferring it to the Form with further layout.

The user interface that you create must use standard, user-friendly elements and ensure maximum user-friendliness. All this is ultimately determined by the following criterion: the effectiveness of the interface - maximum results with minimal effort.
Principles of creating a manual interface for viewing. Like yourself sacred principles When the interfaces are created, three main provisions can be seen:

  1. The program is responsible for helping visonati zavdannya, and not becoming qim zavdannya.
  2. When working with a program, the professional is not guilty of making himself look like a fool.
  3. The program must act in such a way that the koristuvach does not fool the computer.
First principle- This is what is called the “insight” of the interface. The user interface should be intuitive, easy to learn, and not cause problems for the user such as inconveniences during the work process. Use standard, unadorned components, assemble the original ones, selected by similar control programs, and you will achieve the design criteria first principle.

Another principle lies in the hands of the wealthy intellectuals. It is clear to me that often self-employed people are not only reluctant to work on a computer, but are simply afraid to do it on their own. Therefore, the customer interface should be as user-friendly as possible.
Moreover, the fears of the koristuvachs are most often justified, and even the performance of the programs and the computer itself is not comparable to the performance, for example, created by rich databases. In addition, the programmer, with the created interface of the debt collector, will now implement the program “protection from foolishness” - in the event of incorrect actions and the input of incorrect data by the customer. All programs need to be squashed with such a zakhist, it is necessary to destroy it, and as a result, the robot program will guess the famous “click to the left, click to the right goes in the same direction”! And those that the program creates as a major problem begin to create problems themselves.
For the rest of the world another principle There is no need to allow the program to “correct” the actions of the koristuvach and indicate what is happening to you, which limits your narrow frame. Also, be careful not to over-commit to the information and hints provided, especially the interactive ones, which involve the user in a robotic manner. And better yet, let us know the possibility of turning on hints.

Third principle The aim is to create the program with the greatest possible rationality. Unrespectful on Swedish rose computer technology However, the widest range of programs can be called intellectually the kind that create a piece of intelligence. The stinks are admired by robots that display dialogue boxes with bad food on the screen, which scream wonder in the simplest situations. As a result, the owners will cry out in their hearts: “That’s a stupid machine!”
I particularly appreciate the need for regular nutrition for almost everyone text editors about those who do not save changes to the text, although the original and final text are not separated by a symbol. So, I just typed, and then turned everything back, it’s impossible to get rid of it! I have to check that I haven’t zipped anything.

Make sure to follow these rules:

Standard interface elements
Vickory the standard components for this interface element. Having established your program, the teacher will not wait an hour to get to know you, but will immediately start working - this is one of the signs of a professionally developed program.
Small palette of tools
Try to vikorize not too many different components. And of course, vikorista here in one place one standard component, in a similar manner also put it together.
The same position between the elements of the keruban
Rearrange the interface elements on a new level between each other. Scattered components create the appearance of an unprofessionally prepared product. And finally, the careful placement on the Form of buttons, switches, proportions and other components that form the interface is a sign of clear work.
TabOrder. "Correct" order
TabOrder- this is the order of moving the on-screen cursor with the help of elements when pressing a key Tab. In a correctly written program, the cursor moves, following the logic of the robot working with the program. When created by a program, the program often changes components, removes some, and adds others as needed. As a result, in the finished program the cursor jumps chaotically behind the Form. After completing the program, do not forget to tune in TabOrder.
Choose fonts
Just let the font be calm. Tasks for converting Delphi fonts are suitable for any system on which your program can run. Use bold font only to show important elements. Zastosuvannya italics and especially armchair, Such a koristuvach can be mistaken for hyperbole - a vile tone.
Select questions
Because there is a lack of colors for interface elements, just like with fonts, it’s better to fill them with standard ones. Delphi uses the Windows system palette, and the user, having changed it, can easily customize the colors to suit himself.
Alternative control
A professionally developed program gives mother the ability to work not only with the mouse, but also with the keyboard. It is not to blame for the functions that are available to the viconnian less than the misha (painting in graphic editors don’t get insured!). For functions that are the most used, you should transfer hotkeys for their quick click.
Target the interface
If there are specific elements of the customer interface, then the interaction between the customer and the program lies in:
  • type of control element of the task associated with it;
  • rules by which the control element functions.
    On this page you can see the rules for creating certain elements of the interface.
And now I want to show you what tools Delphi uses to manage components on the Form, their mutual placement and the behavior of the cursor when pressing a key Tab.

In order to clearly blend one of the components in the correct order, from the beginning you need to see them. You can simply circle the area on the Form with a bear to indicate the selected components. Abo, calm down" Shift", use the same bear to indicate the skin component that is visible. Repeatedly click the bear on the visible component (while pressing " Shift") takes away from the new vision.

These components can be processed as a single whole - transferred to the form, assigned values ​​to new authorities, copied (for installation, for example, on another form), and then deleted.

Now click right button one of the components at a time, and select from the “floppy” menu Position -> Align... Appear at the end of the dialog, which allows you to adjust the position of the group components horizontally and vertically. For example, we need to align our two buttons with the left edge and create them so that there is still a vertical alignment between them. For whom are the radio buttons visible? Horizontal: Left sidesі Vertical: Space equally.

Vibrated item Center, we move the components so that their centers will be moved on the same line horizontally or vertically, and the point Center in window moves components to the center of the window, either horizontally or vertically.

I have a menu row Tab O rder... causes a dialog box to appear that allows the cursor to move interface elements while pressing a key Tab. At the moment the Form appears on the screen, the cursor is, of course, on the component that is located in the first row of the dialog window. And then move down the list. On the dialog box, two blue arrows “up” and “down” indicate the positions of the visible component. See the required component, use the arrows to move to the required entry in the list, and so on.

When selecting a menu item Control -> This is a submenu that consists of two items:

  • Bring to Front
  • Send to Back
These component methods are available programmatically. Button1.SendToBack moves the button to the “background”, and Button1.BringToFront- To the “foreground”. If one component is placed above another, these methods can be used to replace them. The problems in which this may be blocked are obvious.