ScrollText: Textfile and resource names are not longer read-only.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8310 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-06-16 12:40:53 +00:00
parent c20f4e18cb
commit 3176651aaf
8 changed files with 22 additions and 17 deletions

View File

@ -1,2 +1,2 @@
lazres scrolltext.res scrolltext.txt
lazres scrolltext.lrs scrolltext.txt
lazres scrolltext.res scrolltext_res.txt
lazres scrolltext.lrs scrolltext_lrs.txt

View File

@ -1,3 +1,3 @@
LazarusResources.Add('scrolltext','TXT',[
'This text is in a resource.'#13#10
LazarusResources.Add('scrolltext_lrs','TXT',[
'This text is in a .lrs resource.'#13#10
]);

View File

@ -0,0 +1 @@
This text is in a .lrs resource.

View File

@ -0,0 +1 @@
This text is in a .res resource.

View File

@ -17,7 +17,7 @@ object Form1: TForm1
About.Description.Strings = (
'Component that shows a scrolling window.'#13#10'Use Lines property to set text and Active=True'#13#10'to use the component'
)
About.Title = 'About About About About ScrollingText component'
About.Title = 'About About About About About ScrollingText component'
About.Height = 280
About.Width = 400
About.Font.Color = clNavy
@ -56,7 +56,9 @@ object Form1: TForm1
)
Font.Height = -13
LinkFont.Height = -13
TextSource = stResource
TextSource = stTextfile
TextFileName = '../readme.txt'
TextResourceName = 'scrolltext_res'
end
object BitBtn1: TBitBtn
Left = 239

View File

@ -7,7 +7,7 @@ interface
// Both .lrs and .res files can be used.
// Activate the corresponding define for testing.
{$DEFINE LRS_RESOURCE}
{.$DEFINE RES_RESOURCE}
{$DEFINE RES_RESOURCE}
uses
Classes, SysUtils, FileUtil, ScrollingText, Forms, Controls, Graphics,

View File

@ -106,14 +106,14 @@ type
// Sets the font properties of links in the scrolling text
property LinkFont: TFont read fLinkFont write SetLinkFont;
// Source of the text to display.
// If TextSource=stTextfile 'scrolling.txt' should be in the deployed app folder
// if TextSource=stResource be sure to add LResources to your uses clause
// If TextSource=stTextfile the file "TextFileName" should be in the deployed app folder
// if TextSource=stResource a resource named "TextResourceName" should be available.
// This can be a .res or .lrs file. In case of .lrs, add LResources to your uses clause
// If TextSource=stStringList the scrolling text is taken from the Lines property.
property TextSource: TTextSource read fTextSource write fTextSource default
stStringlist;
// Read-only property to remind you of the correct file name
property TextFileName: string read fTextFileName;
// Read-only property to remind you of the correct resource name
property TextResourceName: string read fResourceName;
property TextFileName: string read fTextFileName write fTextFileName;
property TextResourceName: string read fResourceName write fResourceName;
// Version number of this component
property Version: string read fVersionString;
end;
@ -174,7 +174,6 @@ begin
Brush.Style := bsSolid;
FillRect(0, 0, Width, Height);
end;
if (fTextSource = stTextfile) then
if FileExists('scrolling.txt') then
begin
@ -184,8 +183,8 @@ begin
else
begin
fLines.Clear;
fLines.Add('The file ''' + C_TEXTFILENAME + ''' is missing.');
fLines.Add('It should be in the same folder as your application');
fLines.Add('The file ''' + fTextFileName + ''' is missing.');
fLines.Add('Ideally, it should be in the same folder as your application');
end;
// Load text from resource string
@ -222,7 +221,9 @@ begin
fLines.Add(' ');
fLines.Add('1) Haven''t set any text in the Lines property. or');
fLines.Add('2) TextSource is set to stTextfile and the file');
fLines.Add('''' + C_TEXTFILENAME + ''' is empty.');
fLines.Add('''' + fTextFileName + ''' is empty.');
fLines.Add('3) TextSource is set to stTextResouce and the resource');
fLines.Add('''' + fResourceName + ''' is not provide.');
fLines.Add(' ');
fLines.Add('Note that URL links such as');
fLines.Add('http://wiki.lazarus.freepascal.org/Main_Page');