Unit unit2;

Source: Internet
Author: User

Unit unit2;

Interface

Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, inifiles, stdctrls;

Const
Templatemain = 'main ';
Templatebtn = 'click ';
Type
Tarrstring = array of string;

Tframeinfo = record
Frameimage: string;
Framerect: trect;
End;
Ttextinfo = record
Textimage: string;
Textrect: trect;
Textname: string;
Textfont: integer;
Textcolor: integer;
Textbold: integer;
Textitalic: integer;
End;
Tbuttoninfo = record
Previmage: string;
Prevrect: trect;
Nextimage: string;
Nextrect: trect;
Playimage: string;
Playrect: trect;
Returnimage: string;
Recturnrect: trect;
End;

Ttemplatesinfo = record
Bkimage: string;
Bkgndcolor: integer;
Previewimage: string;
Nbtncount: integer;
Ntxtcount: integer;
Nframecount: integer;
Arrframeinfo: array of tframeinfo;
Arrtxtinfo: array of ttextinfo;
Arrbtninfo: array of tbuttoninfo;
End;
Tform2 = Class (tform)
Button1: tbutton;
Procedure button1click (Sender: tobject );
Private
Function gettemplatesinfo (const atemplatepath: string): ttemplatesinfo;
{Private Declarations}
Public
{Public declarations}
End;

VaR
Form2: tform2;

Implementation

{$ R *. DFM}

{Tform2}

Procedure tform2.button1click (Sender: tobject );
Begin
Gettemplatesinfo ('d:/program files/aimersoft/DVD Creator/templates/art/candle/template. ini ');
End;

Function tform2.gettemplatesinfo (const atemplatepath: string): ttemplatesinfo;
Function splitstring (astr: string; adot: Char): tarrstring;
VaR
Arrstr: tarrstring;
I, J: integer;
Begin
I: = 1; J: = 0;
Setlength (astr, 4 );
While pos (adot, astr)> 0 do
Begin
Arrstr [J]: = copy (astr, I, pos (adot, astr)-I );
I: = pos (adot, astr) + 1;
Astr [I-1]: = CHR (ord (adot) + 1 );
J: = J + 1;
End;
Arrstr [J]: = copy (astr, I, strlen (pchar (astr)-I + 1 );
Result: = arrstr;
End;
VaR
Templatespath: ttemplatesinfo;
INIFILE: Tinifile;
I: integer;
Arrframe: tarrstring;
Sframe: string;
Begin
If not fileexists (atemplatepath) Then exit;

INIFILE: = Tinifile. Create (atemplatepath );
Zeromemory (@ templatespath, sizeof (templatespath ));
Try
With templatespath do
Begin
Bkimage: = INIFILE. readstring (templatemain, 'bkgnd ','');
Bkgndcolor: = INIFILE. readinteger (templatemain, 'bkgnd _ color', 0 );
Previewimage: = INIFILE. readstring (templatemain, 'preview ','');
Nbtncount: = INIFILE. readinteger (templatebtn, 'button _ num', 0 );
Nframecount: = INIFILE. readinteger (templatemain, 'frame _ num', 0 );
Ntxtcount: = INIFILE. readinteger (templatemain, 'text _ num', 0 );
If nframecount> 0 then
Begin
Setlength (arrframeinfo, nframecount );
For I: = 0 to length (arrframeinfo)-1 do
Begin
Arrframeinfo [I]. frameimage: = INIFILE. readstring (templatemain, format ('frame % d_image ', [I]), '');
Sframe: = INIFILE. readstring (templatemain, format ('frame % d', [I]), '');
Arrframe: = splitstring (sframe ,',');
Arrframeinfo [I]. framerect. Left: = strtoint (arrframe [0]);
Arrframeinfo [I]. framerect. Top: = strtoint (arrframe [1]);
Arrframeinfo [I]. framerect. Right: = arrframeinfo [I]. framerect. Left + strtoint (arrframe [2]);
Arrframeinfo [I]. framerect. Bottom: = arrframeinfo [I]. framerect. Top + strtoint (arrframe [3]);
End;
End;

End;

Finally
INIFILE. Free;
End;

End;

End.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.