透明panel的代码要怎么写,要重新写控件吗? ( 积分: 50 )

  • 主题发起人 主题发起人 chbqq
  • 开始时间 开始时间
C

chbqq

Unregistered / Unconfirmed
GUEST, unregistred user!
As the Title
顺便问下谁有delphix的dxgEdit.exe编辑器,发给我一份
e-mail:hbid@163.com
建议大富翁开个游戏的问题分类,把游戏归到图象总不合适吧
 
As the Title
顺便问下谁有delphix的dxgEdit.exe编辑器,发给我一份
e-mail:hbid@163.com
建议大富翁开个游戏的问题分类,把游戏归到图象总不合适吧
 
写个控件:
unit Glass;

interface

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

type
TGlassStyle = (
gsBlackness, gsDstInvert, gsMergeCopy, gsMergePaint, gsNotSrcCopy,
gsNotSrcErase, gsPatCopy, gsPatInvert, gsPatPaint, gsSrcAnd,
gsSrcCopy, gsSrcErase, gsSrcInvert, gsSrcPaint, gsWhiteness);

TGlass = class(TCustomControl)
private
FColor: TColor;
FStyle: TGlassStyle;
FOnPaint: TNotifyEvent;

procedure SetColor(Value: TColor);
procedure SetStyle(Value: TGlassStyle);
procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED;
procedure WMEraseBkgnd(var Message: TMessage); message WM_ERASEBKGND;
procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
protected
Buffer: TBitmap;

procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;
procedure Resize; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Canvas;
published
property Align;
property Anchors;
property AutoSize;
property BiDiMode;
property BorderWidth;
property Color: TColor read FColor write SetColor;
property Ctl3D;
property Enabled;
property Style: TGlassStyle read FStyle write SetStyle default gsSrcAnd;
property Visible;

property OnClick;
property OnDblClick;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Croco', [TGlass]);
end;

function GlassStyleToInt(gs: TGlassStyle): LongInt;
begin
case gs of
gsBlackness : Result := cmBlackness;
gsDstInvert : Result := cmDstInvert;
gsMergeCopy : Result := cmMergeCopy;
gsMergePaint : Result := cmMergePaint;
gsNotSrcCopy : Result := cmNotSrcCopy;
gsNotSrcErase: Result := cmNotSrcErase;
gsPatCopy : Result := cmPatCopy;
gsPatInvert : Result := cmPatInvert;
gsPatPaint : Result := cmPatPaint;
gsSrcAnd : Result := cmSrcAnd;
gsSrcCopy : Result := cmSrcCopy;
gsSrcErase : Result := cmSrcErase;
gsSrcInvert : Result := cmSrcInvert;
gsSrcPaint : Result := cmSrcPaint;
gsWhiteness : Result := cmWhiteness;
else Assert(True, 'Error parameter in function GlassStyleToInt');
end;
end;

constructor TGlass.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Buffer := TBitmap.Create;

ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
csDoubleClicks, csReplicatable];
Width := 100;
Height := 100;
FStyle := gsSrcAnd;
ParentCtl3d := False;
Ctl3D := False;
ParentColor := False;
FColor := clWhite;
end;

destructor TGlass.Destroy;
begin
Buffer.Free;
inherited Destroy;
end;

procedure TGlass.Paint;
var
R: TRect;
rop: LongInt;
begin
R := Rect(0, 0, Width, Height);
Buffer.Width := Width;
Buffer.Height := Height;
Buffer.Canvas.Brush.Style := bsSolid;
Buffer.Canvas.Brush.Color := FColor;
Buffer.Canvas.FillRect(Rect(0, 0, Width, Height));
rop := GlassStyleToInt(FStyle);
StretchBlt(Buffer.Canvas.Handle, 0, 0, Width, Height,
Canvas.Handle, 0, 0, Width, Height, rop);
if Ctl3D then DrawEdge(Buffer.Canvas.Handle, R, BDR_RAISEDINNER, BF_RECT);
Buffer.Canvas.Pen.Mode := pmCopy;
Buffer.Canvas.Pen.Style := psSolid;
Canvas.Draw(0, 0, Buffer);
if Assigned(FOnPaint) then FOnPaint(Self);
end;


procedure TGlass.SetColor(Value: TColor);
begin
if Value <> FColor then
begin
FColor := Value;
RecreateWnd;
end;
end;

procedure TGlass.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);

Params.ExStyle := Params.ExStyle + WS_EX_TRANSPARENT;
end;

procedure TGlass.WMWindowPosChanging(var Message: TWMWindowPosChanging);
begin
Invalidate;

inherited;
end;

procedure TGlass.WMEraseBkgnd(var Message: TMessage);
begin
Message.Result := 0;
end;

procedure TGlass.Resize;
begin
Invalidate;

inherited;
end;

procedure TGlass.CMCtl3DChanged(var Message: TMessage);
begin
inherited;

RecreateWnd;
end;

procedure TGlass.SetStyle(Value: TGlassStyle);
begin
if Value <> FStyle then
begin
FStyle := Value;
RecreateWnd;
end;
end;

end.
 
注释 一个半透明效果的panel。很好用。可以设置透明度从1%~100%。100%为全透明。还可以设置透明渐变和Panel Skin。

unit IAsemiPanel;

interface

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


type
TIAsemiPanelPointD = record
x : Extended;
y : Extended;
end;
TIAsemiPanelPointsD = array of TIAsemiPanelPointD;
TIAsemiPanelPoints = array of TPoint;
TIAsemiPanelKind = (iaspkRect,iaspkRoundRect,iaspkCircle);
TIAsemiPanelHAlign = (iasphCenter,iasphRight,iasphLeft,iasphNone);
TIAsemiPanelVAlign = (iaspvCenter,iaspvTop,iaspvBottom,iaspvNone);
TIAsemiPanelCap3d = (iaspc3dSimple,iaspc3dEmbossed,iaspc3dPressed);
TIAsemiPanelSkinMode = (iaspsmCenter,iaspsmTile,iaspsmStretch);
TIAsemiPanel = class(TPanel)
private
{ Private declarations }
FInnerPoly ,FInnerBorderPoly ,FBorderOuterPoly ,FOuterPoly : TIAsemiPanelPoints;
FInnerPolyD,FInnerBorderPolyD,FBorderOuterPolyD,FOuterPolyD : TIAsemiPanelPointsD;
FBackBitmap : TBitmap;
ATimer : TIApanelSemiTimer;
FSemiPercent: Integer;
FHoldPaint : Integer;
FAngle: Integer;
FPanelKind: TIAsemiPanelKind;
FBevelWidthInner: TBevelWidth;
FPanelHeight: Integer;
FPanelWidth: Integer;
FCaptionFixed: boolean;
FCaptionAngle: integer;
FCaptionHAlign: TIAsemiPanelHAlign;
FCaptionLeft: integer;
FCaptionTop: integer;
FCaptionValign: TIAsemiPanelVAlign;
FCaption3dKind: TIAsemiPanelCap3d;
FCaptionTransparent: Boolean;
FColor1: TColor;
FGradientAngle: Integer;
FSkin,FSkinL,FSkinD: TBitmap;
FSkinMode: TIAsemiPanelSkinMode;
procedure GetBeBackBitmap(ANotPaint : boolean = false);
procedure WMSIZE(var Message : TMessage); message WM_SIZE;
procedure WMMOVE(Var Message : TMessage); message WM_MOVE;
procedure CMNEEDBACK(Var Message : TMessage); message CM_NEEDBACK;
procedure WMPaint(Var Message : TMessage); message WM_PAINT;
procedure DrawOnIt(ADC : HDC = 0);
procedure DrawWithOut;
procedure SetSemiPercent(Value: Integer);
function GetHeight: Integer;
function GetWidth: Integer;
procedure SetHeight(Value: Integer);
procedure SetWidth(Value: Integer);
function GetBevelInner: TPanelBevel;
function GetBevelOuter: TPanelBevel;
function GetBevelWidth: TBevelWidth;
function GetBorderStyle: TBorderStyle;
function GetBorderWidth: TBorderWidth;
procedure SetBevelInner(Value: TPanelBevel);
procedure SetBevelOuter(Value: TPanelBevel);
procedure SetBevelWidth(Value: TBevelWidth);
procedure SetBorderStyle(Value: TBorderStyle);
procedure SetBorderWidth(Value: TBorderWidth);
procedure SetAngle(Value: Integer);
procedure SetPanelKind(Value: TIAsemiPanelKind);

