how to make:超级解霸的动画图标?(空)

superdelphi 2000-01-23 04:07:00
...全文
253 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
superdelphi 2000-02-01
  • 打赏
  • 举报
回复
谢谢大家的帮助!
jll 2000-01-30
  • 打赏
  • 举报
回复
各位大虾:
超级解霸实际上是用Timer组件来实现动画按钮的。有兴趣的话,可以用一些图标提取工具查看一下超级解霸的可执行程序,你们就会发现其实里面不止一个图标。这些图标中有8个用来在播放电影时显示动画效果(就是窗口的图标不断变化),另外还有几组分别用来显示“声音”、“视频”按钮等的动画。
具体方法分为大致两步:
(1)、在Form上添加一个CoolBar组件,适当设置其属性,再设置几个按钮以及背景位图。
(2)、在需要动画效果的按钮事件中编写相关代码。下面举一个大致的例子:
1、假设按钮为Button1,
2、在Button1的OnEnter事件(记不清到底是不是这个事件了)中添加显示动画的语句。
3、在Button1的OnExit事件(记不清到底是不是这个事件了)中终止动画的演示。
渤海海峡 2000-01-24
  • 打赏
  • 举报
回复
做一个动画GIF,然后用一个播动画的控件(比如rxlib的哪个)不就ok了。
zdg 2000-01-24
  • 打赏
  • 举报
回复
我想问题没有这么复杂, 比如你做好4个ICON. 在Delphi建一个Timer, 每个timer片依次LoadIcon就可以了, 我用VC实现过这种效果...
为什么要想那么复杂呢???
superdelphi 2000-01-24
  • 打赏
  • 举报
回复
超级解霸肯定不是用timer,如果用线程的话能否给出源代码?
ahfei 2000-01-24
  • 打赏
  • 举报
回复
:( 不好意思,刚才那个循环语法有些问题,大家看得懂就行:)
ahfei 2000-01-24
  • 打赏
  • 举报
回复
>>超级解霸肯定不是用timer,如果用线程的话能否给出源代码?
不要把问题复杂化,解霸为什么不是用Timer???这里用得上线程吗?
就算是用线程,也不就是这样用:
While true do
NotifyIcon1.ModifyIcon(IconArray[i]);
YourThread.Sleep(xxx);
Repeat;
比用Timer复杂多了,又没有什么实际的好处

ahfei 2000-01-24
  • 打赏
  • 举报
回复
用Timer就可以了,再加上下面这个我写的控件
然后 OnTimer中 NotifyIcon1.ModifyIcon(IconArray[i]);

unit NotifyIcon;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DsgnIntf,ShellApi,ExtCtrls,Menus,
EditorForm;

const
WM_MY_Notify=WM_USER+100;
type
ECreateError=class(Exception);
TPopupStyle=Set of (Left_Click,Right_Click,Left_DbClick,Right_DbClick);
TWhoButton=(b_Left,b_Right);
TMouseEvent=
procedure(Sender:TObject;x,y:Word;WhoButton:TWhoButton)
of Object;

//---------class TNotifyIcon---------
TNotifyIcon = class(TGraphicControl)
private
{ Private declarations }
FParentHandle:HWnd;
FIcon:TIcon;
FPda:PNOTIFYICONDATA;
FTitle:string;
FIconVisible:boolean;
FPopupMenu:TPopupMenu;
FPopupStyle:TPopupStyle;
FOnIconMouseDown:TMouseEvent;
FOnIconDoubleClick:TMouseEvent;
procedure SetIcon(Icon:TICON);
procedure SetTitle(NewTitle:string);
function IsShowing:boolean;
procedure ShowIt(Accept:boolean);
procedure NotifyIconClick(var msg : TMessage);
Message WM_My_Notify;
protected
{ Protected declarations }
public
{ Public declarations }
property IsVisible:boolean read IsShowing write ShowIt;
constructor Create(AOwner: TComponent); override;
procedure ShowIcon;
procedure HideIcon;
destructor Destroy; override;
procedure ModifyIcon(NewIcon:TIcon);
procedure Paint;override;
published
{ Published declarations }
property Height default 33;
property Width default 33;
property NotifyIcon:TIcon read FIcon write SetIcon;
property Title:string read FTitle write SetTitle ;
property OnIconDoubleClick:TMouseEvent
read FOnIconDoubleClick write FOnIconDoubleClick;
property OnIconMouseDown:TMouseEvent
read FOnIconMouseDown write FOnIconMouseDown ;
property PopupMenu:TPopupMenu read FPopupMenu write FPopupMenu;
property PopupStyle:TPopupStyle read FPopupStyle
write FPopupStyle default [];
end;

procedure Register;

implementation
procedure Register;
begin
RegisterComponents('Custom', [TNotifyIcon]);
RegisterComponentEditor(TNotifyIcon,TNotifyIconEditor);
end;

