From 3176651aaf99fde83d1be5fed45f46e4ba193327 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 16 Jun 2022 12:40:53 +0000 Subject: [PATCH] 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 --- .../latest_stable/exampleapp/make_res.bat | 4 ++-- .../latest_stable/exampleapp/scrolltext.lrs | 4 ++-- .../latest_stable/exampleapp/scrolltext.res | Bin 113 -> 126 bytes .../exampleapp/scrolltext_lrs.txt | 1 + .../exampleapp/scrolltext_res.txt | 1 + .../latest_stable/exampleapp/unit1.lfm | 6 +++-- .../latest_stable/exampleapp/unit1.pas | 2 +- .../latest_stable/scrollingtext.pas | 21 +++++++++--------- 8 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 components/scrolltext/latest_stable/exampleapp/scrolltext_lrs.txt create mode 100644 components/scrolltext/latest_stable/exampleapp/scrolltext_res.txt diff --git a/components/scrolltext/latest_stable/exampleapp/make_res.bat b/components/scrolltext/latest_stable/exampleapp/make_res.bat index f7934bbe9..d1f5b31bd 100644 --- a/components/scrolltext/latest_stable/exampleapp/make_res.bat +++ b/components/scrolltext/latest_stable/exampleapp/make_res.bat @@ -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 diff --git a/components/scrolltext/latest_stable/exampleapp/scrolltext.lrs b/components/scrolltext/latest_stable/exampleapp/scrolltext.lrs index 24c689f31..907f505c0 100644 --- a/components/scrolltext/latest_stable/exampleapp/scrolltext.lrs +++ b/components/scrolltext/latest_stable/exampleapp/scrolltext.lrs @@ -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 ]); diff --git a/components/scrolltext/latest_stable/exampleapp/scrolltext.res b/components/scrolltext/latest_stable/exampleapp/scrolltext.res index bd4f25c46d2695dd8c5faa460bfb9977540ddb8b..c0a206b567fd837220b5c714dffdba54038444a3 100644 GIT binary patch delta 64 zcmXS{o1mbs#K6E{1H}LTb1?)nI5Pw>_%rwbVF-gOLj;hF2a32d1W&YA7tkw8Emi>H M{L-T2R6SlU0K%{i)&Kwi delta 51 zcmb;`oS+~t%fP^30>uCSb1?)nI5Pw>_%rwbVF-gOLj*&}M0a)WqSWI2(xT*4Jzg#V DCSMEV diff --git a/components/scrolltext/latest_stable/exampleapp/scrolltext_lrs.txt b/components/scrolltext/latest_stable/exampleapp/scrolltext_lrs.txt new file mode 100644 index 000000000..0d8e30b48 --- /dev/null +++ b/components/scrolltext/latest_stable/exampleapp/scrolltext_lrs.txt @@ -0,0 +1 @@ +This text is in a .lrs resource. diff --git a/components/scrolltext/latest_stable/exampleapp/scrolltext_res.txt b/components/scrolltext/latest_stable/exampleapp/scrolltext_res.txt new file mode 100644 index 000000000..6dfa8399e --- /dev/null +++ b/components/scrolltext/latest_stable/exampleapp/scrolltext_res.txt @@ -0,0 +1 @@ +This text is in a .res resource. diff --git a/components/scrolltext/latest_stable/exampleapp/unit1.lfm b/components/scrolltext/latest_stable/exampleapp/unit1.lfm index 95fc3574e..d76dcedf6 100644 --- a/components/scrolltext/latest_stable/exampleapp/unit1.lfm +++ b/components/scrolltext/latest_stable/exampleapp/unit1.lfm @@ -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 diff --git a/components/scrolltext/latest_stable/exampleapp/unit1.pas b/components/scrolltext/latest_stable/exampleapp/unit1.pas index cc8f92116..cdf9acda6 100644 --- a/components/scrolltext/latest_stable/exampleapp/unit1.pas +++ b/components/scrolltext/latest_stable/exampleapp/unit1.pas @@ -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, diff --git a/components/scrolltext/latest_stable/scrollingtext.pas b/components/scrolltext/latest_stable/scrollingtext.pas index 4bc77b941..c17afef7d 100644 --- a/components/scrolltext/latest_stable/scrollingtext.pas +++ b/components/scrolltext/latest_stable/scrollingtext.pas @@ -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');