procedure DefinePolys;
procedure SetBevelWidthInner(Value: TBevelWidth);
procedure RotatePolys;
procedure rotatePoly(var APolyD : TIAsemiPanelPointsD;var APoly : TIAsemiPanelPoints);
procedure SetPanelHeight(Value: Integer);
procedure SetPanelWidth(Value: Integer);
procedure DrawFore(var ABmp : TBitmap);
procedure DrawTextXY(x,y,AAngle,dcl : integer;Text : string;Aun : boolean;var BackBitmap : TBitmap);
procedure DrawTextXYall(X0,Y0,AAngle : integer;Text : string;var BackBitmap : TBitmap);
procedure DrawCaptionAll(var BackBitmap : TBitmap);
procedure SetCaptionFixed(Value: boolean);
procedure SetCaptionAngle(Value: integer);
procedure SetCaptionHAlign(Value: TIAsemiPanelHAlign);
procedure SetCaptionLeft(Value: integer);
procedure SetCaptionTop(Value: integer);
procedure SetCaptionValign(Value: TIAsemiPanelVAlign);
procedure SetCaption3dKind(Value: TIAsemiPanelCap3d);
procedure SetCaptionTransparent(Value: Boolean);
procedure SetColor1(Value: TColor);
procedure SetGradientAngle(Value: Integer);
procedure DrawGradient(C1,C2 : TColor;var backBitmap : TBitmap);
procedure SetSkin(Value: TBitmap);
procedure SetSkinMode(Value: TIAsemiPanelSkinMode);
protected
{ Protected declarations }
procedure Paint; override;
procedure CreateHandle; override;
procedure Loaded; override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property Skin : TBitmap read FSkin write SetSkin;
property SkinMode : TIAsemiPanelSkinMode read FSkinMode write SetSkinMode default iaspsmCenter;
property Angle : Integer read FAngle write SetAngle default 0;
property PanelWidth : Integer read FPanelWidth write SetPanelWidth;
property PanelHeight : Integer read FPanelHeight write SetPanelHeight;
property SemiPercent : Integer read FSemiPercent write SetSemiPercent default 45;
property Width : Integer read GetWidth write SetWidth;
property Height : Integer read GetHeight write SetHeight;
property BevelInner: TPanelBevel read GetBevelInner write SetBevelInner;
property BevelOuter: TPanelBevel read GetBevelOuter write SetBevelOuter;
property BevelWidth: TBevelWidth read GetBevelWidth write SetBevelWidth;
property BevelWidthInner : TBevelWidth read FBevelWidthInner write SetBevelWidthInner;
property BorderWidth: TBorderWidth read GetBorderWidth write SetBorderWidth;
property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle;

property PanelKind : TIAsemiPanelKind read FPanelKind write SetPanelKind default iaspkRect;
property CaptionFixed : boolean read FCaptionFixed write SetCaptionFixed default True;
property CaptionAngle : integer read FCaptionAngle write SetCaptionAngle default 0;
property CaptionHAlign : TIAsemiPanelHAlign read FCaptionHAlign write SetCaptionHAlign default iasphCenter;
property CaptionValign : TIAsemiPanelVAlign read FCaptionValign write SetCaptionValign default iaspvCenter;
property CaptionLeft : integer read FCaptionLeft write SetCaptionLeft default 5;
property CaptionTop : integer read FCaptionTop write SetCaptionTop default 5;
property Caption3dKind : TIAsemiPanelCap3d read FCaption3dKind write SetCaption3dKind default iaspc3dSimple;
property CaptionTransparent : Boolean read FCaptionTransparent write SetCaptionTransparent default false;
property Color1 : TColor read FColor1 write SetColor1 default clBtnFace;
property GradientAngle : Integer read FGradientAngle write SetGradientAngle default 0;

end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('TIA', [TIAsemiPanel]);
end;
function GetDColor(Value : Tcolor): Tcolor;
var
pR,pB,pG : pByte;
begin
result:=colortoRGB(Value);
pR:=@result;
pG:=pByte(integer(pR)+1);
pB:=pByte(integer(pG)+1);
if pR^<32 then pR^:=0 else dec(pR^,32);
if pG^<32 then pG^:=0 else dec(pG^,32);
if pB^<32 then pB^:=0 else dec(pB^,32);
end;
function GetLColor(Value : Tcolor): Tcolor;
var
pR,pB,pG : pByte;
begin
result:=colortoRGB(Value);
pR:=@result;
pG:=pByte(integer(pR)+1);
pB:=pByte(integer(pG)+1);
if pR^>223 then pR^:=255 else inc(pR^,32);
if pG^>223 then pG^:=255 else inc(pG^,32);
if pB^>223 then pB^:=255 else inc(pB^,32);
end;
function GetCColor(Color01,Color02: Tcolor;R,i :integer): Tcolor;
var
C1,C2 : Tcolor;
R1,G1,B1,R2,G2,B2 : Byte;
begin
c1:=ColorTorgb(Color01);
c2:=ColorTorgb(Color02);
R1:=Pbyte(@C1)^;
G1:=Pbyte(integer(@C1)+1)^;
B1:=Pbyte(integer(@C1)+2)^;
R2:=Pbyte(@C2)^;
G2:=Pbyte(integer(@C2)+1)^;
B2:=Pbyte(integer(@C2)+2)^;
if R<>0 then
Result:=RGB((R1+(R2-R1)*i div R),(G1+(G2-G1)*i div R),(B1+(B2-B1)*i div R))
else result:=Color01;
end;
procedure Dark24Bitmap(var B : TBitmap;N : integer);
var
i,j : integer;
pB : PByteArray;
begin
for i:=0 to B.Height-1 do
begin
pb:=B.ScanLine;
for j:=0 to 3*B.Width-1 do
begin
if pb[j]<n then pb[j]:=0 else dec(pb[j],n);
end;
end;
end;
procedure Light24Bitmap(var B : TBitmap;N : integer);
var
i,j : integer;
pB : PByteArray;
begin
for i:=0 to B.Height-1 do
begin
pb:=B.ScanLine;
for j:=0 to 3*B.Width-1 do
begin
if pb[j]>(255-n) then pb[j]:=255 else inc(pb[j],n);
end;
end;
end;
{ TIAsemiPanel }

procedure TIAsemiPanel.CMNEEDBACK(var Message: TMessage);
begin
if ATimer<>nil then ATimer.Suspend;
GetBeBackBitmap(True);
if ATimer<>nil then ATimer.Resume;
end;

constructor TIAsemiPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAngle:=0;
FPanelWidth:=inherited width;
FPanelHeight:=inherited height;
FPanelKind:=iaspkRect;
ATimer:=nil;
FSkin:=TBitmap.Create;
FSkin.PixelFormat:=pf24bit;
FSkin.Height:=0;
FSkin.Width:=0;
FSkinL:=TBitmap.Create;
FSkinL.PixelFormat:=pf24bit;
FSkinL.Height:=0;
FSkinL.Width:=0;
FSkinD:=TBitmap.Create;
FSkinD.PixelFormat:=pf24bit;
FSkinD.Height:=0;
FSkinD.Width:=0;
FSkinMode:=iaspsmCenter;
FCaptionAngle:=0;
FCaptionFixed:=true;
FCaptionHAlign :=iasphCenter;
FCaptionVAlign:=iaspvCenter;
FCaptionLeft:=5;
FCaptionTop:=5;
FColor1:=clBtnFace;
FGradientAngle:=0;
FCaption3dKind:=iaspc3dSimple;
FCaptionTransparent:=false;
FBackBitmap:=TBitmap.Create;
FBackBitmap.PixelFormat:=pf24bit;
FHoldPaint:=0;
self.controlstyle:=self.controlstyle+[csOpaque];
FSemiPercent:=45;
Font.Name:='Times New Roman';
end;

procedure TIAsemiPanel.CreateHandle;
begin
inherited CreateHandle;
ATimer := TIApanelSemiTimer.Create(True);
ATimer.Dt:=2000;
ATimer.AHandle:=self.handle;
ATimer.Resume;
DefinePolys;
DrawOnIt;
end;

procedure TIAsemiPanel.DefinePolys;
var i,dn,n,dn1 : integer;

begin
if (FpanelWidth<=0) or (FPanelHeight<=0) then exit;
case FPanelKind of
iaspkRect :
begin
setlength(FInnerPolyD,4);
setlength(FInnerBorderPolyD,4);
setlength(FBorderOuterPolyD,4);
setlength(FOuterPolyD,4);
FOuterPolyD[0].x:=0; FOuterPolyD[0].y:=0;
FOuterPolyD[1].x:=FPanelwidth;FOuterPolyD[1].y:=0;
FOuterPolyD[2].x:=FPanelwidth;FOuterPolyD[2].y:=FPanelheight;
FOuterPolyD[3].x:=0; FOuterPolyD[3].y:=FPanelheight;

