椭圆形状的按扭是怎么做出来的? RT,羡慕的水谁能指教一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你要这玩意干嘛?你去下一去SUIPAGE看看,里面的按钮有一个属性是可以改为椭圆的,就象苹果机按钮一样 用api应该能画出来的,画圆的窗体都能画出来 回复人: voyager(大地瓜) ( ) 信誉:97 2004-10-08 13:05:00 得分: 0 RZ的图按按钮不知能否满足你的要求? 肯定能,以前没用过这些套件,那天反编译了一下别人软件,就为那华丽的界面。结果发觉都是用的它如果楼主也有我这想法的话,请下载raise套件.呵呵不是打广告 //超级猛料unit RVButton; interface uses SysUtils, Classes, Controls, Messages, Graphics, Windows; const iOffset = 3; type TRVButton = class(TGraphicControl) private FCaption : string; FButtonColor: TColor; FLButtonDown: boolean; FBtnPoints : array[1..2] of TPoint; FKRgn : HRgn; procedure SetCaption(Value: string); procedure SetButtonColor(Value: TColor); procedure FreeRegion; protected procedure Paint; override; procedure DrawCircle; procedure MoveButton; procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN; procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published property ButtonColor: TColor read FButtonColor write SetButtonColor; property Caption: string read FCaption write SetCaption; property Enabled; property Font; property ParentFont; property ParentShowHint; property ShowHint; property Visible; property OnClick; end; procedure Register; implementation procedure Register; begin RegisterComponents('Samples', [TRVButton]); end; { TRVButton } constructor TRVButton.Create(AOwner: TComponent); begin inherited Create(AOwner); ControlStyle := [csClickEvents,csCaptureMouse]; Width := 50; Height := 50; FButtonColor := clBtnFace; FKRgn := 0; FLButtonDown := False; end; destructor TRVButton.Destroy; begin if FKRgn <> 0 then FreeRegion; inherited Destroy; end; procedure TRVButton.DrawCircle; begin FBtnPoints[1] := Point(iOffset,iOffset); FBtnPoints[2] := Point(Width - iOffset,Height - iOffset); FKRgn := CreateEllipticRgn(FBtnPoints[1].x,FBtnPoints[1].y,FBtnPoints[2].x,FBtnPoints[2].y); Canvas.Brush.Color := FButtonColor; FillRgn(Canvas.Handle,FKRgn,Canvas.Brush.Handle); MoveButton; end; procedure TRVButton.FreeRegion; begin if FKRgn <> 0 then DeleteObject(FKRgn); FKRgn := 0; end; procedure TRVButton.MoveButton; var Color1: TColor; Color2: TColor; begin with Canvas do begin if not FLButtonDown then begin Color1 := clBtnHighlight; Color2 := clBtnShadow; end else begin Color1 := clBtnShadow; Color2 := clBtnHighLight; end; Pen.Width := 1; if FLButtonDown then Pen.Color := clBlack else Pen.Color := Color2; Ellipse(FBtnPoints[1].x - 2,FBtnPoints[1].y - 2,FBtnPoints[2].x + 2,FBtnPoints[2].y + 2); if not FLButtonDown then Pen.Width := 2 else Pen.Width := 1; Pen.Color := Color1; Arc(FBtnPoints[1].x,FBtnPoints[1].y,FBtnPoints[2].x,FBtnPoints[2].y, FBtnPoints[2].x,FBtnPoints[1].y,FBtnPoints[1].x,FBtnPoints[2].y); Pen.Color := Color2; Arc(FBtnPoints[1].x,FBtnPoints[1].y,FBtnPoints[2].x,FBtnPoints[2].y, FBtnPoints[1].x,FBtnPoints[2].y,FBtnPoints[2].x,FBtnPoints[1].y); end; SetCaption(''); end; procedure TRVButton.Paint; begin inherited Paint; FreeRegion; DrawCircle; end; procedure TRVButton.SetButtonColor(Value: TColor); begin if Value <> FButtonColor then begin FButtonColor := Value; Invalidate; end; end; procedure TRVButton.SetCaption(Value: string); var X: Integer; Y: Integer; begin if ((Value <> FCaption) and (Value <> '')) then begin FCaption := Value; end; with Canvas.Font do begin Name := Font.Name; Size := Font.Size; Style := Font.Style; if Self.Enabled then Color := Font.Color else Color := clDkGray; end; X := (Width div 2) - (Canvas.TextWidth(FCaption) div 2); Y := (Height div 2) - (Canvas.TextHeight(FCaption) div 2); Canvas.TextOut(X, Y, FCaption); // Invalidate; end; procedure TRVButton.WMLButtonDown(var Message: TWMLButtonDown); begin if not PtInRegion(FKRgn,Message.xPos,Message.yPos) then exit; FLButtonDown := True; MoveButton; inherited; end; procedure TRVButton.WMLButtonUp(var Message: TWMLButtonUp); begin if not FLButtonDown then exit; FLButtonDown := False; MoveButton; inherited; end; end. 请帮我看看这个问题 我们死后,我们的QQ,msn,email怎么办呢? 请问如何弹出音量控制窗口? JVCL3.0正式出来啦! 在TADOQuery的返回结果上再执行查询? 小弟初学DELPHI,请问各位学DELPHI有什么方法? 紧急求购报表控件!!!!!!! 帮忙看看[Error] CopyFile.pas(83): '.' expected but '(' found 是什么原因? 怎样动态更新数据控件?快快求解?进者有分 在Delphi6中Adoquery连接Access数据库的一个问题 为何连接后 ADOTable1 前面打了个问号? 我是新手,攒了些问题,请帮帮忙,谢了
RZ的图按按钮不知能否满足你的要求?
肯定能,以前没用过这些套件,那天反编译了一下别人软件,就为那华丽的界面。结果发觉都是用的它如果楼主也有我这想法的话,请下载raise套件.呵呵
不是打广告
SysUtils, Classes, Controls, Messages, Graphics, Windows; const
iOffset = 3; type
TRVButton = class(TGraphicControl)
private
FCaption : string;
FButtonColor: TColor;
FLButtonDown: boolean;
FBtnPoints : array[1..2] of TPoint;
FKRgn : HRgn;
procedure SetCaption(Value: string);
procedure SetButtonColor(Value: TColor);
procedure FreeRegion;
protected
procedure Paint; override;
procedure DrawCircle;
procedure MoveButton;
procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property ButtonColor: TColor read FButtonColor write SetButtonColor;
property Caption: string read FCaption write SetCaption;
property Enabled;
property Font;
property ParentFont;
property ParentShowHint;
property ShowHint;
property Visible;
property OnClick;
end; procedure Register; implementation procedure Register;
begin
RegisterComponents('Samples', [TRVButton]);
end; { TRVButton } constructor TRVButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := [csClickEvents,csCaptureMouse];
Width := 50;
Height := 50;
FButtonColor := clBtnFace;
FKRgn := 0;
FLButtonDown := False;
end; destructor TRVButton.Destroy;
begin
if FKRgn <> 0 then FreeRegion;
inherited Destroy;
end; procedure TRVButton.DrawCircle;
begin
FBtnPoints[1] := Point(iOffset,iOffset);
FBtnPoints[2] := Point(Width - iOffset,Height - iOffset);
FKRgn := CreateEllipticRgn(FBtnPoints[1].x,FBtnPoints[1].y,FBtnPoints[2].x,FBtnPoints[2].y);
Canvas.Brush.Color := FButtonColor;
FillRgn(Canvas.Handle,FKRgn,Canvas.Brush.Handle);
MoveButton;
end; procedure TRVButton.FreeRegion;
begin
if FKRgn <> 0 then DeleteObject(FKRgn);
FKRgn := 0;
end; procedure TRVButton.MoveButton;
var
Color1: TColor;
Color2: TColor;
begin
with Canvas do
begin
if not FLButtonDown then
begin
Color1 := clBtnHighlight;
Color2 := clBtnShadow;
end
else
begin
Color1 := clBtnShadow;
Color2 := clBtnHighLight;
end; Pen.Width := 1; if FLButtonDown then Pen.Color := clBlack
else Pen.Color := Color2; Ellipse(FBtnPoints[1].x - 2,FBtnPoints[1].y - 2,FBtnPoints[2].x + 2,FBtnPoints[2].y + 2); if not FLButtonDown then Pen.Width := 2
else Pen.Width := 1; Pen.Color := Color1; Arc(FBtnPoints[1].x,FBtnPoints[1].y,FBtnPoints[2].x,FBtnPoints[2].y,
FBtnPoints[2].x,FBtnPoints[1].y,FBtnPoints[1].x,FBtnPoints[2].y); Pen.Color := Color2; Arc(FBtnPoints[1].x,FBtnPoints[1].y,FBtnPoints[2].x,FBtnPoints[2].y,
FBtnPoints[1].x,FBtnPoints[2].y,FBtnPoints[2].x,FBtnPoints[1].y);
end; SetCaption('');
end; procedure TRVButton.Paint;
begin
inherited Paint;
FreeRegion;
DrawCircle;
end; procedure TRVButton.SetButtonColor(Value: TColor);
begin
if Value <> FButtonColor then
begin
FButtonColor := Value;
Invalidate;
end;
end; procedure TRVButton.SetCaption(Value: string);
var
X: Integer;
Y: Integer;
begin
if ((Value <> FCaption) and (Value <> '')) then
begin
FCaption := Value;
end; with Canvas.Font do
begin
Name := Font.Name;
Size := Font.Size;
Style := Font.Style;
if Self.Enabled then Color := Font.Color
else
Color := clDkGray;
end; X := (Width div 2) - (Canvas.TextWidth(FCaption) div 2);
Y := (Height div 2) - (Canvas.TextHeight(FCaption) div 2);
Canvas.TextOut(X, Y, FCaption);
// Invalidate;
end;
procedure TRVButton.WMLButtonDown(var Message: TWMLButtonDown);
begin
if not PtInRegion(FKRgn,Message.xPos,Message.yPos) then exit;
FLButtonDown := True;
MoveButton;
inherited;
end; procedure TRVButton.WMLButtonUp(var Message: TWMLButtonUp);
begin
if not FLButtonDown then exit;
FLButtonDown := False;
MoveButton;
inherited;
end;
end.