diff --git a/components/scrolltext/latest_stable/exampleapp/make_res.bat b/components/scrolltext/latest_stable/exampleapp/make_res.bat new file mode 100644 index 000000000..f7934bbe9 --- /dev/null +++ b/components/scrolltext/latest_stable/exampleapp/make_res.bat @@ -0,0 +1,2 @@ +lazres scrolltext.res scrolltext.txt +lazres scrolltext.lrs scrolltext.txt diff --git a/components/scrolltext/latest_stable/exampleapp/project1.lpi b/components/scrolltext/latest_stable/exampleapp/project1.lpi index b42632a74..da20c746c 100644 --- a/components/scrolltext/latest_stable/exampleapp/project1.lpi +++ b/components/scrolltext/latest_stable/exampleapp/project1.lpi @@ -1,11 +1,13 @@ - + + + + - <ResourceType Value="res"/> <UseXPManifest Value="True"/> @@ -14,9 +16,6 @@ <i18n> <EnableI18N Value="True" LFM="False"/> </i18n> - <VersionInfo> - <StringTable ProductVersion=""/> - </VersionInfo> <BuildModes Count="1"> <Item1 Name="Default" Default="True"/> </BuildModes> @@ -24,9 +23,10 @@ <Version Value="2"/> </PublishOptions> <RunParams> - <local> - <FormatVersion Value="1"/> - </local> + <FormatVersion Value="2"/> + <Modes Count="1"> + <Mode0 Name="default"/> + </Modes> </RunParams> <RequiredPackages Count="2"> <Item1> @@ -40,7 +40,6 @@ <Unit0> <Filename Value="project1.lpr"/> <IsPartOfProject Value="True"/> - <UnitName Value="project1"/> </Unit0> <Unit1> <Filename Value="unit1.pas"/> @@ -67,18 +66,15 @@ <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> </SearchPaths> <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + </Debugging> <Options> <Win32> <GraphicApplication Value="True"/> </Win32> </Options> </Linking> - <Other> - <CompilerMessages> - <MsgFileName Value=""/> - </CompilerMessages> - <CompilerPath Value="$(CompPath)"/> - </Other> </CompilerOptions> <Debugging> <Exceptions Count="3"> diff --git a/components/scrolltext/latest_stable/exampleapp/project1.res b/components/scrolltext/latest_stable/exampleapp/project1.res index 7c6cf3e4b..556537956 100644 Binary files a/components/scrolltext/latest_stable/exampleapp/project1.res and b/components/scrolltext/latest_stable/exampleapp/project1.res differ diff --git a/components/scrolltext/latest_stable/exampleapp/scrolltext.lrs b/components/scrolltext/latest_stable/exampleapp/scrolltext.lrs new file mode 100644 index 000000000..24c689f31 --- /dev/null +++ b/components/scrolltext/latest_stable/exampleapp/scrolltext.lrs @@ -0,0 +1,3 @@ +LazarusResources.Add('scrolltext','TXT',[ + 'This text is in a resource.'#13#10 +]); diff --git a/components/scrolltext/latest_stable/exampleapp/scrolltext.res b/components/scrolltext/latest_stable/exampleapp/scrolltext.res new file mode 100644 index 000000000..bd4f25c46 Binary files /dev/null and b/components/scrolltext/latest_stable/exampleapp/scrolltext.res differ diff --git a/components/scrolltext/latest_stable/exampleapp/scrolltext.txt b/components/scrolltext/latest_stable/exampleapp/scrolltext.txt index 881c4feb8..a772ad67f 100644 --- a/components/scrolltext/latest_stable/exampleapp/scrolltext.txt +++ b/components/scrolltext/latest_stable/exampleapp/scrolltext.txt @@ -1 +1 @@ -This is text +This text is in a resource. diff --git a/components/scrolltext/latest_stable/exampleapp/unit1.lfm b/components/scrolltext/latest_stable/exampleapp/unit1.lfm index 1ef4d8b3e..95fc3574e 100644 --- a/components/scrolltext/latest_stable/exampleapp/unit1.lfm +++ b/components/scrolltext/latest_stable/exampleapp/unit1.lfm @@ -8,7 +8,7 @@ object Form1: TForm1 ClientHeight = 363 ClientWidth = 552 Position = poDesktopCenter - LCLVersion = '1.2.4.0' + LCLVersion = '2.3.0.0' object ScrollingText1: TScrollingText Left = 0 Height = 363 @@ -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 ScrollingText component' + About.Title = 'About About About About ScrollingText component' About.Height = 280 About.Width = 400 About.Font.Color = clNavy @@ -55,6 +55,7 @@ object Form1: TForm1 'June 2014' ) Font.Height = -13 + LinkFont.Height = -13 TextSource = stResource end object BitBtn1: TBitBtn diff --git a/components/scrolltext/latest_stable/exampleapp/unit1.pas b/components/scrolltext/latest_stable/exampleapp/unit1.pas index 66f9b57c8..cc8f92116 100644 --- a/components/scrolltext/latest_stable/exampleapp/unit1.pas +++ b/components/scrolltext/latest_stable/exampleapp/unit1.pas @@ -4,9 +4,14 @@ unit Unit1; interface +// Both .lrs and .res files can be used. +// Activate the corresponding define for testing. +{$DEFINE LRS_RESOURCE} +{.$DEFINE RES_RESOURCE} + uses Classes, SysUtils, FileUtil, ScrollingText, Forms, Controls, Graphics, - Dialogs, Buttons, StdCtrls; + Dialogs, Buttons, StdCtrls, LResources; type @@ -29,9 +34,10 @@ var implementation {$R *.lfm} +{$IFDEF RES_RESOURCE} + {$R scrolltext.res} +{$ENDIF} -resourcestring - scrolltext='Hello'; { TForm1 } procedure TForm1.Button1Click(Sender: TObject); @@ -39,5 +45,10 @@ begin ScrollingText1.Active:=NOT ScrollingText1.Active; end; +initialization +{$IFDEF LRS_RESOURCE} + {$I scrolltext.lrs} +{$ENDIF} + end. diff --git a/components/scrolltext/latest_stable/scrollingtext.pas b/components/scrolltext/latest_stable/scrollingtext.pas index bc8d391d1..3fbc9f7ce 100644 --- a/components/scrolltext/latest_stable/scrollingtext.pas +++ b/components/scrolltext/latest_stable/scrollingtext.pas @@ -36,12 +36,12 @@ interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, - ExtCtrls, LCLIntf,LCLTranslator,AboutScrolltextunit; + ExtCtrls, LCLType, LCLIntf, LCLTranslator, AboutScrolltextunit; const C_TEXTFILENAME = 'scrolling.txt'; - C_TEXTRESOURCENAME = 'scrolltext'; //Note: LResources unit needed - C_VERSION = '1.0.2.0'; + C_TEXTRESOURCENAME = 'scrolltext'; //Note: LResources unit needed for .lrs resource + C_VERSION = '1.0.4.0'; type TTextSource = (stStringlist, stTextfile, stResource); @@ -158,6 +158,7 @@ end; procedure TScrollingText.Init; var r: TLResource; + stream: TResourceStream; begin FBuffer.Width := Width; FBuffer.Height := Height; @@ -185,19 +186,34 @@ begin fLines.Add('The file ''' + C_TEXTFILENAME + ''' is missing.'); fLines.Add('It should be in the same folder as your application'); end; + + // Load text from resource string if (fTextSource = stResource) then - - // Load text from resource string begin - r := LazarusResources.Find(fResourceName); - if r = nil then - raise Exception.CreateFmt('Resource ''%s'' is missing',[fResourceName]) - else + // Test for a .res resource first + if FindResource(HInstance, fResourceName, RT_RCDATA) <> 0 then begin - fLines.Clear; - fLines.Add(r.Value); + stream := TResourceStream.Create(HInstance, fResourceName, RT_RCDATA); + try + fLines.Clear; + fLines.LoadFromStream(stream); + finally + stream.Free; + end; + end else + begin + // Finally, test of a .lrs resource + r := LazarusResources.Find(fResourceName); + if r = nil then + raise Exception.CreateFmt('Resource ''%s'' is missing',[fResourceName]) + else + begin + fLines.Clear; + fLines.Add(r.Value); + end; end; end; + // Are there any lines in the Stringlist? if (fLines.Count = 0) then begin