if BevelOuter=bvNone then
begin
FBorderOuterPolyD[0].x:=FOuterPolyD[0].x; FBorderOuterPolyD[0].y:=FOuterPolyD[0].y;
FBorderOuterPolyD[1].x:=FOuterPolyD[1].x; FBorderOuterPolyD[1].y:=FOuterPolyD[1].y;
FBorderOuterPolyD[2].x:=FOuterPolyD[2].x; FBorderOuterPolyD[2].y:=FOuterPolyD[2].y;
FBorderOuterPolyD[3].x:=FOuterPolyD[3].x; FBorderOuterPolyD[3].y:=FOuterPolyD[3].y;
end else
begin
FBorderOuterPolyD[0].x:=FOuterPolyD[0].x+BevelWidth; FBorderOuterPolyD[0].y:=FOuterPolyD[0].y+BevelWidth;
FBorderOuterPolyD[1].x:=FOuterPolyD[1].x-BevelWidth; FBorderOuterPolyD[1].y:=FOuterPolyD[1].y+BevelWidth;
FBorderOuterPolyD[2].x:=FOuterPolyD[2].x-BevelWidth; FBorderOuterPolyD[2].y:=FOuterPolyD[2].y-BevelWidth;
FBorderOuterPolyD[3].x:=FOuterPolyD[3].x+BevelWidth; FBorderOuterPolyD[3].y:=FOuterPolyD[3].y-BevelWidth;
end;
FInnerBorderPolyD[0].x:=FBorderOuterPolyD[0].x+BorderWidth; FInnerBorderPolyD[0].y:=FBorderOuterPolyD[0].y+BorderWidth;
FInnerBorderPolyD[1].x:=FBorderOuterPolyD[1].x-BorderWidth; FInnerBorderPolyD[1].y:=FBorderOuterPolyD[1].y+BorderWidth;
FInnerBorderPolyD[2].x:=FBorderOuterPolyD[2].x-BorderWidth; FInnerBorderPolyD[2].y:=FBorderOuterPolyD[2].y-BorderWidth;
FInnerBorderPolyD[3].x:=FBorderOuterPolyD[3].x+BorderWidth; FInnerBorderPolyD[3].y:=FBorderOuterPolyD[3].y-BorderWidth;
if BevelInner=bvNone then
begin
FInnerPolyD[0].x:=FInnerBorderPolyD[0].x; FInnerPolyD[0].y:=FInnerBorderPolyD[0].y;
FInnerPolyD[1].x:=FInnerBorderPolyD[1].x; FInnerPolyD[1].y:=FInnerBorderPolyD[1].y;
FInnerPolyD[2].x:=FInnerBorderPolyD[2].x; FInnerPolyD[2].y:=FInnerBorderPolyD[2].y;
FInnerPolyD[3].x:=FInnerBorderPolyD[3].x; FInnerPolyD[3].y:=FInnerBorderPolyD[3].y;
end else
begin
FInnerPolyD[0].x:=FInnerBorderPolyD[0].x+BevelWidthInner; FInnerPolyD[0].y:=FInnerBorderPolyD[0].y+BevelWidthInner;
FInnerPolyD[1].x:=FInnerBorderPolyD[1].x-BevelWidthInner; FInnerPolyD[1].y:=FInnerBorderPolyD[1].y+BevelWidthInner;
FInnerPolyD[2].x:=FInnerBorderPolyD[2].x-BevelWidthInner; FInnerPolyD[2].y:=FInnerBorderPolyD[2].y-BevelWidthInner;
FInnerPolyD[3].x:=FInnerBorderPolyD[3].x+BevelWidthInner; FInnerPolyD[3].y:=FInnerBorderPolyD[3].y-BevelWidthInner;
end;
RotatePolys;
end;
iaspkRoundRect :
begin
dn:=BevelWidthInner+BevelWidth+BorderWidth;n:=4* (dn div 2);
dn1:=dn;
setlength(FInnerPolyD,8+n);
setlength(FInnerBorderPolyD,8+n);
setlength(FBorderOuterPolyD,8+n);
setlength(FOuterPolyD,8+n);

FOuterPolyD[0].x:=dn; FOuterPolyD[0].y:=dn-dn1;
FOuterPolyD[1].x:=FPanelwidth-dn;FOuterPolyD[1].y:=dn-dn1;

for i:=1 to dn div 2 do
begin
FOuterPolyD[1+i].x:=FPanelwidth-dn+dn1*sin(i*(pi/2)/(dn div 2 +1));
FOuterPolyD[1+i].y:=dn -dn1*cos(i*(pi/2)/(dn div 2 +1));
end;
FOuterPolyD[2+dn div 2].x:=FPanelwidth-(dn-dn1);FOuterPolyD[2+dn div 2].y:=dn;
FOuterPolyD[3+dn div 2].x:=FPanelwidth-(dn-dn1);FOuterPolyD[3+dn div 2].y:=FPanelHeight-dn;

for i:=1 to dn div 2 do
begin
FOuterPolyD[3+dn div 2+i].x:=FPanelwidth- dn+dn1*cos(i*(pi/2)/(dn div 2 +1));
FOuterPolyD[3+dn div 2+i].y:=FPanelHeight-dn+dn1*sin(i*(pi/2)/(dn div 2 +1));
end;
FOuterPolyD[4+2*(dn div 2)].x:=FPanelWidth-dn;FOuterPolyD[4+2*(dn div 2)].y:=FPanelHeight-(dn-dn1);
FOuterPolyD[5+2*(dn div 2)].x:=dn; FOuterPolyD[5+2*(dn div 2)].y:=FPanelHeight-(dn-dn1);

for i:=1 to dn div 2 do
begin
FOuterPolyD[5+2*(dn div 2)+i].x:=dn -dn1*sin(i*(pi/2)/(dn div 2 +1));
FOuterPolyD[5+2*(dn div 2)+i].y:=FPanelHeight-dn+dn1*cos(i*(pi/2)/(dn div 2 +1));
end;
FOuterPolyD[6+3*(dn div 2)].x:=(dn-dn1);FOuterPolyD[6+3*(dn div 2)].y:=FPanelHeight-dn;
FOuterPolyD[7+3*(dn div 2)].x:=(dn-dn1);FOuterPolyD[7+3*(dn div 2)].y:=dn;

for i:=1 to dn div 2 do
begin
FOuterPolyD[7+3*(dn div 2)+i].x:=dn-dn1*cos(i*(pi/2)/(dn div 2 +1));
FOuterPolyD[7+3*(dn div 2)+i].y:=dn-dn1*sin(i*(pi/2)/(dn div 2 +1));
end;
//FOuterPoly..
if BevelOuter<>bvNone then dec(dn1,BevelWidth);
FBorderOuterPolyD[0].x:=dn; FBorderOuterPolyD[0].y:=dn-dn1;
FBorderOuterPolyD[1].x:=FPanelwidth-dn;FBorderOuterPolyD[1].y:=dn-dn1;

for i:=1 to dn div 2 do
begin
FBorderOuterPolyD[1+i].x:=FPanelwidth-dn+dn1*sin(i*(pi/2)/(dn div 2 +1));
FBorderOuterPolyD[1+i].y:=dn -dn1*cos(i*(pi/2)/(dn div 2 +1));
end;
FBorderOuterPolyD[2+dn div 2].x:=FPanelwidth-(dn-dn1);FBorderOuterPolyD[2+dn div 2].y:=dn;
FBorderOuterPolyD[3+dn div 2].x:=FPanelwidth-(dn-dn1);FBorderOuterPolyD[3+dn div 2].y:=FPanelHeight-dn;

for i:=1 to dn div 2 do
begin
FBorderOuterPolyD[3+dn div 2+i].x:=FPanelwidth- dn+dn1*cos(i*(pi/2)/(dn div 2 +1));
FBorderOuterPolyD[3+dn div 2+i].y:=FPanelHeight-dn+dn1*sin(i*(pi/2)/(dn div 2 +1));
end;
FBorderOuterPolyD[4+2*(dn div 2)].x:=FPanelWidth-dn;FBorderOuterPolyD[4+2*(dn div 2)].y:=FPanelHeight-(dn-dn1);
FBorderOuterPolyD[5+2*(dn div 2)].x:=dn; FBorderOuterPolyD[5+2*(dn div 2)].y:=FPanelHeight-(dn-dn1);

for i:=1 to dn div 2 do
begin
FBorderOuterPolyD[5+2*(dn div 2)+i].x:=dn -dn1*sin(i*(pi/2)/(dn div 2 +1));
FBorderOuterPolyD[5+2*(dn div 2)+i].y:=FPanelHeight-dn+dn1*cos(i*(pi/2)/(dn div 2 +1));
end;
FBorderOuterPolyD[6+3*(dn div 2)].x:=(dn-dn1);FBorderOuterPolyD[6+3*(dn div 2)].y:=FPanelHeight-dn;
FBorderOuterPolyD[7+3*(dn div 2)].x:=(dn-dn1);FBorderOuterPolyD[7+3*(dn div 2)].y:=dn;

for i:=1 to dn div 2 do
begin
FBorderOuterPolyD[7+3*(dn div 2)+i].x:=dn-dn1*cos(i*(pi/2)/(dn div 2 +1));
FBorderOuterPolyD[7+3*(dn div 2)+i].y:=dn-dn1*sin(i*(pi/2)/(dn div 2 +1));
end;

//FBorderOuterPolyD...
dec(dn1,BorderWidth);
FInnerBorderPolyD[0].x:=dn; FInnerBorderPolyD[0].y:=dn-dn1;
FInnerBorderPolyD[1].x:=FPanelwidth-dn;FInnerBorderPolyD[1].y:=dn-dn1;

