unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Panel1: TPanel;
ScrollBox1: TScrollBox;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
uses StrUtils, LCLType, LCLIntf;
procedure AddTextToLog(const AText: string; AIcon: HICON; ToScroll: TScrollBox);
const
CPanelHeight = 32;
var
Owner: TComponent;
Panel: TPanel;
Memo: TMemo;
Image: TImage;
Bevel: TBevel;
begin
Owner := ToScroll.Owner;
// Panel
Panel := TPanel.Create(Owner);
Panel.Align := alTop;
Panel.BevelOuter := bvNone;
Panel.Height := CPanelHeight;
Panel.Top := MaxInt;
// Image
Image := TImage.Create(Owner);
Image.Align := alLeft;
Image.Width := CPanelHeight;
Image.Transparent := True;
Image.Stretch := True;
Image.Picture.Icon.Handle := AIcon;
Image.Parent := Panel;
// Memo
Memo := TMemo.Create(Owner);
Memo.Align := alClient;
Memo.BorderStyle := bsNone;
Memo.ParentColor := True;
Memo.ReadOnly := True;
Memo.Text := AText;
Memo.Parent := Panel;
// Bevel
Bevel := TBevel.Create(Owner);
Bevel.Align := alTop;
Bevel.Shape := bsTopLine;
Bevel.Height := 2;
Bevel.Top := MaxInt;
//
Panel.Parent := ToScroll;
Bevel.Parent := ToScroll;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
IDI_ERROR = MAKEINTRESOURCE(32513);
IDI_QUESTION = MAKEINTRESOURCE(32514);
IDI_WARNING = MAKEINTRESOURCE(32515);
IDI_INFORMATION = MAKEINTRESOURCE(32516);
IDI_WINLOGO = MAKEINTRESOURCE(32517);
begin
AddTextToLog(DupeString('Test of Information', 7),
LCLIntf.LoadIcon(0, IDI_INFORMATION),
ScrollBox1);
AddTextToLog(DupeString('Test of Question', 8),
LCLIntf.LoadIcon(0, IDI_QUESTION),
ScrollBox1);
AddTextToLog(DupeString('Test of Warning', 9),
LCLIntf.LoadIcon(0, IDI_WARNING),
ScrollBox1);
AddTextToLog(DupeString('Test of Error', 10),
LCLIntf.LoadIcon(0, IDI_ERROR),
ScrollBox1);
AddTextToLog(DupeString('Test of Logo', 11),
LCLIntf.LoadIcon(0, IDI_WINLOGO),
ScrollBox1);
end;
end.