Q&A

  • 판넬 자동숨김 기능?
안녕하세요
폼에서 마우스의 반응에 따라 자동숨김 기능을 알고 싶네요
고수님 한수부탁합니다.

마치 vb.net의 도구모음 같은 기능이요?

소스나 콤포넌트좀??  밥한끼 후하게 삽니다 헤헤!!


unit PHK_PAN;
interface


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

type VH_Flag = (sjVertical, sjHorizontal);

type
TPHK_PAN = class(TPanel)
private
{ Private declarations }
Finterval, FDelay: Integer;
FMaxWidth, FMinWidth: Integer;
FMaxHeight, FMinHeight : integer;
FVH_FLAG : VH_Flag;
FAutoHide: Boolean;
procedure SetAutoHide(Value: Boolean);
protected
{ Protected declarations }
RcTimer: TTimer;
procedure CheckClock(Sender: TObject);
procedure CreateWnd; override;
procedure WMSize(var Msg : TMessage); message WM_SIZE;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property Interval: Integer read FInterval write FInterval;
property Delay: Integer read FDelay write FDelay;
property MaxWidth: Integer read FMaxWidth write FMaxWidth;
property MinWidth: Integer read FMinWidth write FMinWidth;
property MaxHeight: Integer read FMaxHeight write FMaxHeight;
property MinHeight: Integer read FMinHeight write FMinHeight;
property AutoHide: Boolean read FAutoHide write SetAutoHide;
property VertHorz: VH_Flag read FVH_FLAG write FVH_FLAG;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('SAmpleS', [TPHK_PAN]);
end;

constructor TPHK_PAN.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

FInterval := 20;
FDelay := 50;
FMinWidth := 15;
FMinHeight := 5;
FAutoHide := True;
Align := alLeft;
RcTimer := TTimer.Create(Self);
RcTimer.Interval := 600;
RcTimer.OnTimer := CheckClock;
RcTimer.Enabled := True;
end;

procedure TPHK_PAN.CreateWnd;
begin
inherited CreateWnd;
FMaxWidth := Width;
FMaxHeight := Height;
end;

destructor TPHK_PAN.Destroy;
begin
RcTimer.Free;
inherited Destroy;
end;

procedure TPHK_PAN.WMSize(var Msg : TMessage);
begin
Inherited;
if (csDesigning in ComponentState) then FMaxWidth := Width;
if (csDesigning in ComponentState) then FMaxHeight := Height;
end;



procedure TPHK_PAN.CheckClock(Sender: TObject);

procedure Delay(msecs:integer);
var
FirstTickCount : longint;
begin
FirstTickCount := GetTickCount;
repeat
Application.ProcessMessages;
until ((GetTickCount - FirstTickCount) >= Longint(msecs));
end;

var
P: TPoint;
R: TRect;
_I: Integer;
begin
if (csDesigning in ComponentState) then Exit;
GetCursorPos(P);
GetWindowRect(Handle, R);
if FAutoHide then
if FVH_FLAG = sjVertical then begin
if (Align in [alBottom, alTop, alNone]) then Exit;
if (PtInRect(R, P)) and (Width = FMinWidth) then begin
_i := FMinWidth;
while _I < FMaxWidth do begin
Width := _I;
INC(_i, FInterval);
Delay(FDelay);
Refresh;
end;
Width := FMaxWidth;
end
else if (not PtInRect(R, P)) and (Width = FMaxWidth) then begin
_I := FMaxWidth;
while _I > FMinWidth do begin
Width := _I;
DEC(_i, FInterval);
Delay(FDelay);
Refresh;
end;
Width := FMinWidth;
end;
end
else begin
if (Align in [alLeft, alRight, alNone]) then Exit;
if (PtInRect(R, P)) and (Height = FMinHeight) then begin
_i := FMinHeight;
while _I < FMaxHeight do begin
Height := _I;
INC(_i, FInterval);
Delay(FDelay);
Refresh;
end;
Height := FMaxHeight;
end
else if (not PtInRect(R, P)) and (Height = FMaxHeight) then begin
_I := FMaxHeight;
while _I > FMinHeight do begin
Height := _I;
DEC(_i, FInterval);
Delay(FDelay);
Refresh;
end;
Height := FMinHeight;
end;
end;
end;

procedure TPHK_PAN.SetAutoHide(Value: Boolean);
begin
if FautoHide = Value then exit;
FAutoHide := Value;

if FAutoHide then RcTimer.Enabled := Value
else
begin
RcTimer.Enabled := False;
Width := fMaxWidth;
Height := fMaxHeight;
end;

end;


end.
0  COMMENTS