for i:=1 to dn div 2 do
begin
FInnerBorderPolyD[1+i].x:=FPanelwidth-dn+dn1*sin(i*(pi/2)/(dn div 2 +1));
FInnerBorderPolyD[1+i].y:=dn -dn1*cos(i*(pi/2)/(dn div 2 +1));
end;
FInnerBorderPolyD[2+dn div 2].x:=FPanelwidth-(dn-dn1);FInnerBorderPolyD[2+dn div 2].y:=dn;
FInnerBorderPolyD[3+dn div 2].x:=FPanelwidth-(dn-dn1);FInnerBorderPolyD[3+dn div 2].y:=FPanelHeight-dn;

for i:=1 to dn div 2 do
begin
FInnerBorderPolyD[3+dn div 2+i].x:=FPanelwidth- dn+dn1*cos(i*(pi/2)/(dn div 2 +1));
FInnerBorderPolyD[3+dn div 2+i].y:=FPanelHeight-dn+dn1*sin(i*(pi/2)/(dn div 2 +1));
end;
FInnerBorderPolyD[4+2*(dn div 2)].x:=FPanelWidth-dn;FInnerBorderPolyD[4+2*(dn div 2)].y:=FPanelHeight-(dn-dn1);
FInnerBorderPolyD[5+2*(dn div 2)].x:=dn; FInnerBorderPolyD[5+2*(dn div 2)].y:=FPanelHeight-(dn-dn1);

for i:=1 to dn div 2 do
begin
FInnerBorderPolyD[5+2*(dn div 2)+i].x:=dn -dn1*sin(i*(pi/2)/(dn div 2 +1));
FInnerBorderPolyD[5+2*(dn div 2)+i].y:=FPanelHeight-dn+dn1*cos(i*(pi/2)/(dn div 2 +1));
end;
FInnerBorderPolyD[6+3*(dn div 2)].x:=(dn-dn1);FInnerBorderPolyD[6+3*(dn div 2)].y:=FPanelHeight-dn;
FInnerBorderPolyD[7+3*(dn div 2)].x:=(dn-dn1);FInnerBorderPolyD[7+3*(dn div 2)].y:=dn;

for i:=1 to dn div 2 do
begin
FInnerBorderPolyD[7+3*(dn div 2)+i].x:=dn-dn1*cos(i*(pi/2)/(dn div 2 +1));
FInnerBorderPolyD[7+3*(dn div 2)+i].y:=dn-dn1*sin(i*(pi/2)/(dn div 2 +1));
end;
//FInnerBorderPolyD...
if BevelInner<>bvNone then dec(dn1,BevelWidthInner);
FInnerPolyD[0].x:=dn; FInnerPolyD[0].y:=dn-dn1;
FInnerPolyD[1].x:=FPanelwidth-dn;FInnerPolyD[1].y:=dn-dn1;

for i:=1 to dn div 2 do
begin
FInnerPolyD[1+i].x:=FPanelwidth-dn+dn1*sin(i*(pi/2)/(dn div 2 +1));
FInnerPolyD[1+i].y:=dn -dn1*cos(i*(pi/2)/(dn div 2 +1));
end;
FInnerPolyD[2+dn div 2].x:=FPanelwidth-(dn-dn1);FInnerPolyD[2+dn div 2].y:=dn;
FInnerPolyD[3+dn div 2].x:=FPanelwidth-(dn-dn1);FInnerPolyD[3+dn div 2].y:=FPanelHeight-dn;

for i:=1 to dn div 2 do
begin
FInnerPolyD[3+dn div 2+i].x:=FPanelwidth- dn+dn1*cos(i*(pi/2)/(dn div 2 +1));
FInnerPolyD[3+dn div 2+i].y:=FPanelHeight-dn+dn1*sin(i*(pi/2)/(dn div 2 +1));
end;
FInnerPolyD[4+2*(dn div 2)].x:=FPanelWidth-dn;FInnerPolyD[4+2*(dn div 2)].y:=FPanelHeight-(dn-dn1);
FInnerPolyD[5+2*(dn div 2)].x:=dn; FInnerPolyD[5+2*(dn div 2)].y:=FPanelHeight-(dn-dn1);

for i:=1 to dn div 2 do
begin
FInnerPolyD[5+2*(dn div 2)+i].x:=dn -dn1*sin(i*(pi/2)/(dn div 2 +1));
FInnerPolyD[5+2*(dn div 2)+i].y:=FPanelHeight-dn+dn1*cos(i*(pi/2)/(dn div 2 +1));
end;
FInnerPolyD[6+3*(dn div 2)].x:=(dn-dn1);FInnerPolyD[6+3*(dn div 2)].y:=FPanelHeight-dn;
FInnerPolyD[7+3*(dn div 2)].x:=(dn-dn1);FInnerPolyD[7+3*(dn div 2)].y:=dn;

for i:=1 to dn div 2 do
begin
FInnerPolyD[7+3*(dn div 2)+i].x:=dn-dn1*cos(i*(pi/2)/(dn div 2 +1));
FInnerPolyD[7+3*(dn div 2)+i].y:=dn-dn1*sin(i*(pi/2)/(dn div 2 +1));
end;
//FInnerPolyD...
RotatePolys;
end;
iaspkCircle :
begin
n:=(FPanelwidth+FPanelHeight) div 2;if n<8 then n:=8;
setlength(FInnerPolyD,n);
setlength(FInnerBorderPolyD,n);
setlength(FBorderOuterPolyD,n);
setlength(FOuterPolyD,n);
for i:=0 to n-1 do
begin
FOuterPolyD.x:=FPanelwidth/2+FPanelwidth*sin(i*2*pi/n)/2;
FOuterPolyD.y:=FPanelHeight/2-FPanelHeight*cos(i*2*pi/n)/2;
if BevelOuter<>bvNone then dn:=BevelWidth else dn:=0;
FBorderOuterPolyD.x:=FPanelwidth/2+(FPanelwidth-dn)*sin(i*2*pi/n)/2;
FBorderOuterPolyD.y:=FPanelHeight/2-(FPanelHeight-dn)*cos(i*2*pi/n)/2;
dn:=dn+Borderwidth;
FInnerBorderPolyD.x:=FPanelwidth/2+(FPanelwidth-dn)*sin(i*2*pi/n)/2;
FInnerBorderPolyD.y:=FPanelHeight/2-(FPanelHeight-dn)*cos(i*2*pi/n)/2;
if BevelInner<>bvNone then dn:=dn+BevelWidthInner;
FInnerPolyD.x:=FPanelwidth/2+(FPanelwidth-dn)*sin(i*2*pi/n)/2;
FInnerPolyD.y:=FPanelHeight/2-(FPanelHeight-dn)*cos(i*2*pi/n)/2;
end;
RotatePolys;
end;
end;
end;

destructor TIAsemiPanel.Destroy;
begin
if ATimer<>nil then
if ATimer.Suspended then
begin
ATimer.Terminate;
ATimer.Resume;
ATimer.WaitFor;
end else
begin
ATimer.Suspend;
ATimer.Terminate;
ATimer.Resume;
ATimer.WaitFor;
end;
FSkin.free;
FSkinL.free;
FSkinD.free;
FBackBitmap.free;
inherited Destroy;
end;
procedure TIAsemiPanel.DrawCaptionAll(var BackBitmap : TBitmap);
var
sz,sz1 : size;
AText,s : string;
X,Y,dx,dy,ax,ay,nx,ny,cx,cy,p1,p2,Buttondepth : integer;

