LCD面板构件(0分)

  • 主题发起人 主题发起人 那一刀
  • 开始时间 开始时间

那一刀

Unregistered / Unconfirmed
GUEST, unregistred user!
如何编写LCD面板构件?!大家一起讨论一下!
 
没人回答
 
顶顶

那一刀

上www.delphibbs.net上看看有没有收获
 
没有,太差了!
 
我有一套这样的 例程 如需要请说一生
 
我想要,plf22@163.com,谢谢
 
我想要,chinakam1974@21cn.com,谢谢
 
别客气
业已发出请查收!
 
我想要一份amadman@etang.com
 
自己写的一个小控件

Numbers:包括你要显示的字符的位图
Layout:按照位图中的顺序的字符串


unit SuperLED;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;

type
TSuperLED = class(TPanel)
private
{ Private declarations }
FNumbers : TBitmap;
FNumberWidth : Word;
FValue : string;
FLayout: String;
FMargin : Word;
FAutoSize : Boolean;
FGap : Integer;
FFormatWidth : Word;
procedure SetNumbers (Value : TBitmap);
procedure SetMargin (Value : Word);
procedure SetValue(value : string);
procedure SetAutoSize (Value : Boolean);
procedure SetGap (Value : Integer);
procedure SetFormatWidth (Value : Word);
procedure SetLayout(value : string);
protected
{ Protected declarations }
procedure Paint; override;
procedure SetHeight;
procedure GetSides (var TopSide, LeftSide, RightSide : Integer);
function GetIndex(c:string):integer;
public
{ Public declarations }
constructor Create (AOwner : TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property Numbers : TBitmap read FNumbers write SetNumbers;
property Margin : Word read FMargin write SetMargin default 2;
property Value : string read FValue write SetValue;
property AutoSize : Boolean read FAutoSize write SetAutoSize default true;
property Gap : Integer read FGap write SetGap default 0;
property FormatWidth : Word read FFormatWidth write SetFormatWidth default 1;
property Layout : string read FLayout write SetLayout;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('OtherVCL', [TSuperLED]);
end;

constructor TSuperLED.Create(AOwner : TComponent);
begin
inherited Create (AOwner);
FNumbers:=TBitmap.Create;
BevelInner:=bvLowered;
BevelWidth:=1;
Color:=clBlack;
FNumberWidth:=0;
FValue:='0';
FMargin:=2;
FAutoSize:=True;
FGap:=0;
FFormatWidth:=1;
end;

destructor TSuperLED.Destroy;
begin
FNumbers.Free;
inherited Destroy;
end;

procedure TSuperLED.SetNumbers(value:TBitmap);
begin
FNumbers.Assign(Value);
if FNumbers<>nil then
begin
if Length(FLayout)>0 then
FNumberWidth:=FNumbers.Width div Length(FLayout);
SetHeight;
Invalidate;
end;
end;

procedure TSuperLED.SetMargin (Value : Word);
begin
FMargin:=Value;
SetHeight;
Invalidate;
end;

procedure TSuperLED.SetValue(value : string);
begin
FValue:=value;
Invalidate;
end;

procedure TSuperLED.SetAutoSize(value : Boolean);
begin
FAutoSize:=Value;
SetHeight;
Invalidate;
end;

procedure TSuperLED.SetGap(value:Integer);
begin
FGap:=Value;
Invalidate;
end;

procedure TSuperLED.SetFormatWidth(value : word);
begin
FFormatWidth:=Value;
SetValue (FValue);
end;

procedure TSuperLED.SetLayout(value : string);
begin
FLayout:=value;
if FNumbers<>nil then
FNumberWidth:=FNumbers.Width div Length(FLayout);
Invalidate;
end;

function TSuperLED.GetIndex(c:string):Integer;
var
i:integer;
begin
result:=0;
if Length(FLayout)>0 then
for i:=Length(FLayout) downto 1 do
begin
if c=FLayout then result:=i;
end;
end;

procedure TSuperLED.Paint;
var
DigitLeft, BitmapLeft, TopSide, LeftSide, RightSide, L : Integer;
begin
inherited Paint;
if FNumbers<>nil then { something to draw with }
begin
GetSides (TopSide, LeftSide, RightSide); { get drawing area }
DigitLeft:=RightSide;
for L:=Length (Value) downto 1 do { draw value }
begin
Dec (DigitLeft, FNumberWidth);
if DigitLeft>LeftSide then
begin
BitmapLeft:=(GetIndex(Value[L])-1)*FNumberWidth;
Canvas.CopyRect (Rect (DigitLeft, TopSide, DigitLeft+FNumberWidth, TopSide+FNumbers.Height),
FNumbers.Canvas,
Rect (BitmapLeft, 0, BitmapLeft+FNumberWidth, FNumbers.Height));
end; { if }
DigitLeft:=DigitLeft-FFormatWidth-Gap; { add the gap if there is one }
end; { for }
end; { if }
end;

procedure TSuperLED.GetSides (var TopSide, LeftSide, RightSide : Integer);
begin
LeftSide:=0;
RightSide:=Width;
TopSide:=0;
if BevelInner<>bvNone then
begin
Inc (LeftSide, BevelWidth);
Dec (RightSide, BevelWidth);
Inc (TopSide, BevelWidth);
end; { if }
if BevelOuter<>bvNone then
begin
Inc (LeftSide, BevelWidth);
Dec (RightSide, BevelWidth);
Inc (TopSide, BevelWidth);
end; { if }
Inc (LeftSide, BorderWidth);
Dec (RightSide, BorderWidth);
Inc (TopSide, BorderWidth);
Inc (LeftSide, Margin);
Dec (RightSide, Margin);
Inc (TopSide, Margin);
end;

procedure TSuperLED.SetHeight;
var
T, L, R : Integer;
begin
if FAutoSize then
begin
GetSides (T, L, R);
Height:=(T*2)+FNumbers.Height;
end;
end;

end.
 
最偷懒的办法就是->找个LED字体!呵呵!
 
LMD里面就有呀
 
后退
顶部