procedure TNotifyIcon.Paint;
begin
if (csDesigning in ComponentState) then
begin
inherited;
Width:=32;
Height:=32;
With Canvas do
begin
if Assigned(FIcon) then
begin
Draw(0,0,FIcon);
end;
{
else
begin
Brush.Color:=clInfoBk;
Ellipse(0,0,Self.Width,Self.Height);
Font.Color:=clBlue;
Brush.Style:=bsClear;
FloodFill(5,5,clInfoBk,fsBorder);
Brush.Color:=clInfoBk;
TextOut(3,Self.Height div 2-6,'Notify');
end;
}
end;
end;
end;

procedure TNotifyIcon.NotifyIconClick(var msg : TMessage);
var p:TPoint;
begin
case msg.LParam of
WM_LBUTTONDOWN:
begin
GetCursorPos(p);
if Left_Click in FPopupStyle then
begin
SetForegroundWindow(FParentHandle);
FPopupMenu.Popup(p.x,p.y);
end;
if Assigned(FOnIconMouseDown) then
begin
FOnIconMouseDown(Self,p.x,p.y,b_Left);
end;
end;
WM_RBUTTONDOWN:
begin
GetCursorPos(p);
if Right_Click in FPopupStyle then
begin
SetForegroundWindow(FParentHandle);
FPopupMenu.Popup(p.x,p.y);
end;
if Assigned(FOnIconMouseDown) then
begin
FOnIconMouseDown(Self,p.x,p.y,b_Right);
end;
end;
WM_LBUTTONDBLCLK:
begin
GetCursorPos(p);
if Left_DbClick in FPopupStyle then
begin
SetForegroundWindow(FParentHandle);
FPopupMenu.Popup(p.x,p.y);
end;
if Assigned(FOnIconDoubleClick) then
begin
FOnIconDoubleClick(Self,p.x,p.y,b_Left);
end;
end;
WM_RBUTTONDBLCLk:
begin
GetCursorPos(p);
if Right_Click in FPopupStyle then
begin
SetForegroundWindow(FParentHandle);
FPopupMenu.Popup(p.x,p.y);
end;
if Assigned(FOnIconDoubleClick) then
begin
FOnIconDoubleClick(Self,p.x,p.y,b_Right);
end;
end;
end;
end;

constructor TNotifyIcon.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FIcon:=TIcon.Create;
Height:=32;
Width:=32;
Visible:=false;
FTitle:='Welcome';
FIconVisible:=false;
//-------------set tray info---------
try
if AOwner is TForm then
FParentHandle:=TForm(AOwner).Handle
else
FParentHandle:=GetParentForm(Self).Handle;
except
raise ECreateError.Create('创建NotifyIcon控件时发生了错误!');
end;
New(Fpda);
With FPda^ do
begin
uCallbackMessage:=WM_MY_Notify;
cbsize:=SizeOf(FPda^);
uID:=200;
wnd:=FParentHandle;
uFlags:=NIF_ICON+NIF_Tip+NIF_MESSAGE;
end;
end;

procedure TNotifyIcon.ShowIt(Accept:boolean);
begin
if Accept=true then ShowIcon
else HideIcon;
end;

procedure TNotifyIcon.SetIcon(Icon:TICON);
begin
FIcon.Assign(Icon);
if csDesigning in ComponentState then
Self.Refresh ;
end;

procedure TNotifyIcon.ShowIcon;
begin
if (Assigned(FIcon)) and (not FIconVisible) then
begin
if FIcon.Handle<>FPda^.hIcon then
HideIcon; //如果Icon改变了,先隐藏它
FPda^.hIcon:=FIcon.handle;
FIconVisible:=true;
Shell_NotifyIcon(NiM_ADD,FPda); //显示
end;
end;

procedure TNotifyIcon.HideIcon;
begin
if FIconVisible then
begin
FIconVisible:=false;
Shell_NotifyIcon(NiM_DELETE,FPda);
end;
end;

procedure TNotifyIcon.SetTitle(NewTitle:string);
begin
FTitle:=NewTitle;
StrCopy(FPda^.szTip,PChar(FTitle));
if FIconVisible then
begin
ModifyIcon(FIcon);
end;
end;

destructor TNotifyIcon.Destroy;
begin
try
HideIcon;
finally
Dispose(FPda);
FIcon.Free;
end;
inherited Destroy;
end;

procedure TNotifyIcon.ModifyIcon(NewIcon:TIcon);
begin
SetIcon(NewIcon);
FPda^.hIcon:=FIcon.handle;
if FIconVisible then
Shell_NotifyIcon(NiM_Modify,FPda);
end;

function TNotifyIcon.IsShowing:boolean;
begin
Result:=FIconVisible;
end;


end.
barton 2000-01-23
  • 打赏
  • 举报
回复
错!RxLib有原码,一看就...
Firing_Sky 2000-01-23
  • 打赏
  • 举报
回复
简单一点,在Timer.timer事件中改变Application和form的图标
麻烦一点,专门为它们建立一个线程
blaise 2000-01-23
  • 打赏
  • 举报
回复
yes,with a timer,regularly change you window's icon,the icon in task bar will also changes.But I don't know how to make the shortcut on desktop icon also changes like the dialup link in w2k.
zdg 2000-01-23
  • 打赏
  • 举报
回复
作几个图标, 再LoadIcon...

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