begin
x:=0;y:=0;
Buttondepth:=Borderwidth;
if BevelOuter<>bvNone then ButtonDepth:=ButtonDepth+BevelWidth;
if BevelInner<>bvNone then ButtonDepth:=ButtonDepth+BevelWidthInner;
BackBitmap.Canvas.font.Assign(self.font);
AText:=caption;
sz.cx:=0;sz.cy:=0;
while AText<>'' do
begin
p1:=pos('&amp;',AText);
p2:=pos('&amp;&amp;',AText);
if p1=0 then
begin
s:=AText;
AText:='';
end else
begin
if p1=p2 then
begin
s:=copy(AText,1,p1);
AText:=copy(AText,p1+2,length(AText)-p1-1);
end else
begin
s:=copy(AText,1,p1-1);
AText:=copy(AText,p1+1,length(AText)-p1);
end;
end;
GetTextExtentPoint32(BackBitmap.Canvas.handle,@(s[1]),length(s),sz1);
inc(sz.cx,sz1.cx);if sz.cy=0 then inc(sz.cy,sz1.cy);
end;
AText:=caption;
if FCaptionFixed then
begin
dx:=round(sz.cx*abs(cos((CaptionAngle-Angle)*pi/1800))+sz.cy*abs(sin((CaptionAngle-Angle)*pi/1800)));
dy:=round(sz.cx*abs(sin((CaptionAngle-Angle)*pi/1800))+sz.cy*abs(cos((CaptionAngle-Angle)*pi/1800)));
if sin((CaptionAngle-Angle)*pi/1800)>0 then
begin
if cos((CaptionAngle-Angle)*pi/1800)>0 then
begin
ax:=0;ay:=round(sz.cx*abs(sin((CaptionAngle-Angle)*pi/1800)));
end else
begin
ax:=round(sz.cx*abs(cos((CaptionAngle-Angle)*pi/1800)));ay:=dy;
end;
end else
begin
if cos((CaptionAngle-Angle)*pi/1800)>0 then
begin
ax:=round(sz.cy*abs(sin((CaptionAngle-Angle)*pi/1800)));ay:=0;
end else
begin
ax:=dx;ay:=round(sz.cy*abs(cos((CaptionAngle-Angle)*pi/1800)));
end;
end;
case FCaptionHAlign of
iasphLeft : x:=Buttondepth+4;
iasphCenter : x:=(PanelWidth-dx) div 2;
iasphRight : x:=PanelWidth-Buttondepth-4-dx;
iasphNone : x:=CaptionLeft;
end;
case FCaptionVAlign of
iaspvTop : y:=Buttondepth+4;
iaspvCenter : y:=(PanelHeight-dy) div 2;
iaspvBottom : y:=PanelHeight-ButtonDepth-4-dy;
iaspvNone : y:=CaptionTop;
end;
nx:=round((x+ax)*cos(Angle*pi/1800)+(y+ay)*sin(Angle*pi/1800));
ny:=round(-(x+ax)*sin(Angle*pi/1800)+(y+ay)*cos(Angle*pi/1800));
cx:=round(PanelWidth*cos(Angle*pi/1800)/2+PanelHeight*sin(Angle*pi/1800)/2);
cy:=round(-PanelWidth*sin(Angle*pi/1800)/2+PanelHeight*cos(Angle*pi/1800)/2);
nx:=(width div 2-cx)+nx;
ny:=(height div 2-cy)+ny;
DrawTextXYall(nx,ny,CaptionAngle,AText,BackBitmap);
end else
begin
dx:=round(sz.cx*abs(cos(CaptionAngle*pi/1800))+sz.cy*abs(sin(CaptionAngle*pi/1800)));
dy:=round(sz.cx*abs(sin(CaptionAngle*pi/1800))+sz.cy*abs(cos(CaptionAngle*pi/1800)));
if sin((CaptionAngle)*pi/1800)>0 then
begin
if cos((CaptionAngle)*pi/1800)>0 then
begin
ax:=0;ay:=round(sz.cx*abs(sin((CaptionAngle)*pi/1800)));
end else
begin
ax:=round(sz.cx*abs(cos((CaptionAngle)*pi/1800)));ay:=dy;
end;
end else
begin
if cos((CaptionAngle)*pi/1800)>0 then
begin
ax:=round(sz.cy*abs(sin((CaptionAngle)*pi/1800)));ay:=0;
end else
begin
ax:=dx;ay:=round(sz.cy*abs(cos((CaptionAngle)*pi/1800)));
end;
end;
case FCaptionHAlign of
iasphLeft : x:=Buttondepth+4;
iasphCenter : x:=(width-dx) div 2;
iasphRight : x:=width-Buttondepth-4-dx;
iasphNone : x:=CaptionLeft;
end;
case FCaptionVAlign of
iaspvTop : y:=Buttondepth+4;
iaspvCenter : y:=(height-dy) div 2;
iaspvBottom : y:=height-ButtonDepth-4-dy;
iaspvNone : y:=CaptionTop;
end;
DrawTextXYall(x+ax,y+ay,CaptionAngle,AText,BackBitmap);
end;
end;
procedure TIAsemiPanel.DrawTextXYall(X0,Y0,AAngle : integer;Text : string;var BackBitmap : TBitmap);
var p1,p2,i,k,x,y,dx,dy : integer;
AText,s : string;
sz : size;
begin
s:=Text;k:=0;x:=x0;y:=y0;dx:=0;dy:=0;
for i:=-1 to 1 do
begin
case FCaption3dKind of
iaspc3dSimple : if i<>0 then continue else begin k:=0; end;
iaspc3dEmbossed : begin
if i=-1 then begin k:=1;dx:=-1;dy:=-1; end else
if i=0 then begin k:=-1;dx:=1;dy:=1; end else begin k:=0;dx:=0;dy:=0; end;

end;
iaspc3dPressed : begin
if i=-1 then begin k:=-1;dx:=-1;dy:=-1; end else
if i=0 then begin k:=1;dx:=1;dy:=1; end else begin k:=0;dx:=0;dy:=0; end;

end;
end;
Text:=s;x0:=x;y0:=y;
while Text<>'' do
begin
p1:=pos('&amp;',Text);
p2:=pos('&amp;&amp;',Text);
if p1=0 then
begin
DrawTextXY(X0+dx,Y0+dy,AAngle,k,Text,false,Backbitmap);
Text:='';
end else
begin
if p1=p2 then
begin
AText:=copy(Text,1,p1);
GetTextExtentPoint32(BackBitmap.Canvas.handle,@(AText[1]),length(AText),sz);
DrawTextXY(X0+dx,Y0+dy,AAngle,k,AText,false,Backbitmap);
X0:=X0+round(sz.cx*cos(AAngle*pi/1800));
Y0:=Y0+round(-sz.cx*sin(AAngle*pi/1800));
Text:=copy(Text,p1+2,length(Text)-p1-1);
end else
begin
AText:=copy(Text,1,p1-1);
GetTextExtentPoint32(BackBitmap.Canvas.handle,@(AText[1]),length(AText),sz);
DrawTextXY(X0+dx,Y0+dy,AAngle,k,AText,false,Backbitmap);
X0:=X0+round(sz.cx*cos(AAngle*pi/1800));
Y0:=Y0+round(-sz.cx*sin(AAngle*pi/1800));
if p1=length(text) then text:=text+' ';
AText:=copy(Text,p1+1,1);
GetTextExtentPoint32(BackBitmap.Canvas.handle,@(AText[1]),length(AText),sz);
DrawTextXY(X0+dx,Y0+dy,AAngle,k,AText,true,Backbitmap);
X0:=X0+round(sz.cx*cos(AAngle*pi/1800));
Y0:=Y0+round(-sz.cx*sin(AAngle*pi/1800));
Text:=copy(Text,p1+2,length(Text)-p1-1);
end;
end;
end;
end;
end;
procedure TIAsemiPanel.DrawTextXY(x,y,AAngle,dcl : integer;Text : string;Aun : boolean;var BackBitmap : TBitmap);
var
MyFont,Oldfont : HFONT;
MyLFont : LOGFONT;
begin
if not enabled then
BackBitmap.Canvas.font.Color:=getLcolor(color) else
BackBitmap.Canvas.font.Color:=self.font.color;
if BackBitmap.Canvas.Font.Color=clNone then Exit;
if dcl>0 then BackBitmap.Canvas.font.Color:=getLColor(Color);
if dcl<0 then BackBitmap.Canvas.font.Color:=getDColor(Color);
GETOBJECT(BackBitmap.Canvas.Font.Handle,sizeof(MyLFont),@MyLFont);
MyLfont.lfEscapement :=AAngle;
MyLFont.lfOrientation:=AAngle;
if Aun then MyLFont.lfUnderline:=1;
MyFont:=CREATEFONTINDIRECT(MyLFont);
Oldfont:=selectObject(BackBitmap.canvas.handle,MyFont);
BackBitmap.Canvas.Brush.Style:=bsClear;
BackBitmap.Canvas.TextOut(X,Y,Text);
deleteobject(selectobject(BackBitmap.canvas.handle,Oldfont));
BackBitmap.Canvas.Brush.Style:=bsSolid;
end;
procedure TIAsemiPanel.DrawFore(var ABmp : TBitmap);
var Lcolor,DColor : TColor;
i,j,dx,dy : integer;
p1 : array [1..4] of Tpoint;
Rgn,LRGN,DRGN : HRGN;
begin
LRGN:=CreateRectRGN(0,0,0,0);
DRGN:=CreateRectRGN(0,0,0,0);
LColor:=GetLColor(Color);
DColor:=GetDColor(Color);
// Draw the inner bitmap...
for i:=0 to length(FInnerPoly)-1 do
begin
if i=(length(FInnerPoly)-1) then
begin
p1[1].x:=FInnerPoly.x; p1[1].y:=FInnerPoly.y;
p1[2].x:=FInnerBorderPoly.x; p1[2].y:=FInnerBorderPoly.y;
p1[3].x:=FInnerBorderPoly[0].x; p1[3].y:=FInnerBorderPoly[0].y;
p1[4].x:=FInnerPoly[0].x; p1[4].y:=FInnerPoly[0].y;
end else
begin
p1[1].x:=FInnerPoly.x; p1[1].y:=FInnerPoly.y;
p1[2].x:=FInnerBorderPoly.x; p1[2].y:=FInnerBorderPoly.y;
p1[3].x:=FInnerBorderPoly[i+1].x;p1[3].y:=FInnerBorderPoly[i+1].y;
p1[4].x:=FInnerPoly[i+1].x; p1[4].y:=FInnerPoly[i+1].y;
end;
dx:=p1[3].x-p1[2].x;
dy:=p1[3].y-p1[2].y;
if dy<dx then
begin
Rgn:=CreatepolygonRGN(p1[1],4,Alternate);
if BevelInner=bvRaised then
combinergn(LRGN,LRGN,RGN,RGN_OR) else
combinergn(DRGN,DRGN,RGN,RGN_OR);

