?? klistbox.pas
字號(hào):
unit Klistbox;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus;
type
TLabelColorType = (LCTFont, LCTColor);
TKListbox = class(TListbox)
private
{ Private declarations }
FAllowArrow : Boolean;
FAllowEnter : Boolean;
FFocusColor : TColor;
FUnFocusColor : TColor;
FFocusCtl : Boolean; //礙力肺 瘤瀝等 器目膠肺 撈悼且巴牢瘤 酒囪瘤 瘤瀝
FFocusprior : TWincontrol; //撈傈狼 器目膠
FFocusNext : TWincontrol; //撈饒狼 器目膠
FLabelCtl : TLabel; //瘤瀝等 扼駭狼 禍惑闌 官槽促
FLabelCtlType : TLabelColorType; //瘤瀝等 扼駭狼 禍惑 肚綽 迄飄甫 瘤瀝茄促.
FLabelEColor : TColor; //扼駭器目膠甫 罐闌錠 禍惑
FLabelFColor: TColor; //扼駭器目膠甫 酪闌錠 禍惑
protected
{ Protected declarations }
procedure SetUnFocusColor(Value: TColor);
procedure DoEnter; override;
procedure DoExit; override;
procedure KeyPress(var Key: Char); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure SetFocusCtl(Value : Boolean);
procedure SetFocusprior(Value : TWincontrol);
procedure SetFocusNext(Value : TWincontrol);
procedure SetLabelCtl(Value : TLabel);
procedure SetLabelCtlType(Value : TLabelColorType);
procedure SetLabelEColor(Value : TColor);
procedure SetLabelFColor(Value : TColor);
public
{ Public declarations }
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property AllowArrow: Boolean read FAllowArrow write fAllowArrow default True;
property AllowEnter: Boolean read FAllowEnter write FAllowEnter default False;
property FocusColor : TColor read FFocusColor write FFocusColor;
property FocusUnColor : TColor read FUnFocusColor write SetUnFocusColor default clWindow;
property LabelCtl: TLabel read FLabelCtl write SetLabelCtl;
property LabelCtlType: TLabelColorType read FLabelCtltype write SetLabelCtltype;
property LabelFColor: TColor read FLabelFColor write SetLabelFColor default clWindow;
property LabelEColor: TColor read FLabelEColor write SetLabelEColor default clWindow;
property FocusCtl : Boolean Read FFocusCtl Write SetFocusCtl Default False;
property FocusPrior : TWincontrol Read FFocusPrior Write SetFocusPrior;
property FocusNext : TWincontrol Read FFocusNext Write SetFocusNext;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Etc', [TKListbox]);
end;
constructor TKListbox.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
FAllowArrow := False;
FAllowEnter := True;
FUnFocusColor := Color;
FFocusColor := Color;
ImeMode := imSHanguel;
Font.Size := 10;
Font.Name := '奔覆';
ShowHint := True;
Height := 18;
end;
destructor TKListbox.Destroy;
begin
inherited Destroy;
end;
procedure TKListbox.DoEnter;
begin
Color := FFocusColor;
if FLabelCtl <> Nil then
if FLabelCtlType = LCTFont then FLabelCtl.Font.Color := FLabelFcolor
else FLabelCtl.Color := FLabelFcolor;
inherited;
end;
procedure TKListbox.DoExit;
begin
Color := FUnFocusColor;
if FLabelCtl <> Nil then
if FLabelCtlType = LCTFont then FLabelCtl.Font.Color := FLabelEcolor
else FLabelCtl.Color := FLabelEcolor;
inherited DoExit;
end;
procedure TKListbox.KeyDown(var Key: Word; Shift: TShiftState);
var
MyForm: TCustomForm;
begin
if FAllowArrow and (Key = VK_DOWN) then begin
MyForm := GetParentForm(Self);
if (FFocusCtl) and (fFocusNext <> Nil) then FFocusNext.SetFocus
else SendMessage(MyForm.Handle, WM_NEXTDLGCTL, 0, 0);
Key := 0;
end else if FAllowArrow and (Key = VK_UP) then begin
MyForm := GetParentForm(Self);
if (FFocusCtl) and (FFocusPrior <> Nil) then FFocusPrior.SetFocus
else SendMessage(MyForm.Handle, WM_NEXTDLGCTL, 1, 0);
Key := 0;
end else if FAllowEnter and (Key = VK_RETURN)and(Shift=[]) then begin
MyForm := GetParentForm(Self);
if (FFocusCtl) and (fFocusNext <> Nil) then FFocusNext.SetFocus
else SendMessage(MyForm.Handle, WM_NEXTDLGCTL, 0, 0);
inherited KeyDown(Key,Shift);
end else inherited;
end;
procedure TKListbox.KeyPress(var Key: Char);
begin
if (Key = Char(VK_RETURN)) or (Key = Char(VK_ESCAPE)) then
begin
GetParentForm(Self).Perform(CM_DIALOGKEY, Byte(Key), 0);
if Key = Char(VK_RETURN) then begin
inherited KeyPress(Key);
Key := #0;
Exit;
end;
end;
inherited KeyPress(Key);
end;
procedure TKListbox.SetUnFocusColor(Value: TColor);
begin
if Value = FUnFocusColor then Exit;
FUnFocusColor := Value;
if not Focused or (csDesigning in ComponentState) then Color := FUnFoCusColor;
end;
procedure TKListbox.SetLabelCtl(Value : TLabel);
begin
FLabelCtl := Value;
end;
procedure TKListbox.SetLabelCtltype(Value : TLabelColorType);
begin
FLabelCtlType := Value;
end;
procedure TKListbox.SetLabelFColor(Value : TColor);
begin
FLabelFColor := Value;
end;
procedure TKListbox.SetLabelEColor(Value : TColor);
begin
FLabelEColor := Value;
end;
procedure TKListbox.SetFocusCtl(Value : Boolean);
Begin
FFocusCtl := Value;
End;
procedure TKListbox.SetFocusprior(Value : TWincontrol);
Begin
FFocusprior := Value;
inherited;
End;
procedure TKListbox.SetFocusNext(Value : TWincontrol);
Begin
FFocusNext := Value;
inherited;
End;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -