Some of the contents of Chapter 16 of the book of Delphi

xiaoxiao2021-04-05  296

Chapter 16 Operation Interface and Operation Logic

We have discussed in the eighth chapter in the first chapter, and the user interface is the benefit of the business logic. Such separation can be

The software architecture is more reasonable, and the structure is easy to understand, thereby enhancing the flexibility and maintainability of the software.

As I mentioned, the purpose we discussed is to find a practical method from chaos from chaos, this

Is one of the main purposes of this book. Ordered things are easy to understand, easy to understand, you can master it, master after you

It will find that the philosophy behind it is simple, thus sublimation to a higher level to feel good software structure.

Mercure.

The topic of this chapter will focus on how to discuss the client's procedures, I hope that our discussion is pendant with all software.

Help with friends.

First section separation operation interface and operation logic

How to design a friendly software operation interface is an important topic of human-computer engineering research. Easy software has a clear

The show, not only the layout is well known, but the operation intention is also a good understanding, and dealing with generous

Even the answer to you is also attached to the micro. If you write the software like this to tell you the keyword repeating error

User: "Dear, you have previously entered the number of outbound orders numbered 991028, you can't turn it again. Do you want

Check out the previous outline? ", Your software will be greatly increased. Maybe IBM OS2 is because of saying

Many users don't understand nonsense, they are abandoned by users, losing the people, and be bound by Bill Gates.

We don't intend to discuss how to dress up the software, but should talk about the beautiful interface, how should it be better?

The land structure is organized, and the user's operation command is handled.

If you have planned a preliminary mode of operation, use the menu with an icon as a tool for the user's command.

And write the process statement that completes the business processing in the Menuitem's OnClick event. Everything is good, and the business logistics

The series is also processed in the RemoteDataMoudle in the server-side, the classic three-layer architecture. But you

The boss does not like the menu, he has a unique clock on the button, so you need to change the menu to Button, then

Modern code moves to Button's onclick event, or pointing Button's onclick event to its original Menu

The ItemClick event handling process. After the software submits the user trial, the user strongly requires the software to modify the software to Microso.

FT Word 2000 interface, both menus and buttons, but also provide shortcuts for keyboards (because

Their boss is accustomed to the keyboard input method of the old program under DoS. So you have to modify the software

The interface control and adjusts the operation code again so that each command input method can be responded. At last,

After thousands of hard work, you can finalize the modification of the entire software interface.

It can be seen that different people have different hobbies and needs, they each have the habit of operating software. But they make

The same is the same, that is, the specified operation instruction is issued to your software, and the representation of this operation is used.

Software function!

In the needs of all kinds of different users, after the final purpose of all users, we should think about it carefully.

Different users use different means in order to achieve the same purpose. Oh! The original purpose and means are two things,

Only everyone reaches the same purpose in different means.

Therefore, we should separate the operation interface with the operational logic, and should first distinguish the means and purpose, and then will

The purpose is linked. In this way, changes to the operation interface will not affect the operational logic, the means is the means, the purpose is

of. In order to achieve your goal, you can don't ask for means, this is the truth! Said here, maybe someone will say: This truth is understanding. So, if you develop software, more

Using these shallow truths, it is not difficult to design a simple and practical software structure.

What is the benefits of operating interface and operational logic?

1. Easy to understand

When you write a business operation code, you don't care about the interface mode of operation, while in beautifying your software, only

Consider the aesthetics of the interface. The appearance is the appearance, the heart is inner, only you know, the beautiful interface of the appearance is connected

Exquisite to the outstanding operation code, the table is like one. Your friends can appreciate the appearance of beautiful software, and it is easy to read.

Your heart.

2. Easy to maintain

Regardless of the popular interface of the future, it is a new homepage model or Outlook's classic side. You can only repair

Change the part of the interface to meet the requirements. You can also complete your software thoroughly change your face, with a new face

Now. Even the unique skills that can not be passed down from the famous male female in the Sichuan opera. But software is still software,

The inherent functional logic of the software has not changed. However, because of the habit of being happy, chasing fashion fashion

It will make the pocket of the bosses of the software companies more and more drums.

3. Extensible

A new breakthrough in human-computer engineering will provide more command input methods for software users. Today, voice

Identification technology has gradually commercialized. You can already use the voice recognition support module provided by IBM ViaVoice.

Can identify controls for voice commands. Add such controls into your software and operate with your previously written operation logic

Your software is like a long ears, with a aura, you can listen to your story. I also believe that there will always be one day.

Write a control that can read your expression, then the software will be able to touch you according to your emotions.

care. But the soul of the software is still the original operational logic code!

4. Suitable for large-scale software development

Large-scale software development and speaking work cooperation, each other. If you are the boss of a software company, then, in the system

Analytical designers completed software design, you can find a batch of fashion designers to design beautiful sexy boundaries for your software.

Face, please refer to the encoded programmer to write operational logic. And you can easily manage and control the quality of each process,

And the responsibility is clear.

Although the end of the end of the earth has blown, we have to go back to our theme. Separation of operating interfaces and operational logic,

What methods and principles should I follow?

First, you should summarize the functionality of the current module to provide a clear operation command set to the user. Also

It is to say that the design can be provided to the user, which is a list of available commands for the old-fashioned command line program. remember

These commands are set to be the purpose of the user's execution operation.

Then, in each of the commands set according to the command, the operation logic code is planned, and the operation is prepared according to the general principles of the program.

Logic code. For the general principles of writing procedures, please refer to "First Love Delphi" book.

Finally, to remind a little, the operational command is sometimes controlled by the program. Some programmers are in order to achieve

The user is prohibited in a state in a certain state, and the specified operation command is prohibited, try to control the properties of command controls such as menus, buttons.

, Blocking and pressing all controls of all executable commands. However, you want to prohibit commands, not controls!

Below we will discuss the separation operation interface and operational logic, Delphi provides us with a valuable east

West, TAACTIONLIST and TACTION.

Section 2 use TACTIONLIST and TACTION

The meaning of the word "action" is behavior, action or action. TACTION is abstracting the user wants to perform actions or execution of acts, operations or execution of the behavior of the software interface, and TACTIONLIST describes the list of commands. you can

To add a TACTIONLIST component to your Form, Frame or DataModule, double-click this component to be defined

The TACTION objects needed.

Designers and engineers to create Delphi buildings, for most command controls (such as TButton, Tmenuitem, etc.

Wait, designed an action attribute, and often happen to appear in the first item in the Object Inspecter window property page.

On, this can be seen in their hard work. But no matter what, they provide us with a simple way to live

The Action property of the control is associated with the TAction object defined in the TActionList component.

Since the operation logic code written in the Onexecute event of the TACTION object can be automatically associated command control

Call, therefore, replace the type of command control, no modification or adjustment operation logic code. This will use the operating interface.

The surface is separated from the operational logic.

If you want to prohibit users from performing some actions in some states, you can set the enabled properties of the related TACTION objects.

For False, the relevant command control will be freezed, which turns the face, which turns on the grayish face, and

No matter, he is the end of your life.

Thanks again to the master of Delphi, they did everything for us after they were in the station, and they also put their nine yin.

Put in the Source / Vcl / ActNList.Pas unit.

Since there are masters of Jiuyin Zhenjing, we should take cultivation and enhance our internal strength.

First, in the ActNList unit, TACTIONLIST is declared:

TactionList = Class (TCUSTOMACTIONLIST)

Published

Property images;

Property onchange;

Property onexecute;

Property OnUpdate;

END;

TACTIONList only published some properties and events of TCUSTOMActionList. In fact, TACTIONLIST is used

Failed to install TACTION and provide a way to manage TACTION. Detailed usage about TACTIONLIST, we

The discussion will be discussed in the subsequent TactionManager control.

Let's take a look at the discussion of TAAP:

Taction = Class (TCUSTOMACTION)

Published

Property Caption;

Property checked;

Property enabled;

Property helpContext;

Property Hint;

Property ImageIndex;

Property Shortcut;

Property visible;

Property onexecute;

Property OnHint;

Property OnUpdate;

END;

TACTION is inherited from the TCUSTomAction class, as in front, but only some of the characteristics of the parent class. I

I don't want to interpret the original code of TAACTION, I believe that friends who have read "First Love Delphi" can

Enough to interpret these code. I just want to discuss these features published to us, what features can we provide.

Since there are still some characteristics, it is published in the parent class of TAction. It will also talk together in the discussion, but some don't

Important features are no longer nonsense.

CAPTION Attribute: Fill in this property, you can use a short title to explain the meaning of the command operation to the user. This property will automatically update the CAPTION property of the related command control, so the CAPTION property of the button and menu is input.

Category property: The category of the operation command is mainly to facilitate your classification to manage your operation command set. This property

It is published in TcontainedAction in Taction, and then developed in our subsequent TactionManager control

In the item, you will see how this property manages the operation command.

Enabled Property: Control whether the command operation can be executed, which can automatically control whether the associated command control is allowed. block

Command control should start from here.

ImageIndex Properties: Indicates an icon index of an operation command, contacts the images of TACTIONLIST. There is a life of icon

Let the control can enjoy his grace.

Shortcut Properties: Use the shortcuts of the operation command with the keyboard to give the gospel to the people who have a keyboard operation.

Visible Attribute: Control Enabled allows the command control to make gray, control this property allows the command control disappears

Before the households. Note, although the command control disappears, the user can still send an operation command through the shortcut, and enabled

Can really block the command.

Onexecute event: You can write an operation logic code in this event, and when the user triggers the relevant command control,

Start operation logic code for this event.

Other features view Delphi's online help!

Before you first understand TAAActionList and TACTION, we will start practice. The following PrettyPoem program demonstrates

The basic usage of TACTIONLIST and TACTION is very simple. If you don't want to waste time, you can jump directly to the back MU

LTIFACE program to see how to perform the absorbent of Sichuan Opera - change face.

You can find the original code of this program in the CD attached to the book.

File prettypoem.dpr

PROGRAM PRETTYPOEM;

Uses

Forms,

Main in 'main.pas' {fmain};

{$ R * .res}

Begin

Application.INITIALIZE;

Application.createform (TFMain, Fmain);

Application.run;

End.

Document main.pas

Unit main;

Interface

Uses

Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs,

Menus, Actnlist, Comctrls, Toolwin, Stdctrls, Imglist;

Type

Tfmain = Class (TFORM)

Mainmenu: TmainMenu;

ActionList: TAActionList;

ActGucheng: TACTION;

Actximurong: TAACTION;

Actliqingzhao: TACTION;

ACTSUSHI: TACTION;

N1: tMenuitem;

N2: TMENUITEM;

N3: TMENUITEM;

N4: TMENUITEM;

N5: TMENUITEM;

N6: TMENUITEM;

Toolbar1: Ttoolbar;

Toolbutton1: Ttoolbutton;

Toolbutton2: TtoolButton;

Toolbutton3: ttoolbutton;

Toolbutton4: TtoolButton;

Button1: tbutton;

Button2: tbutton;

Button3: tbutton;

Button4: tbutton;

CBDISABLIQINGZHAO: TCHECKBOX; ACTDISABLIQINGZHAO: TACTION

ACTHIDELIQINGZHAO: TACTION;

Cbhideliqingzhao: Tcheckbox;

ImageList: timagelist;

Labpoem: TLABEL;

Labshadow: TLABEL;

Procedure actguchengexecute (sender: TOBJECT);

Procedure actximurongexecute (sender: TOBJECT);

Procedure actdisableliqingzhaoexecute (sender: TOBJECT);

Procedure ACTHIDELIQINGZHAOEXECUTE (Sender: TOBJECT);

Procedure actsushiexecute (sender: TOBJECT);

Procedure Actliqingzhaoexecute (Sender: TOBJECT);

Private

{Private Declarations}

Procedure RecitePoem (Poem: string);

public

{Public declarations}

END;

VAR

Fmain: tfmain;

IMPLEMENTATION

{$ R * .dfm}

Procedure tfmain.recitepoem (poem: string);

Begin

Labpoem.caption: = POEM;

Labshadow.caption: = POEM;

END;

Procedure tfmain.actguchengexecute (sender: TOBJECT);

Begin

RecitePoem ('Night Give me black eyes I use her to find light ");

END;

Procedure tfmain.actximurongexecute (sender: TOBJECT);

Begin

RecitePoem ('Xi water is eager to flow to the sea and the wave is eager to re-return the land');

END;

Procedure tfmain.actsushiexecute (sender: TOBJECT);

Begin

RecitePoem ('people have joys and sorrows with yin and sunny ");

END;

Procedure tfmain.actliqingzhaoexecute (sender: TOBJECT);

Begin

Recitepoem ('sickness is also a ghost ";

END;

Procedure tfmain.actdisableliqingzhaoexecute (sender: TOBJECT);

Begin

Actliqingzhao.Enabled: = not cbdisableliqingzhao.checked;

END;

Procedure tfmain.acthideliqingzhaoexecute (sender: TOBJECT);

Begin

Actliqingzhao.visible: = not cbhideliqingzhao.checked;

END;

End.

Document main.dfm

Object Fmain: Tfmain

LEFT = 192

TOP = 107

Width = 442

HEIGHT = 195

Bordericons = [bisystemmenu, Biminimize]

CAPTION = 'talking about ancient Chinese

Color = CLBTNFACE

Font.charset = GB2312_CHARSET

Font.color = CLWINDOWTEXT

Font.height = -12font.name = 'Song Body'

Font.style = []

Menu = mainmenu

OldcreateOrder = FALSE

Pixelsperinch = 96

TextHeight = 12

Object Labshadow: TLABEL

LEFT = 17

TOP = 41

Width = 380

HEIGHT = 20

CAPTION = 'Ancient and modern poetry names appreciate, please choose your favorite poet. '

Font.charset = GB2312_CHARSET

Font.color = CLBLACK

Font.height = -20

Font.name = 'Lishu'

Font.style = []

ParentFont = FALSE

TRANSPARENT = TRUE

end

Object Labpoem: TLABEL

LEFT = 16

TOP = 40

Width = 380

HEIGHT = 20

CAPTION = 'Ancient and modern poetry names appreciate, please choose your favorite poet. '

Font.charset = GB2312_CHARSET

Font.color = CLBLUE

Font.height = -20

Font.name = 'Lishu'

Font.style = []

ParentFont = FALSE

TRANSPARENT = TRUE

end

Object Toolbar1: Ttoolbar

LEFT = 0

TOP = 0

Width = 434

HEIGHT = 26

AutoSize = True

ButtonWidth = 63

CAPTION = 'Toolbar'

EdgeBorders = [EBTOP, EBBOTTOM]

Flat = true

Images = imagelist

List = TRUE

Showcaptions = true

Taborder = 0

Object Toolbutton1: TtoolButton

LEFT = 0

TOP = 0

Action = actgucheng

end

Object Toolbutton2: Ttoolbutton

LEFT = 63

TOP = 0

Action = actximurong

end

Object Toolbutton3: TtoolButton

LEFT = 126

TOP = 0

Action = ACTSUSHI

end

Object Toolbutton4: TtoolButton

LEFT = 189

TOP = 0

Action = ACTLIQINGZHAO

end

end

Object Button1: TButton

LEFT = 12

TOP = 80

Width = 75

HEIGHT = 25

Action = actgucheng

Taborder = 1

end

Object Button2: TButton

LEFT = 116

TOP = 80

Width = 75

HEIGHT = 25

Action = actximurong

Taborder = 2nd

Object Button3: TButton

LEFT = 12

TOP = 112

Width = 75

HEIGHT = 25

Action = ACTSUSHI

Taborder = 3

end

Object Button4: TButton

LEFT = 116

TOP = 112

Width = 75

HEIGHT = 25

Action = ACTLIQINGZHAO

Taborder = 4

end

Object Cbdisableliqingzhao: Tcheckbox

LEFT = 232

TOP = 116

Width = 81

HEIGHT = 17

Action = actdisableliqingzhao

Taborder = 5

end

Object Cbhideliqingzhao: Tcheckbox

LEFT = 328

TOP = 116

Width = 81

HEIGHT = 17

Action = ACTHIDELIQINGZHAO

Taborder = 6

end

Object Mainmenu: TmainMenu

Images = imagelist

LEFT = 332

TOP = 4

Object N1: TMenuItem

Caption = 'modern feelings'

Object N2: TMenuItem

Action = actgucheng

end

Object N3: TMenuItem

Action = actximurong

end

end

Object N4: TMenuItem

CAPTION = 'Classical style'

Object N5: TMenuItem

Action = ACTSUSHI

end

Object N6: TMenuItem

Action = ACTLIQINGZHAO

end

end

end

Object ActionList: TACTIONLIST: TAACTIONLIST

Images = imagelist

LEFT = 360

TOP = 4

Object actgucheng: TAACTION

Category = 'modern feelings'

CAPTION = 'Gu City'

ImageIndex = 0

Shortcut = 16455

Onexecute = actguchengexecute

end

Object actximurong: TACTION

Category = 'modern feelings'

CAPTION = 'Cham Murong'

ImageIndex = 1

Shortcut = 16472

Onexecute = actximurongexecute

end

Object ACTSUSHI: TAACTION

Category = 'Classical style'

CAPTION = 'Su Shi'

ImageIndex = 2

Shortcut = 16467

Onexecute = ACTSUSHIEXECUTE

end

Object Actliqingzhao: TACTION

Category = 'Classical style'

CAPTION = 'Li Qingzhao'

ImageIndex = 3

Shortcut = 16460

Onexecute = actliqingzhaoexecutendeendeend

Object actdisableliqingzhao: TACTION

Category = 'control'

Caption = 'prohibits Li Qingzhao'

Onexecute = actdisableliqingzhaoexecute

end

Object ACTHIDELIQINGZHAO: TACTION

Category = 'control'

Caption = 'Hide Li Qingzhao'

Onexecute = ACTHIDELIQINGZHAOEXECUTE

end

end

Object ImageList: Timagelist

LEFT = 388

TOP = 4

Bitmap = {......}

转载请注明原文地址:https://www.9cbs.com/read-132065.html

New Post(0)