Skip to content

Commit e53f5b4

Browse files
committed
Advanced demo: use native resource type
1 parent 48b3b4a commit e53f5b4

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

Demos/Advanced/Advanced.lpi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
<SessionStorage Value="InProjectDir"/>
1111
<MainUnit Value="0"/>
1212
<ResourceType Value="res"/>
13+
<UseXPManifest Value="True"/>
14+
<XPManifest>
15+
<DpiAware Value="True"/>
16+
</XPManifest>
17+
<Resources Count="5">
18+
<Resource_0 FileName="Res\Lorem ipsum.uni" Type="RCDATA" ResourceName="LOREM IPSUM"/>
19+
<Resource_1 FileName="Res\Transcriptions.bmp" Type="BITMAP" ResourceName="TRANSCRIPTIONS"/>
20+
<Resource_2 FileName="Res\Arabic.uni" Type="RCDATA" ResourceName="ARABIC"/>
21+
<Resource_3 FileName="Res\Greek.uni" Type="RCDATA" ResourceName="GREEK"/>
22+
<Resource_4 FileName="Res\Hebrew.uni" Type="RCDATA" ResourceName="HEBREW"/>
23+
</Resources>
1324
</General>
1425
<VersionInfo>
1526
<StringTable ProductVersion=""/>

Demos/Advanced/Advanced.lpr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
//HeaderCustomDrawDemo in 'HeaderCustomDrawDemo.pas' {HeaderOwnerDrawForm},
2222
States in 'States.pas' {StateForm}, Printer4Lazarus;
2323

24+
{$R *.res}
2425

2526
begin
2627
Application.Initialize;

Demos/Advanced/Advanced.res

197 KB
Binary file not shown.

Demos/Advanced/HeaderCustomDrawDemo.lfm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ object HeaderOwnerDrawForm: THeaderOwnerDrawForm
1111
Font.Name = 'MS Sans Serif'
1212
OnCreate = FormCreate
1313
OnDestroy = FormDestroy
14-
LCLVersion = '0.9.29'
14+
LCLVersion = '1.7'
1515
object Label8: TLabel
1616
Left = 12
17-
Height = 102
18-
Top = 320
17+
Height = 64
18+
Top = 358
1919
Width = 745
2020
Anchors = [akLeft, akRight, akBottom]
2121
Caption = 'This page demonstrates the advance custom draw mode for a tree''s header. The left column is drawn as usual while with the other columns more and more details are customized by the applicaiton. Note: Virtual Treeview allows to customize the header fully or only parts of it and draws all standard elements as normal if they are not handled by the application. This allows very flexible designs but avoids full custom draw if only a small details must be drawn differently.'
@@ -54,6 +54,7 @@ object HeaderOwnerDrawForm: THeaderOwnerDrawForm
5454
Header.Background = clBtnShadow
5555
Header.Columns = <
5656
item
57+
Color = clWindow
5758
Hint = 'This column is drawn entirely by the tree.'
5859
ImageIndex = 1
5960
Options = [coDraggable, coEnabled, coResizable, coShowDropMark, coVisible]
@@ -64,6 +65,7 @@ object HeaderOwnerDrawForm: THeaderOwnerDrawForm
6465
end
6566
item
6667
Alignment = taCenter
68+
Color = clWindow
6769
Hint = 'Only the background is customized.'
6870
ImageIndex = 2
6971
Layout = blGlyphTop

Demos/Advanced/HeaderCustomDrawDemo.pas

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface
1111

1212
uses
1313
LCLIntf, VTGraphics, Types, SysUtils, Classes, Graphics, Controls, Forms,
14-
Dialogs, VirtualTrees, StdCtrls, ExtCtrls, LResources, LCLType, LCLProc;
14+
Dialogs, VirtualTrees, StdCtrls, ExtCtrls, LCLType, LCLProc;
1515

1616
type
1717
THeaderOwnerDrawForm = class(TForm)
@@ -243,7 +243,7 @@ procedure THeaderOwnerDrawForm.FormCreate(Sender: TObject);
243243
//FBackBitmap2.PixelFormat := OptimalPixelFormat;
244244
CreateCheckerBackground;
245245
FHeaderBitmap := TBitmap.Create;
246-
FHeaderBitmap.LoadFromLazarusResource('Transcriptions');
246+
FHeaderBitmap.LoadFromResourceName(HINSTANCE, 'Transcriptions');
247247
end;
248248

249249
//----------------------------------------------------------------------------------------------------------------------
@@ -307,7 +307,5 @@ procedure THeaderOwnerDrawForm.HeaderCustomDrawTreeGetText(Sender: TBaseVirtualT
307307

308308
//----------------------------------------------------------------------------------------------------------------------
309309

310-
initialization
311-
{$i bitmap.lrs}
312310

313311
end.

Demos/Advanced/Main.pas

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,35 @@ implementation
5353
uses
5454
SpeedDemo, GeneralAbilitiesDemo, DrawTreeDemo, PropertiesDemo,
5555
GridDemo, VisibilityDemo, AlignDemo, WindowsXPStyleDemo, MultilineDemo, HeaderCustomDrawDemo,
56-
States;
56+
States, LCLType;
5757

5858
//----------------------------------------------------------------------------------------------------------------------
5959

60-
6160
procedure LoadUnicodeStrings(const Name: string; var Strings: array of String);
6261

6362
// Loads the Unicode strings from the resource.
6463

6564
var
66-
Res: TLResource;
67-
Head, Tail: PChar;
65+
Stream: TResourceStream;
66+
Head, Tail: PAnsiChar;
6867
I: Integer;
6968

7069
begin
71-
Res := LazarusResources.Find(Name);
72-
if (Res <> nil) and (Res.Value <> '') then
73-
begin
74-
Head := PChar(Res.Value);
70+
Stream := TResourceStream.Create(HINSTANCE, Name, RT_RCDATA);
71+
try
72+
Head := Stream.Memory;
7573
Tail := Head;
7674
for I := 0 to High(Strings) do
7775
begin
7876
Head := Tail;
79-
while not (Tail^ in [#0, #13]) do
77+
while not (Ord(Tail^) in [0, 13]) do
8078
Inc(Tail);
8179
SetString(Strings[I], Head, Tail - Head);
8280
// Skip carriage return and linefeed.
8381
Inc(Tail, 2);
8482
end;
83+
finally
84+
Stream.Free;
8585
end;
8686
end;
8787

0 commit comments

Comments
 (0)