deleteobject(RGN);
end else
begin
Rgn:=CreatepolygonRGN(p1[1],4,Alternate);
if BevelInner=bvRaised then
combinergn(DRGN,DRGN,RGN,RGN_OR) else
combinergn(LRGN,LRGN,RGN,RGN_OR);
deleteobject(RGN);
end;
end;



// Draw the outer bitmap...
for i:=0 to length(FInnerPoly)-1 do
begin
if i=(length(FInnerPoly)-1) then
begin
p1[1].x:=FBorderOuterPoly.x; p1[1].y:=FBorderOuterPoly.y;
p1[2].x:=FOuterPoly.x; p1[2].y:=FOuterPoly.y;
p1[3].x:=FOuterPoly[0].x; p1[3].y:=FOuterPoly[0].y;
p1[4].x:=FBorderOuterPoly[0].x; p1[4].y:=FBorderOuterPoly[0].y;
end else
begin
p1[1].x:=FBorderOuterPoly.x; p1[1].y:=FBorderOuterPoly.y;
p1[2].x:=FOuterPoly.x; p1[2].y:=FOuterPoly.y;
p1[3].x:=FOuterPoly[i+1].x; p1[3].y:=FOuterPoly[i+1].y;
p1[4].x:=FBorderOuterPoly[i+1].x; p1[4].y:=FBorderOuterPoly[i+1].y;
end;
dx:=p1[3].x-p1[2].x;
dy:=p1[3].y-p1[2].y;
if dy<dx then
begin
Rgn:=CreatepolygonRGN(p1[1],4,Alternate);
if BevelOuter=bvRaised then
combinergn(LRGN,LRGN,RGN,RGN_OR) else
combinergn(DRGN,DRGN,RGN,RGN_OR);
deleteobject(RGN);
end else
begin
Rgn:=CreatepolygonRGN(p1[1],4,Alternate);
if BevelOuter=bvRaised then
combinergn(DRGN,DRGN,RGN,RGN_OR) else
combinergn(LRGN,LRGN,RGN,RGN_OR);
deleteobject(RGN);
end;
end;
// we begin draw the caption....
if (FSkin<>nil) and (FSkin.height<>0) and (FSkin.width<>0) and (height<>0) and (width<>0) then
begin
case SkinMode of
iaspsmCenter :
begin
ABmp.Canvas.Draw((width-FSkin.Width) div 2,(height-FSkin.height) div 2,FSkin);
selectcliprgn(ABMp.canvas.handle,LRGN);
ABmp.Canvas.Draw((width-FSkin.Width) div 2,(height-FSkin.height) div 2,FSkinL);
selectcliprgn(ABMp.canvas.handle,DRGN);
ABmp.Canvas.Draw((width-FSkin.Width) div 2,(height-FSkin.height) div 2,FSkinD);
selectcliprgn(ABMp.canvas.handle,0);
end;
iaspsmTile :
begin
for i:=0 to (height div FSkin.height) do
for j:=0 to (width div FSkin.Width) do
begin
ABmp.Canvas.Draw(FSkin.Width*j,FSkin.height*i,FSkin);
end;
selectcliprgn(ABMp.canvas.handle,LRGN);
for i:=0 to height div FSkin.height do
for j:=0 to width div FSkin.Width do
begin
ABmp.Canvas.Draw(FSkin.Width*j,FSkin.height*i,FSkinL);
end;
selectcliprgn(ABMp.canvas.handle,DRGN);
for i:=0 to height div FSkin.height do
for j:=0 to width div FSkin.Width do
begin
ABmp.Canvas.Draw(FSkin.Width*j,FSkin.height*i,FSkinD);
end;
selectcliprgn(ABMp.canvas.handle,0);
end;
iaspsmStretch :
begin
ABmp.Canvas.StretchDraw(rect(0,0,width,height),FSkin);
selectcliprgn(ABMp.canvas.handle,LRGN);
ABmp.Canvas.StretchDraw(rect(0,0,width,height),FSkinL);
selectcliprgn(ABMp.canvas.handle,DRGN);
ABmp.Canvas.StretchDraw(rect(0,0,width,height),FSkinD);
selectcliprgn(ABMp.canvas.handle,0);
end;
end;
end else
begin
if colortorgb(Color)=colortorgb(Color1) then
begin
ABmp.canvas.brush.color:=LColor;
fillRGN(ABMp.canvas.handle,LRGN,ABmp.canvas.brush.handle);
ABmp.canvas.brush.color:=DColor;
fillRGN(ABMp.canvas.handle,DRGN,ABmp.canvas.brush.handle);
end else
begin
DrawGradient(Color,Color1,ABmp);
selectcliprgn(ABMp.canvas.handle,LRGN);
DrawGradient(GetLColor(Color),GetLColor(Color1),ABmp);
selectcliprgn(ABMp.canvas.handle,DRGN);
DrawGradient(GetDColor(Color),GetDColor(Color1),ABmp);
selectcliprgn(ABMp.canvas.handle,0);
end;
end;
deleteObject(LRGN);
deleteobject(DRGN);
if FCaptionTransparent then DrawCaptionAll(ABmp);
end;

procedure TIAsemiPanel.DrawOnIt(ADC : HDC = 0);
var FForeBitmap : TBitmap;
p1,p2 : pByteArray;
i,j,RGNres : integer;
ACanvas : TCanvas;
RGN,RGN1 : HRGN;
begin
if ATimer<>nil then ATimer.Suspend;
ACanvas:=TCanvas.Create;
if ADC=0 then ACanvas.handle:=Canvas.handle else ACanvas.handle:=ADC;
FForeBitmap:=TBitmap.Create;
FForeBitmap.PixelFormat:=pf24bit;
FForeBitmap.Width:=FBackBitmap.width;
FForeBitmap.Height:=FBackBitmap.height;
case FSemiPercent of
0 :
begin
FForeBitmap.canvas.brush.Color:=self.Color;
FForeBitmap.Canvas.FillRect(rect(0,0,width,height));
DrawFore(FForeBitmap);
end;
else
begin
FForeBitmap.canvas.brush.Color:=self.Color;
FForeBitmap.Canvas.FillRect(rect(0,0,width,height));
DrawFore(FForeBitmap);
for i:=0 to FBackBitmap.height-1 do
begin
p1:=FBackBitmap.ScanLine;
p2:=FForeBitmap.ScanLine;
for j:=0 to (3*FBackBitmap.Width)-1 do
begin
p2[j]:=p2[j]+FSemiPercent*(p1[j]-p2[j]) div 100;
end;
end;
end;
end;
RGN1:=CreateRectRGN(0,0,width,height);
if (ADC=0) and ((csDesigning in ComponentState)) then
for i:=0 to self.ControlCount-1 do
begin
if controls is TWinControl then
begin
RGN:=CreateRectRGN(0,0,0,0);
RGNres:=integer(getwindowrgn(TWinControl(self.controls).handle,RGN));
if (RGNres=SIMPLEREGION) then
begin
deleteobject(RGN);
RGN:=CreateRectRGN(0,0,self.controls.width,self.controls.height);
end;
offsetRGN(RGN,self.controls.left,self.controls.top);
end else
begin
RGN:=CreateRectRGN(0,0,self.controls.width,self.controls.height);
offsetRGN(RGN,self.controls.left,self.controls.top);
end;
combinergn(RGN1,RGN1,RGN,RGN_DIFF);
deleteobject(RGN);
end;
selectcliprgn(ACanvas.Handle,RGN1);
if not FCaptionTransparent then DrawCaptionAll(FForeBitmap);
ACanvas.Draw(0,0,FForeBitmap);
selectcliprgn(ACanvas.Handle,0);
FForeBitmap.free;
deleteobject(rgn1);

if ADC=0 then
begin
i:=0;
while i<self.ControlCount do
begin
if (self.controls is TWinControl) then
begin
postmessage(TWinControl(self.controls).handle,WM_PAINT,0,0);
// self.controls.invalidate;
self.controls.update;
end else
begin
inc(FHoldPaint);
self.controls.invalidate;
self.controls.update;
end;
inc(i);
end;
end else
begin
for i:=0 to self.ControlCount-1 do
begin
if (self.controls is TWinControl) then
begin
inc(FHoldPaint);
end else
begin
inc(FHoldPaint);
self.controls.invalidate;
end;
end;
end;
ACanvas.Free;
if ATimer<>nil then ATimer.Resume;
end;

