안녕하세요..!!메리 크리스마스 입니다..!!
오늘 첫눈(?)..을 보았습니다....!! 조금이지만..기분은 좋더라구요..!!
다름이 아니오라..!!
윈도우에서 보면 IP주소 입력시.....TEdit 과 비슷한 박스에 아이피 입력하는
칸이 있습니다..!^^
거기서 그러니까..델파이에서..Edit 에 . 을 넣고 싶은데...가능한지요..!!
xxx.xxx.xxx.xxx ---> 중간에 점 3개...
MaskEdit을 쓰면 되는지...!!
쓴다면 어떻개..해줘야 되는지...!!
고수님들의 손길을 기다리겠습니다..!
밖에 바람이 차더군요..!!
감기 조심하시구요..!!
> 안녕하세요..!!메리 크리스마스 입니다..!!
> 오늘 첫눈(?)..을 보았습니다....!! 조금이지만..기분은 좋더라구요..!!
> 다름이 아니오라..!!
>
> 윈도우에서 보면 IP주소 입력시.....TEdit 과 비슷한 박스에 아이피 입력하는
> 칸이 있습니다..!^^
> 거기서 그러니까..델파이에서..Edit 에 . 을 넣고 싶은데...가능한지요..!!
>
> xxx.xxx.xxx.xxx ---> 중간에 점 3개...
>
> MaskEdit을 쓰면 되는지...!!
> 쓴다면 어떻개..해줘야 되는지...!!
> 고수님들의 손길을 기다리겠습니다..!
> 밖에 바람이 차더군요..!!
> 감기 조심하시구요..!!
예전에 만든 컴포넌트 소스입니다.
그럼 이만...
{11/08 규춘이가 새롭게 만든 IPEDIT}
unit InzenIP;
{$IFDEF VER80} {$DEFINE Delphi3andLower} {$ENDIF}
{$IFDEF VER90} {$DEFINE Delphi3andLower} {$ENDIF}
{$IFDEF VER93} {$DEFINE Delphi3andLower} {$ENDIF}
{$IFDEF VER100} {$DEFINE Delphi3andLower} {$ENDIF}
{$IFDEF VER110} {$DEFINE Delphi3andLower} {$ENDIF}
{$IFNDEF Delphi3andLower}
{$DEFINE Delphi4andHigher}
{$ENDIF}
interface
uses
{$IFDEF Win32} Windows, {$Else Win32} WinTypes, WinProcs, {$ENDIF Win32}
Messages, SysUtils, StdCtrls, Classes, Graphics, Controls, Forms, Dialogs;
type
TumIPMaskEdit = class(TCustomEdit)
private
FFocused: Boolean;
procedure ClickHook(Sender: TObject);
procedure DblClickHook(Sender: TObject);
procedure KeyDownHook(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure KeyPressHook(Sender: TObject; var Key: Char);
procedure KeyUpHook(Sender: TObject; var Key: Word; Shift: TShiftState);
// 규춘이 테스트 삼아 올려 보당...
procedure WMCommand(var Msg: TWMCommand); message WM_COMMAND;
procedure WMChar(var Msg: TWMChar); message wm_Char;
procedure WMPaint(var Msg: TWMPaint); message wm_Paint;
procedure CMEnter(var Msg: TCMEnter); message cm_Enter;
procedure CMExit(var Msg: TCMExit); message cm_Exit;
protected
FCanvas: TControlCanvas;
FAlignment: TAlignment;
procedure Change; override;
procedure KeyPress(var Key: Char); override;
procedure CreateParams(var Params: TCreateParams); override;
function GetTextMargins: TPoint;
procedure SetAlignment(A: TAlignment); virtual;
procedure SetFocused (A: Boolean); virtual;
function GetCanvas: TCanvas; virtual;
public
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
published
property Alignment: TAlignment read FAlignment write SetAlignment;
end;
type
TInzenIP = class(TWinControl)
private
FAlignment: TAlignment;
FAutoSize: Boolean;
FCanvas: TCanvas;
FColor: TColor;
FColorDisabled: TColor;
FCtl3D: Boolean;
FBorderStyle: TBorderStyle;
FEnabled: Boolean;
FText: String;
FIP1, FIP2, FIP3, FIP4: Byte;
FIPLong: LongInt;
FIPSection: Array[1.. 4] of TumIPMaskEdit;
FOnChange: TNotifyEvent;
FOnKeyDown, FOnKeyUp: TKeyEvent;
FOnKeyPress: TKeyPressEvent;
procedure SetAlignment(Value: TAlignment);
procedure SetAutoSize(Value: Boolean);
procedure SetBorderStyle(Value: TBorderStyle);
procedure SetColor(Value: TColor);
procedure SetColorDisabled(Value: TColor);
procedure SetCtl3D(Value: Boolean);
procedure SetEnabled(Value: Boolean);
procedure SetText(Value: String);
procedure RefreshText;
procedure SetIP1(Value: Byte);
procedure SetIP2(Value: Byte);
procedure SetIP3(Value: Byte);
procedure SetIP4(Value: Byte);
procedure SetIPLong(Value: LongInt);
procedure ValueChanged;
procedure WMSetFocus(var Msg: TWMSetFocus); message wm_SetFocus;
procedure WMPaint(var Msg: TWMPaint); message wm_Paint;
protected
public
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
published
property Alignment: TAlignment read FAlignment write SetAlignment;
property AutoSize: Boolean read FAutoSize write SetAutoSize;
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle;
property Color: TColor read FColor write SetColor;
property ColorDisabled: TColor read FColorDisabled write SetColorDisabled;
property Ctl3D: Boolean read FCtl3D write SetCtl3D;
property Enabled: Boolean read FEnabled write SetEnabled;
property IP1: Byte read FIP1 write SetIP1;
property IP2: Byte read FIP2 write SetIP2;
property IP3: Byte read FIP3 write SetIP3;
property IP4: Byte read FIP4 write SetIP4;
property IPLong: LongInt read FIPLong write SetIPLong;
property Text: String read FText write SetText;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnKeyDown: TKeyEvent read FOnKeyDown write FOnKeyDown;
property OnKeyPress: TKeyPressEvent read FOnKeyPress write FOnKeyPress;
property OnKeyUp: TKeyEvent read FOnKeyUp write FOnKeyUp;
// inherited properties
{$IFDEF Delphi4andHigher}
property Anchors;
{$ENDIF}
property Cursor;
property Font;
property Hint;
property ShowHint;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property TabOrder;
property TabStop;
property Visible;
property OnClick;
property OnDblClick;
property OnEnter;
property OnExit;
end;
{ BONUS numerical transformation routines}
function DecToHex(aValue: LongInt): String;
function HexToDec(aValue: String ): LongInt;
function DecToBin(aValue: LongInt): String;
function BinToDec(aValue: String ): LongInt;
procedure Register;
implementation
uses WinSock;
{ BONUS numerical transformation routines}
function DecToHex(aValue : LongInt) : String;
var
w: Array[1..2] of Word absolute aValue;
St: String;
function HexByte(b: Byte): String;
const
Hex: Array[$0..$F] of Char = '0123456789ABCDEF';
begin
HexByte := Hex[b shr 4] + Hex[b and $F];
end;
function HexWord(w: Word): String;
begin
HexWord := HexByte(Hi(w)) + HexByte(Lo(w));
end;
begin
St := HexWord(w[2]) + HexWord(w[1]);
while (St[1] = '0') and (Length(St) > 1) do
Delete(St, 1, 1);
Result := St;
end;
function HexToDec(aValue: String): LongInt;
var
l: LongInt;
b: Byte;
begin
Result := 0;
if Length(aValue) <> 0 then
begin
l := 1;
b := Length(aValue) + 1;
repeat
dec(b);
if aValue[b] <= '9' then Result := Result + (Byte(aValue[b]) - 48) * l
else Result := Result + (Byte(aValue[b]) - 55) * l;
l := l * 16;
until b = 1;
end;
end;
function DecToBin(aValue: LongInt): String;
var
w: Array[1..2] of Word absolute aValue;
St: String;
function BinByte(b: Byte): String;
const
Bin: array[False..True] of Char = '01';
begin
Result := Bin[b and 128 = 128] + Bin[b and 64 = 64] + Bin[b and 32 = 32] + Bin[b and 16 = 16] +
Bin[b and 8 = 8] + Bin[b and 4 = 4] + Bin[b and 2 = 2] + Bin[b and 1 = 1];
end;
function BinWord(w: Word) : String;
begin
BinWord := BinByte(Hi(w)) + BinByte(Lo(w));
end;
begin
St := BinWord(w[2]) + BinWord(w[1]);
while (St[1] = '0') and (Length(St) > 1) do
Delete(St, 1, 1);
Result := St;
end;
function BinToDec(aValue : String) : LongInt;
var
l : LongInt;
b : Byte;
begin
Result := 0;
if Length(aValue) = 0
then Exit;
l := 1;
b := Length(aValue) + 1;
repeat
dec(b);
if aValue[b] = '1'
then Result := Result + l;
l := l shl 1;
until b = 1;
end;
{ Stuctures needed for IPEdit }
type
SunB = packed record
s_b1, s_b2, s_b3, s_b4: Char;
end;
SunW = packed record
s_w1, s_w2: Word;
end;
in_addr = record
case Integer of
0: (S_un_b: SunB);
1: (S_un_w: SunW);
2: (S_addr: LongInt);
end;
// 여기서는 Mask를 선언한당......
constructor TumIPMaskEdit.Create(aOwner: TComponent);
begin
inherited;
FCanvas := TControlCanvas.Create;
FCanvas.Control := Self;
OnClick := ClickHook;
OnDblClick := DblClickHook;
OnKeyDown := KeyDownHook;
OnKeyPress := KeyPressHook;
OnKeyUp := KeyUpHook;
end;
destructor TumIPMaskEdit.Destroy;
begin
FCanvas.Free;
inherited;
end;
procedure TumIPMaskEdit.Change;
begin
inherited;
try
TInzenIP(Parent).ValueChanged;
except
end;
end;
function TumIPMaskEdit.GetTextMargins: TPoint;
var
DC: hDC;
SaveFont: hFont;
i: Integer;
SysMetrics, Metrics: TTextMetric;
begin
if NewStyleControls then
begin
if BorderStyle = bsNone then i := 0
else
if Ctl3D then i := 1
else i := 2;
Result.X := SendMessage(Handle, EM_GETMARGINS, 0, 0) and $0000FFFF + i;
Result.Y := i;
end
else
begin
if BorderStyle = bsNone then i := 0
else
begin
DC := GetDC(0);
GetTextMetrics(DC, SysMetrics);
SaveFont := SelectObject(DC, Font.Handle);
GetTextMetrics(DC, Metrics);
SelectObject(DC, SaveFont);
ReleaseDC(0, DC);
i := SysMetrics.tmHeight;
if i > Metrics.tmHeight then i := Metrics.tmHeight;
i := i div 4;
end;
Result.X := i;
Result.Y := i;
end;
end;
procedure TumIPMaskEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
// ES_MULTILINE 속성이 있어야만 ES_RIGHT, ES_LEFT, ES_CENTER 가 동작함
Params.Style := Params.Style or ES_MULTILINE or ES_CENTER;
end;
procedure TumIPMaskEdit.SetAlignment(A: TAlignment);
begin
if FAlignment = A then Exit;
FAlignment := A;
Invalidate;
end;
procedure TumIPMaskEdit.SetFocused(A: Boolean);
begin
if FFocused = A then Exit;
FFocused := A;
end;
function TumIPMaskEdit.GetCanvas: TCanvas;
begin
Result := TCanvas(FCanvas);
end;
procedure TumIPMaskEdit.ClickHook(Sender: TObject);
begin
try
if Assigned(TInzenIP(Parent).OnClick) then
TInzenIP(Parent).OnClick(Sender);
except
end;
end;
procedure TumIPMaskEdit.DblClickHook(Sender: TObject);
begin
try
if Assigned(TInzenIP(Parent).OnDblClick) then
TInzenIP(Parent).OnDblClick(Sender);
except
end;
end;
procedure TumIPMaskEdit.KeyDownHook(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
try
if Assigned(TInzenIP(Parent).FOnKeyDown) then
TInzenIP(Parent).FOnKeyDown(Sender, Key, Shift);
except
end;
end;
procedure TumIPMaskEdit.KeyPressHook(Sender: TObject; var Key: Char);
begin
try
if Assigned(TInzenIP(Parent).FOnKeyPress) then
TInzenIP(Parent).FOnKeyPress(Sender, Key);
except
end;
end;
procedure TumIPMaskEdit.KeyUpHook(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
try
if Assigned(TInzenIP(Parent).FOnKeyUp) then
TInzenIP(Parent).FOnKeyUp(Sender, Key, Shift);
except
end;
end;
procedure TumIPMaskEdit.WMChar(var Msg: TWMChar);
var
St: String;
b, i, Code: Integer;
begin
if ((Char(Msg.CharCode) >= '0') and (Char(Msg.CharCode) <= '9')) or
(Char(Msg.CharCode) = #8) then
begin
St := Text + Char(Msg.CharCode);
{$R-} Val(St, i, Code); {$R+}
if SelLength > 0 then inherited
else if i <= 255 then inherited;
if (Length(text) > 2) and (i <= 255) then
begin
for b := 1 to 3 do
begin
if TInzenIP(Parent).FIPSection[b].Focused then
begin
TInzenIP(Parent).FIPSection[b+1].SetFocus;
Break;
end;
end;
end;
end else
// dot 나 RightKey 나 Spacebar 를 이용시 옆탭으로 이동을 하기위함
if (Char(Msg.CharCode) = '.') or (Char(Msg.CharCode) = #32) then
begin
for b := 1 to 3 do
begin
if TInzenIP(Parent).FIPSection[b].Focused then
begin
if TInzenIP(Parent).FIPSection[b].Text = '' then
TInzenIP(Parent).FIPSection[b].Text := '0';
TInzenIP(Parent).FIPSection[b+1].SetFocus;
Break;
end;
end;
end;
end;
procedure TumIPMaskEdit.KeyPress(var Key: Char);
begin
inherited KeyPress(Key);
// ES_MULTILINE 속성이 있어서 Enter 키를 막음
if Key = #13 then
Key := #0;
end;
// TEdit의 MaxLength 길이보다 많은 값을 입력하려 할때 이것은
// 부모 원도우에 EN_MAXTEXT 메시지를 보내는데 이를 받아서 구현합니다
procedure TumIPMaskEdit.WMCommand(var Msg: TWMCommand);
begin
if Msg.NotifyCode = EN_MAXTEXT then
begin
// PostMessage(Handle, WM_NEXTDLGCTL,0, 0); // 다음 콘트롤로 focus 이동
// SendMessage(Handle, WM_NEXTDLGCTL, 1, 0); // 이전으로 이동시
inherited;
end;
end;
procedure TumIPMaskEdit.WMPaint(var Msg: TWMPaint);
var
ALeft: Integer;
Margins: TPoint;
R: TRect;
DC: HDC;
PS: TPaintStruct;
strText: String;
AAlignment: TAlignment;
procedure TryToPaint;
begin
FCanvas.Font := Font;
with FCanvas do
begin
R := ClientRect;
if not (NewStyleControls and Ctl3D) and (BorderStyle = bsSingle) then
begin
Brush.Color := clWindowFrame;
FrameRect(R);
InflateRect(R, -1, -1);
end;
Brush.Color := Color;
if not Enabled then Font.Color := clGrayText;
strText := Text;
if (csPaintCopy in ControlState) then
case CharCase of
ecUpperCase: strText := AnsiUpperCase(strText);
ecLowerCase: strText := AnsiLowerCase(strText);
end;
if PasswordChar <> #0 then
FillChar(strText[1], Length(strText), PasswordChar);
Margins := GetTextMargins;
case AAlignment of
taLeftJustify: ALeft := Margins.X;
taRightJustify: ALeft := ClientWidth - TextWidth(strText) - Margins.X - 1;
else ALeft := (ClientWidth - TextWidth(strText)) div 2;
end;
TextRect(R, ALeft, Margins.Y, strText);
end;
end;
procedure PaintDefault;
begin
DC := Msg.DC;
if DC = 0 then DC := BeginPaint(Handle, PS);
FCanvas.Handle := DC;
try
TryToPaint;
finally
FCanvas.Handle := 0;
if Msg.DC = 0 then EndPaint(Handle, PS);
end;
end;
begin
// if FFocused then AAlignment := taLeftJustify
if FFocused then AAlignment := taCenter
else AAlignment := FAlignment;
PaintDefault;
inherited;
end;
procedure TumIPMaskEdit.CMEnter(var Msg: TCMEnter);
begin
SetFocused(True);
Invalidate;
inherited;
end;
procedure TumIPMaskEdit.CMExit(var Msg: TCMExit);
begin
inherited;
SetFocused(False);
Invalidate;
end;
// 여기부터는 보여질 컴포는 선언하는
constructor TInzenIP.Create(aOwner: TComponent);
var
b: Byte;
begin
inherited;
FAlignment := taCenter;
FAutoSize := True;
FBorderStyle := bsSingle;
FColor := clWindow;
FColorDisabled := clBtnFace;
FCtl3D := False;
FEnabled := True;
TabStop := True;
FCanvas := TCanvas.Create;
Width := 96;
Height := 21;
for b := 1 to 4 do
begin
FIPSection[b] := TumIPMaskEdit.Create(Self);
FIPSection[b].Top := 3;
FIPSection[b].MaxLength := 3;
FIPSection[b].BorderStyle := bsNone;
FIPSection[b].Parent := Self;
FIPSection[b].Alignment := taCenter;
end;
{ for b := 2 to 4 do
begin
FIPSection[b].TabStop := False;
end;}
end;
destructor TInzenIP.Destroy;
var
b: Byte;
begin
for b := 1 to 4 do
FIPSection[b].Free;
FCanvas.Free;
inherited;
end;
procedure TInzenIP.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
end;
end;
procedure TInzenIP.SetAutoSize(Value: Boolean);
begin
if FAutoSize <> Value then
begin
FAutoSize := Value;
Repaint;
end
end;
procedure TInzenIP.SetBorderStyle(Value: TBorderStyle);
begin
if FBorderStyle <> Value then
begin
FBorderStyle := Value;
Repaint;
end;
end;
procedure TInzenIP.SetColor(Value: TColor);
begin
if FColor <> Value then
begin
FColor := Value;
Repaint;
end;
end;
procedure TInzenIP.SetColorDisabled(Value: TColor);
begin
if FColorDisabled <> Value then
begin
FColorDisabled := Value;
Repaint;
end;
end;
procedure TInzenIP.SetCtl3D(Value: Boolean);
begin
if FCtl3D <> Value then
begin
FCtl3D := Value;
Repaint;
end;
end;
procedure TInzenIP.SetEnabled(Value: Boolean);
begin
if FEnabled <> Value then
begin
FEnabled := Value;
FIPSection[1].Enabled := FEnabled;
FIPSection[2].Enabled := FEnabled;
FIPSection[3].Enabled := FEnabled;
FIPSection[4].Enabled := FEnabled;
Repaint;
end;
end;
procedure TInzenIP.SetText(Value: String);
begin
if FText <> Value then
begin
FText := Value;
IPLong := inet_addr(PChar(Value));
end;
end;
procedure TInzenIP.RefreshText;
begin
FText := IntToStr(FIP1) + '.' + IntToStr(FIP2) + '.' +
IntToStr(FIP3) + '.' + IntToStr(FIP4);
FIPLong := (LongInt(FIP4) shl 24) +
(LongInt(FIP3) shl 16) +
(LongInt(FIP2) shl 8) +
LongInt(FIP1);
end;
procedure TInzenIP.SetIP1(Value: Byte);
var
Pos: Integer;
Imsi: String;
begin
if FIP1 <> Value then
begin
FIP1 := Value;
if Imsi = FIPSection[1].Text then FIPSection[1].Text := '' else
FIPSection[1].Text := IntToStr(FIP1);
if FIPSection[1].Focused then
begin
// Pos := Length(FIPSection[1].Text);
// SendMessage(FIPSection[1].Handle, em_SetSel, Pos, Pos);
end;
RefreshText;
end;
end;
procedure TInzenIP.SetIP2(Value: Byte);
var
Pos: Integer;
Imsi : STring;
begin
if FIP2 <> Value then
begin
FIP2 := Value;
if Imsi = FIPSection[2].Text then FIPSection[2].Text := '' else
FIPSection[2].Text := IntToStr(FIP2);
if FIPSection[2].Focused then
begin
// Pos := Length(FIPSection[2].Text);
// SendMessage(FIPSection[2].Handle, em_SetSel, Pos, Pos);
end;
RefreshText;
end;
end;
procedure TInzenIP.SetIP3(Value: Byte);
var
Pos: Integer;
Imsi: String;
begin
if FIP3 <> Value then
begin
FIP3 := Value;
if Imsi = FIPSection[3].Text then FIPSection[3].Text := '' else
FIPSection[3].Text := IntToStr(FIP3);
if FIPSection[3].Focused then
begin
// Pos := Length(FIPSection[3].Text);
// SendMessage(FIPSection[3].Handle, em_SetSel, Pos, Pos);
end;
RefreshText;
end;
end;
procedure TInzenIP.SetIP4(Value: Byte);
var
Pos: Integer;
Imsi: String;
begin
if FIP4 <> Value then
begin
FIP4 := Value;
if Imsi = FIPSection[4].Text then FIPSection[4].Text := '' else
FIPSection[4].Text := IntToStr(FIP4);
if FIPSection[4].Focused then
begin
// Pos := Length(FIPSection[4].Text);
// SendMessage(FIPSection[4].Handle, em_SetSel, Pos, Pos);
end;
RefreshText;
end;
end;
procedure TInzenIP.SetIPLong(Value: LongInt);
var
Addr: in_addr;
begin
if FIPLong <> Value then
begin
FIPLong := Value;
Addr.S_addr := FIPLong;
FIP1 := Byte(Addr.S_un_b.s_b1);
FIP2 := Byte(Addr.S_un_b.s_b2);
FIP3 := Byte(Addr.S_un_b.s_b3);
FIP4 := Byte(Addr.S_un_b.s_b4);
FText := IntToStr(FIP1) + '.' + IntToStr(FIP2) + '.' +
IntToStr(FIP3) + '.' + IntToStr(FIP4);
FIPSection[1].Text := IntToStr(Byte(Addr.S_un_b.s_b1));
FIPSection[2].Text := IntToStr(Byte(Addr.S_un_b.s_b2));
FIPSection[3].Text := IntToStr(Byte(Addr.S_un_b.s_b3));
FIPSection[4].Text := IntToStr(Byte(Addr.S_un_b.s_b4));
end;
end;
procedure TInzenIP.ValueChanged;
var
Code, i: Integer;
b: Byte;
begin
{$R-}
Val(FIPSection[1].Text, b, Code);
//if Code <> 0 then
IP1 := b;
Val(FIPSection[2].Text, b, Code);
//if Code <> 0 then
IP2 := b;
Val(FIPSection[3].Text, b, Code);
//if Code <> 0 then
IP3 := b;
Val(FIPSection[4].Text, b, Code);
//if Code <> 0 then
IP4 := b;
{$R+}
if Assigned(FOnChange) then
FOnChange(Self);
RefreshText;
{ for b := 1 to 3 do
begin
if (FIPSection[b].Focused) and (Length(FIPSection[b].Text) > 2) then
begin
FIPSection[b+1].SetFocus;
FIPSection[b+1].SelStart := 1;
Break;
end;
end;}
end;
procedure TInzenIP.WMSetFocus(var Msg: TWMSetFocus);
begin
inherited;
if FEnabled then FIPSection[1].SetFocus;
end;
procedure TInzenIP.WMPaint(var Msg: TWMPaint);
var
DC: hDC;
b: Byte;
SectionWidth, SectionHeight: Integer;
procedure PaintThisControl;
var
b: Byte;
begin
FCanvas.Font := Font;
if FEnabled then
FCanvas.Brush.Color := Color
else
FCanvas.Brush.Color := ColorDisabled;
SectionWidth := FCanvas.TextWidth('666') + 1;
SectionHeight := FCanvas.TextHeight('Sj!`,') + 2;
if not Ctl3D and (FBorderStyle <> bsNone) then
// FCanvas.Pen.Color := clBtnShadow
FCanvas.Pen.Color := clWindowFrame
else
FCanvas.Pen.Color := Color;
FCanvas.Rectangle(0, 0, Width, Height);
if Ctl3D and (FBorderStyle <> bsNone) then
begin
FCanvas.Pen.Color := clBtnShadow;
FCanvas.MoveTo(0, Height);
FCanvas.LineTo(0, 0);
FCanvas.LineTo(Width - 1, 0);
FCanvas.Pen.Color := clWindow;
FCanvas.LineTo(Width - 1, Height - 1);
FCanvas.LineTo(-1, Height - 1);
FCanvas.Pen.Color := cl3DLight;
FCanvas.MoveTo(1, Height - 2);
FCanvas.LineTo(Width - 2, Height - 2);
FCanvas.LineTo(Width - 2, 0);
FCanvas.Pen.Color := cl3DDkShadow;
FCanvas.MoveTo(Width - 3, 1);
FCanvas.LineTo(0, 1);
FCanvas.MoveTo(1, 1);
FCanvas.LineTo(1, Height - 2);
end;
FCanvas.Font.Style := FCanvas.Font.Style + [fsBold];
for b := 1 to 3 do
FCanvas.TextOut((SectionWidth + 5) * b - 1, 3, '.');
end;
begin
inherited;
DC := GetDC(Handle);
FCanvas.Handle := DC;
try
PaintThisControl;
finally
ReleaseDC(Handle, DC);
end;
// Fixing the control size
if FAutoSize then
begin
Width := (SectionWidth + 5) * 4;
Height := SectionHeight + 6;
end;
// Fixing IP sections
for b := 1 to 4 do
begin
FIPSection[b].Alignment := FAlignment;
if FEnabled then
FIPSection[b].Color := Color
else
FIPSection[b].Color := ColorDisabled;
FIPSection[b].Cursor := Cursor;
FIPSection[b].Font := Font;
FIPSection[b].ParentFont := ParentFont;
FIPSection[b].Hint := Hint;
FIPSection[b].ShowHint := ShowHint;
FIPSection[b].ParentShowHint := ParentShowHint;
FIPSection[b].PopupMenu := PopupMenu;
FIPSection[b].HelpContext := HelpContext;
FIPSection[b].Left := (SectionWidth + 5) * b - (SectionWidth + 5) + 3;
FIPSection[b].Width := SectionWidth;
FIPSection[b].Height := Height - 5;
FIPSection[b].Repaint;
end;
end;
procedure Register;
begin
RegisterComponents('InZen', [TInzenIP]);
end;
end.