Home > Back-end >  Consult at design time, automatically add multiple identical control approach
Consult at design time, automatically add multiple identical control approach

Time:09-24

Your colleagues a happy New Year!!!!!!

The younger brother to achieve such an idea, design in Delphi, I want to put multiple controls, same the attribute set is basic and same, different only such as name, such as binding field is different, how to implement the placement of these controls, a rather than one by one to add, one by one to modify properties

I now think of is added in the pas and DFM code respectively corresponding code, there are more advanced methods?

CodePudding user response:

Copy and paste will not?

CodePudding user response:

1, usually by copy and paste,
2, can advance to do a window, there are a number of controls, when open the window of pas files, through the mouse choose among a number of controls, copy, paste into your window,

CodePudding user response:

Copy and paste finished wouldn't have changed my name? You don't have to set properties?? Can use it directly???

CodePudding user response:

Don't want to copy and paste it in the code dynamically generated control good, write a loop added directly

CodePudding user response:

This kind of?

This is my platform function, are generally used to modify properties of alternate field or create alternate field
DELPHI should have this kind of similar to a third party

CodePudding user response:

reference 5 floor lsh341999 reply:
this?

This is my platform function, are generally used to modify properties of alternate field or create alternate field
DELPHI should have this kind of similar to a third party.

Hello, this is useful to me, can you tell me the name of this tools?
I have only cnpack, inside like this function without you

CodePudding user response:

reference 4 floor wuweifenfang response:
don't want to copy and paste it in the code dynamically generated control good, write a loop directly add

Is not just a matter of dynamically generated, and different attribute set, events

CodePudding user response:

Lazy is not solve problems

A software like programmers children

A shit a urine, slowly yards out

You can't eat hot bean curd, slowly come

CodePudding user response:

The following recurrence unintelligible dongdong:

Sorry is what others write! I do not know whether useful!
As to save the file, a custom file formats, such as ini!
Sender: ZHJJS (HHH), letter area: Visual
Mark: Delphi dynamic DFM file application (1)
Transmitting station: central China network center (Fri Dec 13 22:33:45 1996)

Dynamic DFM overview file
1.Dynamic DFM file is relative to the static DFM, the so-called static DFM file refers to the Delphi development environment
Form in the design documents, the form of the design process is the process of compiling process, therefore, dynamic DFM file is
Generated in the program is running process or access the DFM files,
Dynamic DFM files to create and use the following two kind of situations:
Low in the process of the program is run by the Create method dynamically generated form or parts, then dynamically generated other department
An insert which generate DFM files
Generate DFM in Delphi development environment, design file, and then use DFM file access function, or use the Str
Eam and Filer object, the method of DFM file read into memory, processing, and finally in the disk

Generated by conventional methods of Delphi form design of DFM file of specified at the start of the program runs the
Structure, because in the process of form design, each part in the program in the form of object statement defines the components become
Amount, the fixed structure while convenient application, but at the expense of the flexibility,
In Delphi applications sometimes need to establish and control during the process of running, and then insert the control another department
Pieces, such as:

Procedure TForm1. Button1Click (Sender: Tobject);
Var
Ctrl: TControl
The begin
Ctrl:=TEdit the Create (Self);
Ctrl. Top:=100;
Ctrl. Left:=100;
Ctrl. Width:=150;
Ctrl. Height:=20;
InsertControl (Ctrl);
end;

Dynamic insert control has the advantage of can at any time, any place to insert any number of any type of control
System, because the application requirements in many cases is only know that in the program is running, so the dynamic insert control will
Very important, and in many cases, the need to keep the interface elements, call again for another program, such as application
The state of the system and keep the program interface customization and the preservation of the dialog box, etc., then generate dynamic DFM file is the best choose
Choose,
Dynamic insert control deficiency is in front of the insert control, cannot see visually control the size, style, a
Etc, also is the process of dynamic insert control is visual, but can be by means of static DFM file visualization
Design, dynamic DFM file that is generated and used the second method, which is before the application is running, in Delp
Hi development environment, use the visual development tools required to design the style of the window or components, in DFM file,
After the application is running in the process, DFM file read into memory, the Stream object of Delphi and Filer object reading
Take DFM file, can automatically create the parts in accordance with the contents of DFM file and have all of the components,
There are two points need to pay attention in the use of dynamic DFM file,
Low dynamic insert each control or component part (s) must be in a program called RegisterClass register
Read in DFM files automatically create parts after, if the call InsertControl method,
the closed windowTo call when RemoveControl method to remove the control, otherwise it will produce abnormal events

2. The dynamic one of DFM file application: card of hypermedia system design
Delphi multiple types of visual components such as text widget, edit widget, graphics components, database
Media, media put parts and OLE parts, etc., each of these components occupy a certain area in the screen, has the quite rich
Performance ability, can be as a kind of media in the card, so can use the visual component of hypermedia system
The card design,
Hypermedia card design requirements for card number and types of media is not restricted in the media, and must be able to repair the
Change and access card, therefore, dynamic DFM file is more appropriate, and if the use of the Stream object, the card
Stored in a database BLOB fields, for the combination of hypertext and the relational database technology created the opportunity,
Below is a part of source program of hypermedia card design subsystem, it demonstrates how to create objects, insert objects
And dynamic DFM file access,
(1) registered in the application object

Procedure TMainForm. FormCreate (Sender: TObject);
The begin
RegisterClass (TLabel);
RegisterClass (TEdit);
RegisterClass (TMemo);
RegisterClass (TButton);
RegisterClass (TPanel);
RegisterClass (TPanelP);
RegisterClass (TBitBtn);
...
end;

2 create and insert object

Procedure TMDIChild. FormClick (Sender: TObject);
Var
Ctrl: TControl;
Point: a TPoint;
The begin
The GetCursorPos (Point);
Point:=BackGround. ScreenToClient (Point);
Case CurToolIndex of
1: the begin
Ctrl:=TLabel. Create (self);
TLabel (Ctrl). AutoSize:=False;
TLabel (CTRL). Caption:='Label' + S.
TLabel (CTRL). Name:='Label 1;
TLabel (CTRL). Top:=Point. Y;
TLabel (CTRL). Left:=Point X;
TLabel (Ctrl). Height:=Round (100 * 1000/Res/thewire);
TLabel (Ctrl). Width:=Round (600 * 1000/Res/thewire);
TLabel (Ctrl). Color:=clWhite;
TLabel (Ctrl). The Font. Color:=clBlack;
TLabel (Ctrl). The Font. The Name:='Roman';
TLabel (Ctrl). The Font. Height:=- TLabel (Ctrl). Height;
TLabel (Ctrl). The Font. Pitch:=fpFixed;
TLabel (Ctrl) Enabled:=False;
TLabel (Ctrl). The OnClick:=LabelClick;
TLabel (Ctrl). onm ouseMove:=ReportPos;
BackGround. InsertControl (Ctrl);
CurTool. Down:=False;
CurTool:=nil;
...
end;
2: the begin
Ctrl:=TEdit the Create (self);
TEdit (CTRL). AutoSize:=True;
TEdit (CTRL). Top:=Point. Y;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related