procedure TIAsemiPanel.DrawWithOut;
var FForeBitmap : TBitmap;
p1,p2 : pByteArray;
i,j : integer;
ACanvas : TCanvas;
RGN1 : HRGN;
begin
if ATimer<>nil then ATimer.Suspend;
ACanvas:=TCanvas.Create;
ACanvas.handle:=Canvas.handle;
FForeBitmap:=TBitmap.Create;
FForeBitmap.PixelFormat:=pf24bit;
FForeBitmap.Width:=FBackBitmap.width;
FForeBitmap.Height:=FBackBitmap.height;
case FSemiPercent of
0 :
begin
FForeBitmap.canvas.brush.Color:=self.Color;
FForeBitmap.Canvas.FillRect(rect(0,0,width,height));
DrawFore(FForeBitmap);
end;
100 : begin FForeBitmap.Canvas.Draw(0,0,FBackBitmap); DrawFore(FForeBitmap); end;
else
begin

FForeBitmap.canvas.brush.Color:=self.Color;
FForeBitmap.Canvas.FillRect(rect(0,0,width,height));
DrawFore(FForeBitmap);
for i:=0 to FBackBitmap.height-1 do
begin
p1:=FBackBitmap.ScanLine;
p2:=FForeBitmap.ScanLine;
for j:=0 to (3*FBackBitmap.Width)-1 do
begin
p2[j]:=p2[j]+FSemiPercent*(p1[j]-p2[j]) div 100;
end;
end;

end;
end;


RGN1:=CreateRectRGN(0,0,width,height);
selectcliprgn(ACanvas.Handle,RGN1);
if not FCaptionTransparent then DrawCaptionAll(FForeBitmap);
ACanvas.Draw(0,0,FForeBitmap);
validatergn(handle,RGN1);
selectcliprgn(ACanvas.Handle,0);
FForeBitmap.free;
deleteobject(rgn1);
ACanvas.Free;
if ATimer<>nil then ATimer.Resume;
end;

procedure TIAsemiPanel.GetBeBackBitmap(ANotPaint : boolean = false);
var
ABitmap,A1 : TBitmap;
p1,p2 : pByteArray;
i,j : integer;
differ : Boolean;
begin
FBackBitmap.Width:=width;
FBackBitmap.height:=height;
if assigned(parent) then
begin
ABitmap:=TBitmap.Create;
ABitmap.PixelFormat:=pf24bit;
ABitmap.Width:=-parent.ClientOrigin.x+ClientOrigin.x+width;
ABitmap.Height:=-parent.ClientOrigin.y+ClientOrigin.y+height;
ABitmap.Canvas.brush.Color:=TCustomForm(parent).Color;
ABitmap.Canvas.FillRect(rect(0,0,ABitmap.width,ABitmap.height));

sendmessage(parent.handle,WM_PAINT,ABitmap.Canvas.handle,0);
Application.ProcessMessages;
A1:=TBitmap.Create;
A1.PixelFormat:=pf24Bit;
a1.width:=FBackBitmap.Width;
a1.Height:=FBackBitmap.Height;
A1.Canvas.Draw(0,0,FBackBitmap);
FBackBitmap.Canvas.Draw(parent.ClientOrigin.x-ClientOrigin.x,parent.ClientOrigin.y-ClientOrigin.y,ABitmap);
ABitmap.free;
if ANotPaint then
begin
differ:=false;
for i:=0 to FBackbitmap.Height-1 do
begin
p1:=FBackBitmap.ScanLine;
p2:=A1.ScanLine;
for j:=0 to 3*FBackBitmap.Width-1 do
begin
if p1[j]<>p2[j] then begin differ:=true; break; end;
end;
if differ then break;
end;
if differ then begin DrawOnIt; end;
end else invalidate;
A1.free;
end;
end;

function TIAsemiPanel.GetBevelInner: TPanelBevel;
begin
result:=inherited BevelInner;
end;

function TIAsemiPanel.GetBevelOuter: TPanelBevel;
begin
result:=inherited BevelOuter;
end;

function TIAsemiPanel.GetBevelWidth: TBevelWidth;
begin
result:=inherited BevelWidth;
end;

function TIAsemiPanel.GetBorderStyle: TBorderStyle;
begin
result:=inherited BorderStyle;
end;

function TIAsemiPanel.GetBorderWidth: TBorderWidth;
begin
result:=inherited BorderWidth;
end;

function TIAsemiPanel.GetHeight: Integer;
begin
result:=inherited Height;
end;

function TIAsemiPanel.GetWidth: Integer;
begin
result:=inherited Width;
end;

procedure TIAsemiPanel.Loaded;
begin
inherited Loaded;
FSkinL.Height:=FSkin.Height;
FSkinL.Width:=FSkin.Width;
FSkinL.Canvas.Draw(0,0,FSkin);
FSkinD.Height:=FSkin.Height;
FSkinD.Width:=FSkin.Width;
FSkinD.Canvas.Draw(0,0,FSkin);
Light24Bitmap(FSkinL,64);
Dark24Bitmap(FSkinD,64);
DrawOnIt;
end;

procedure TIAsemiPanel.Paint;
begin
if FHoldPaint>0 then begin dec(FHoldPaint);DrawWithOut; exit; end;
DrawOnIt;
postmessage(self.handle,CM_NEEDBACK,0,0);
DrawOnIt;
end;

procedure TIAsemiPanel.rotatePoly(var APolyD: TIAsemiPanelPointsD;var APoly: TIAsemiPanelPoints);
var i : Integer;
dx,dy : extended;
begin
setlength(APoly,length(APolyD));
dx:=(FPanelWidth*cos(Angle*pi/1800)+FPanelHeight*sin(Angle*pi/1800))/2;
dy:=(-FPanelWidth*sin(Angle*pi/1800)+FPanelHeight*cos(Angle*pi/1800))/2;
dx:=width/2-dx;
dy:=height/2-dy;
for i:=0 to length(APolyD)-1 do
begin
APoly.x:=round( APolyD.x*cos(Angle*pi/1800)+APolyD.y*sin(Angle*pi/1800)+dx);
APoly.y:=round(-APolyD.x*sin(Angle*pi/1800)+APolyD.y*cos(Angle*pi/1800)+dy);
end;
end;

procedure TIAsemiPanel.RotatePolys;
var
RGN : HRGN;
begin
movewindow(handle,left,top,
round(abs(FPanelwidth*cos(Angle*pi/1800)) + abs (FPanelheight*sin(Angle*pi/1800))),
round(abs(FPanelwidth*sin(Angle*pi/1800)) + abs (FPanelheight*cos(Angle*pi/1800))),TRUE);
rotatePoly(FInnerPolyD,FInnerPoly);
rotatePoly(FInnerBorderPolyD,FInnerBorderPoly);
rotatePoly(FBorderOuterPolyD,FBorderOuterPoly);
rotatePoly(FOuterPolyD,FOuterPoly);
RGN:=CreatePolygonRGN(FOuterPoly[0],length(FOuterPoly),Alternate);
setwindowrgn(handle,RGN,TRUE);
end;

procedure TIAsemiPanel.SetAngle(Value: Integer);
var da : integer;
begin
while Value>1800 do dec(Value,3600);
while Value<=-1800 do inc(Value,3600);
if FAngle<>Value then
begin
da:=Value-FAngle;
FAngle := Value;
if FCaptionFixed then inc(FCaptionAngle,da);
DefinePolys;
invalidate;
end;
end;

procedure TIAsemiPanel.SetBevelInner(Value: TPanelBevel);
begin
if Value<>Inherited BevelInner then
begin
Inherited BevelInner:=Value;
DefinePolys;
end;
end;

procedure TIAsemiPanel.SetBevelOuter(Value: TPanelBevel);
begin
if Value<>Inherited BevelOuter then
begin
Inherited BevelOuter:=Value;
DefinePolys;
end;
end;

procedure TIAsemiPanel.SetBevelWidth(Value: TBevelWidth);
begin
if Value<>Inherited BevelWidth then
begin
Inherited BevelWidth:=Value;
DefinePolys;
end;
end;

procedure TIAsemiPanel.SetBevelWidthInner(Value: TBevelWidth);
begin
if Value<>FBevelWidthInner then
begin
FBevelWidthInner := Value;
DefinePolys;
invalidate;
end;
end;

procedure TIAsemiPanel.SetBorderStyle(Value: TBorderStyle);
begin
if Value<>Inherited BorderStyle then
begin
Inherited BorderStyle:=Value;
DefinePolys;
end;
end;

procedure TIAsemiPanel.SetBorderWidth(Value: TBorderWidth);
begin
if Value<>Inherited BorderWidth then
begin
Inherited BorderWidth:=Value;
DefinePolys;
end;
end;

procedure TIAsemiPanel.SetHeight(Value: Integer);
begin
if Value<>Inherited Height then
begin
if (Angle=0) or (Angle=1800) then PanelHeight:=Value;
if (Angle=900) or (Angle=-900) then PanelWidth:=Value;
DefinePolys;
end;
end;

