You've already forked lazarus-ccr
ScrollText: Support .res resources. Fix missing resource in exampleapp.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8307 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -0,0 +1,2 @@
|
||||
lazres scrolltext.res scrolltext.txt
|
||||
lazres scrolltext.lrs scrolltext.txt
|
@ -1,11 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="project1"/>
|
||||
<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">
|
||||
|
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
LazarusResources.Add('scrolltext','TXT',[
|
||||
'This text is in a resource.'#13#10
|
||||
]);
|
BIN
components/scrolltext/latest_stable/exampleapp/scrolltext.res
Normal file
BIN
components/scrolltext/latest_stable/exampleapp/scrolltext.res
Normal file
Binary file not shown.
@ -1 +1 @@
|
||||
This is text
|
||||
This text is in a resource.
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user