有没有delphi7的控件,实现能存储两幅图标图片,当鼠标移过图片区域,图标由图标1换成图标2,并且无煽动切换。谢谢各位高手!
解决方案 »
- 用ADO 可以连接PARADOX库吗?感谢
- 怎样实现主细表录入?
- 请问如下经典的DELPHI书在何处有下载?(最好是直接链接的)up有分
- 在线求救!!!!紧急!!!!
- 请问有不有这样一个控件?一个透明的Panel在上面放一个不规则的图形,在图形没覆盖的地方能直接点击下面的控件!有这样的东东吗?
- 我想知道怎么样调用特殊符号!高手,帮忙!
- 当我试图打开某个窗体时delphi自动关闭!请问为什么???
- delphi 的Open 问题
- 关于输入法的问题求教
- 那有mschart.cab下栽?网上的
- 除了Decision Cube外,大家还有没有用过其它数据决策分析组件啊?
- 请问我想写web中用的ActiveX来显示tif图片,用什么控件?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TIconEx = class(TLabel)
private
FPicture1: TPicture;
FPicture2: TPicture;
procedure SetPicture1(Value: TPicture);
procedure SetPicture2(Value: TPicture);
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Picture1: TPicture read FPicture1 write FPicture1;
property Picture2: TPicture read FPicture2 write FPicture2;
end;
{ TIconEx }procedure TIconEx.CMMouseEnter(var Message: TMessage);
begin
if csDesigning in ComponentState then Exit;
if not Assigned(FPicture1) then Exit;
self.Canvas.CopyRect(self.ClientRect, FPicture1.Bitmap.Canvas, FPicture1.Bitmap.Canvas.ClipRect);
end;procedure TIconEx.CMMouseLeave(var Message: TMessage);
begin
if csDesigning in ComponentState then Exit;
if not Assigned(FPicture2) then Exit;
self.Canvas.CopyRect(self.ClientRect, FPicture2.Bitmap.Canvas, FPicture2.Bitmap.Canvas.ClipRect);
end;constructor TIconEx.Create(AOwner: TComponent);
begin
inherited;
FPicture1 := TPicture.Create;
FPicture2 := TPicture.Create;
Caption := '';
AutoSize := False;
icon.Width := 100;
icon.Height := 100;
if(AOwner is TWinControl) then
Parent := TWinControl(AOwner);
Color := clWhite;
end;destructor TIconEx.Destroy;
begin
FPicture1.Free;
FPicture2.Free;
inherited;
end;procedure TIconEx.SetPicture1(Value: TPicture);
begin
FPicture1.Assign(Value);
end;procedure TIconEx.SetPicture2(Value: TPicture);
begin
FPicture2.Assign(Value);
end;end.测试:
procedure TForm1.Button1Click(Sender: TObject);
var
icon: TIconEx;
begin
icon := TIconEx.Create(self);
icon.Left := 10;
icon.Top := 10;
icon.Picture1.LoadFromFile('c:\\1.bmp');
icon.Picture2.LoadFromFile('c:\\2.bmp');
end;当把它加到控件面板上时出错,没细调是为什么,动态创建没问题。