procedure TIAsemiPanel.SetPanelHeight(Value: Integer);
begin
if (Value>=0) and (FPanelHeight<>Value) then
begin
FPanelHeight:=Value;
DefinePolys;
invalidate;
end;
end;

procedure TIAsemiPanel.SetPanelKind(Value: TIAsemiPanelKind);
begin
if FPanelKind<>Value Then
begin
FPanelKind := Value;
DefinePolys;
invalidate;
end;
end;

procedure TIAsemiPanel.SetPanelWidth(Value: Integer);
begin
if (Value>=0) and (FPanelWidth<>Value) then
begin
FPanelWidth := Value;
DefinePolys;
invalidate;
end;
end;

procedure TIAsemiPanel.SetSemiPercent(Value: Integer);
begin
if (FSemiPercent<>Value) and (Value>=0) and (Value<=100) then
begin
FSemiPercent := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetWidth(Value: Integer);
begin
if Value<>Inherited Width then
begin
if (Angle=0) or (Angle=1800) then PanelWidth:=Value;
if (Angle=900) or (Angle=-900) then PanelHeight:=Value;
DefinePolys;
end;
end;

procedure TIAsemiPanel.WMMOVE(var Message: TMessage);
begin
inherited;
postmessage(self.handle,CM_NEEDBACK,0,0);
Message.Result:=0;
end;

procedure TIAsemiPanel.WMPaint(var Message: TMessage);
begin
if Message.WParam<>0 then
begin
DrawOnIt(HDC(Message.WPARAM));
Message.Result:=0;
end;
inherited;
end;

procedure TIAsemiPanel.WMSIZE(var Message: TMessage);
begin
inherited;
postmessage(self.handle,CM_NEEDBACK,0,0);
Message.Result:=0;
if not((Angle=0) or (Angle=1800) or (Angle=900) or (Angle=-900)) then
begin
if (width<>round(abs(FPanelwidth*cos(Angle*pi/1800)) + abs (FPanelheight*sin(Angle*pi/1800)))) or
(Height<>round(abs(FPanelwidth*sin(Angle*pi/1800)) + abs (FPanelheight*cos(Angle*pi/1800))))
then
begin
DefinePolys;
end;
end else
begin
if (Angle=0) or (Angle=1800) then
begin
FPanelWidth:=Width;
FPanelHeight:=Height;
end else
begin
FPanelWidth:=Height;
FPanelHeight:=Width;
end;
DefinePolys;
end;
end;

procedure TIAsemiPanel.SetCaptionFixed(Value: boolean);
begin
if Value<> FCaptionFixed then
begin
FCaptionFixed := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetCaptionAngle(Value: integer);
begin
while Value>1800 do dec(Value,3600);
while Value<=-1800 do inc(Value,3600);
if FCaptionAngle<>Value then
begin
FCaptionAngle := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetCaptionHAlign(Value: TIAsemiPanelHAlign);
begin
if value<> FCaptionHAlign then
begin
FCaptionHAlign := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetCaptionLeft(Value: integer);
begin
if Value<>FCaptionLeft then
begin
FCaptionLeft := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetCaptionTop(Value: integer);
begin
if Value<>FCaptionTop then
begin
FCaptionTop := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetCaptionValign(Value: TIAsemiPanelVAlign);
begin
if value<> FCaptionValign then
begin
FCaptionValign := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetCaption3dKind(Value: TIAsemiPanelCap3d);
begin
if value<> FCaption3dKind then
begin
FCaption3dKind := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetCaptionTransparent(Value: Boolean);
begin
if value<> FCaptionTransparent then
begin
FCaptionTransparent := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetColor1(Value: TColor);
begin
if value<> FColor1 then
begin
FColor1 := Value;
invalidate;
end;
end;

procedure TIAsemiPanel.SetGradientAngle(Value: Integer);
begin
while Value>1800 do dec(Value,3600);
while Value<=-1800 do inc(Value,3600);
if FGradientAngle<>Value then
begin
FGradientAngle:= Value;
invalidate;
end;
end;

procedure TIAsemiPanel.DrawGradient(C1, C2: TColor; var backBitmap: TBitmap);
var
NofLines,i,Q : Integer;
L,dx,dy,x0,y0,L0,Cs,Sn : Double;
begin
C1:=ColortoRGB(C1);
C2:=ColortoRGB(C2);

Cs:=cos(FGradientAngle*pi/1800);
Sn:=sin(FGradientAngle*pi/1800);
L:=abs( Width*Sn)+abs( Height*Cs);
L0:=sqrt(sqr( Width)+sqr( Height));
backBitmap.Canvas.Pen.width:=round(L / 96);
if backBitmap.Canvas.Pen.width<3 then backBitmap.Canvas.Pen.width:=3;
NofLines:=round(L/backBitmap.Canvas.Pen.width);q:=0;
if (Cs>=0) and (Sn>=0) then Q:=1;
if (Cs>=0) and (Sn<0) then Q:=4;
if (Cs<0) and (Sn>=0) then Q:=2;
if (Cs<0) and (Sn<0) then Q:=3;
dx:=backBitmap.Canvas.Pen.width*Sn;dy:=backBitmap.Canvas.Pen.width*Cs;x0:=0;y0:=0;
if q=1 then
begin
x0:= width*(1-sqr(Sn));
y0:=- width*Sn*Cs;
end;
if q=2 then
begin
x0:= height*Sn*Cs;
y0:= Height*(1-sqr(Sn));
end;
if q=3 then
begin
x0:= width*sqr(Sn);
y0:= height+ width*Sn*Cs;
end;
if q=4 then
begin
x0:= width- height*Sn*Cs;
y0:= Height*(1-sqr(Cs));
end;
for i:=0 to NofLines do
begin
BackBitmap.Canvas.Pen.color:=GetCColor(C1,C2,NofLines,i);
BackBitmap.Canvas.Moveto(round(x0+i*dx),Round(y0+i*dy));
BackBitmap.Canvas.Lineto(round(x0+i*dx-L0*Cs),
Round(y0+i*dy+L0*Sn));
end;
end;

procedure TIAsemiPanel.SetSkin(Value: TBitmap);
begin
if (Value=nil) or (Value.height=0) then
begin
FSkin.Height:=0;
FSkin.Width:=0;
invalidate;
end else
begin
FSkin.Height:=Value.Height;
FSkin.Width:=Value.Width;
FSkin.Canvas.Draw(0,0,Value);
FSkinL.Height:=Value.Height;
FSkinL.Width:=Value.Width;
FSkinL.Canvas.Draw(0,0,Value);
FSkinD.Height:=Value.Height;
FSkinD.Width:=Value.Width;
FSkinD.Canvas.Draw(0,0,Value);
Light24Bitmap(FSkinL,64);
Dark24Bitmap(FSkinD,64);
invalidate;
end;
end;

procedure TIAsemiPanel.SetSkinMode(Value: TIAsemiPanelSkinMode);
begin
if value<> FSkinMode then
begin
FSkinMode := Value;
invalidate;
end;
end;

end.

unit IATimerSemiPanel;

interface

uses
Windows,Messages,Classes,Controls;
const
CM_NEEDBACK = CM_BASE+101;
type
TIApanelSemiTimer = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
Dt : integer;
AHandle : HWND;
end;

implementation

{ Important: Methods and properties of objects in VCL can only be used in a
method called using Synchronize, for example,

Synchronize(UpdateCaption);

and UpdateCaption could look like,

procedure TIApanelSemiTimer.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }

{ TIApanelSemiTimer }

procedure TIApanelSemiTimer.Execute;
var i : integer;
begin
repeat
postMessage(AHandle,CM_NEEDBACK,0,0);
for i:=1 to 20 do
begin
sleep(Dt div 20);
if Terminated then break;
end;
if Terminated then break;
until self.Terminated;
end;

end.
 
晕,这么多,把你那个控件直接发到我邮箱里,有demo也发一份,可以用就给你加分
 
啧,你连看都懒得看,这又怎么对得起作者的劳作成果,当时我找到这个控件也花也一些功夫的,既然你这样说,这口气很让我失落,其实我也不是很在乎这些分的,赚分与我来说不过是游戏,你看吧
 
啊,真是非常抱歉。好吧,我拷下来慢慢消化,等行了再给你加分,不过下次希望回答问题的时候能直接把控件传上去,在delphi编译器看的时候比较清楚、直观
 
多人接受答案了。
 
继续努力,继续学习!
好好学习,天天在线!
■■■■■ ■ ■ ■
■ ■ ■ ■ ■
■■■■■ ■ ■■■■ ■■■■■
■ ■ ■ ■ ■ ■ ■
■■■■■■■■ ■ ■■■■■■■ ■ ■
■ ■ ■ ■
■■■■■ ■ ■■■■■ ■
■ ■■ ■ ■ ■ ■
■■■■■ ■ ■■■■■ ■ ■
■ ■■ ■
■ ■ ■ ■ ■ ■ ■ ■
■ ■■ ■ ■ ■ ■ ■
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
778
import
I
I
回复
0
查看
659
import
I
后退
顶部