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.res scrolltext_res.txt
lazres scrolltext.lrs scrolltext.txt lazres scrolltext.lrs scrolltext_lrs.txt

View File

@ -1,3 +1,3 @@
LazarusResources.Add('scrolltext','TXT',[ LazarusResources.Add('scrolltext_lrs','TXT',[
'This text is in a resource.'#13#10 '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 = ( 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' '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.Height = 280
About.Width = 400 About.Width = 400
About.Font.Color = clNavy About.Font.Color = clNavy
@ -56,7 +56,9 @@ object Form1: TForm1
) )
Font.Height = -13 Font.Height = -13
LinkFont.Height = -13 LinkFont.Height = -13
TextSource = stResource TextSource = stTextfile
TextFileName = '../readme.txt'
TextResourceName = 'scrolltext_res'
end end
object BitBtn1: TBitBtn object BitBtn1: TBitBtn
Left = 239 Left = 239

View File

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

View File

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