Produce Chinese statement with Delphi

zhaozj2021-02-11  172

18th issue (May 17): Computer and life

Half-year version: Computer and life

Half-year column: Programming skills

Publishing date: 19990517

Produce Chinese statement with Delphi

China Space Technology Research Institute of Maternity

In database application development, an important issue for system designers and programmakers need to consider how to design and output reports, we can pick in Delphi

Use multiple programs to solve this problem. If you use OLE automation technology to output data to MS-Word, MS-Excel, but most direct, most local or use

QuickReport report components in Delphi3.0 / 40. It is Norwegian Qusoft specializes in Delphi, using QuickReport to quickly design in the West

Reports for people habits.

However, when designing a Chinese statement, the author found that the vertical line and slash between the columns and columns in QuickReport; although QuickReport provided

Tqshape control, use this control to draw vertical lines between columns, but if the user does not correctly adjust the height of the Tqshape instance, the vertical line in the output report is not

Continuous is long, and if we adjust the height of a BAN, we will have to adjust the height of all Tqshape instances under this band; as for the slash,

The QuickReport report component does not provide this feature.

The author carefully found relevant information, successfully solved the above problems, hoping to help everyone.

Solutions

To create a new control with TQShape, the new control can draw vertical lines, slash and backlash.

The PAINT method of the TQShape class is overloaded, so that it can be very intuitive in the design phase. Users can select the type of line in the design phase,

If you select a straight line, the control automatically adjusts its height to the height of the BAND, the user can adjust its lateral position but cannot adjust its height; if you choose the slash, the user can

Adjust the length and tilt of the slash as needed.

The Print method of the TQShape class is overloaded, which can output a straight line and the slash at the run phase.

Description: This control can only draw straight and slashes. If the reader needs to draw a rectangle and circle, you can use the TQShape control to be implemented.

Control design steps

Step 1. Use the control wizards provided by Delphi, select Tqshape as the parent class, create a new class TMYQRSHAPE, and select the appropriate package (package), and finally generate unit files.

Step 2. In the generated unit file, add an enumerated type.

TLINES = (None, Topbottom, Bottomtop); None, TopBottom, Bottomtop, three types of values, representing straight, slash / and antilactors /.

Step 3. Increase the private member flinetype: tLINEs in the new class TMYQRShape, add the publication property LINETYPE: TLINES Read

FLINETYPE WRITE SETFLINETYPE.

Step 4. Establish a process setFLINETYPE.

Procedure

TMYQRSHAPE.SETFLINETYPE (Value: TLINES);

Begin

IF value <> flinetype kil

Begin

FLINETYPE: = Value;

INVALIDATE;

END;

END;

Step 5. Overload the Paint method.

Procedure TMYQRSHAPE.PAINT;

Begin

Case LineType of

Bottomtop:

Begin

Canvas.Moveto (0, Height);

Canvas.LineTo (Width, 0);

END;

Topbottom:

Begin

Canvas.Moveto (0, 0);

Canvas.LineTo (Width, Height);

END;

None:

Begin

Height: = parent.height;

TOP: = 0;

Width: = 4;

Shape: = QRSVERTLINE

Inherited paint;

END;

END;

END;

Step 6. Overload the Print method.

Procedure TmyQRShape.print (OFSX, OFSY: Integer); Begin

With qrprinter do

Begin

Case LineType of

Bottomtop:

Begin

Canvas.Moveto (XPOS (OFSX Size.Left), YPOS (OFSY SIZE.TOP) Height;

Canvas.LineTo (XPOSX Size.left) Width, Ypos (OFSY SIZE.TOP);

END;

Topbottom:

Begin

Canvas.Moveto (XPOSX Size.Left), YPOS (OFSY SIZE.TOP);

Canvas.Lineto (XPOSX Size.Left) Width, Ypos (OFSY SIZE.TOP) Height);

END;

None:

Inherited Print (OFSX, OFSY);

END;

END;

END;

Step 7. Save and install the TMYQRSHAPE control.

This control is debugged, installs, and successfully applied to the development of a database management system under Delphi40. The full code of the control is as follows:

Source program:

Unit myqrshape;

Interface

Uses

Windows, Messages, Sysutils, Classes, Graphics,

Controls, Forms, Dialogs,

Quickrpt, qrctrls;

Type

TLINES = (None, TopBottom, Bottomtop);

TMYQRSHAPE = Class (TQRShape)

Private

FlineType: TLINES;

Procedure setflinetype (value: tlines);

protected

Procedure Print (OFSX, OFSY: Integer; OVERRIDE;

proca;

public

Published

Property LineType: Tlines Read FlineType Write SetFLINETYPE

END;

PROCEDURE register;

IMPLEMentation

Procedure

TMYQRSHAPE.SETFLINETYPE (Value: TLINES);

Begin

IF value <> flinetype kil

Begin

FLINETYPE: = Value;

INVALIDATE;

END;

END;

Procedure TMYQRSHAPE.PAINT;

Begin

Case LineType of

Bottomtop:

Begin

Canvas.Moveto (0, Height);

Canvas.LineTo (Width, 0);

END;

Topbottom:

Begin

Canvas.Moveto (0, 0);

Canvas.LineTo (Width, Height);

END;

None:

Begin

Height: = parent.height;

TOP: = 0;

Width: = 4;

Shape: = QRSVERTLINE

Inherited paint;

END;

END;

END;

Procedure TmyQRShape.print (OFSX, OFSY: Integer);

Begin

With qrprinter do

Begin

Case LineType of

Bottomtop:

Begin

Canvas.Moveto (xpos (OFSX Size.Left), YPOS (OFSY SIZE.TOP) Height); Canvas.LineTo (XPOS (OFSX Size.LEFT) Width, Ypos (OFSY SIZE.TOP));

END;

Topbottom:

Begin

Canvas.Moveto (XPOSX Size.Left), YPOS (OFSY SIZE.TOP);

Canvas.Lineto (XPOSX Size.Left) Width, Ypos (OFSY SIZE.TOP) Height);

END;

None:

Inherited Print (OFSX, OFSY);

END;

END;

END;

PROCEDURE register;

Begin

Registercomponents ('QReport', [TMYQRSHAPE]);

END;

End.

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

New Post(0)