手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>delphi>列表

具有自动恢复功能的通知栏图标控件

来源:互联网 作者:西部数码 时间:2008-04-09
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

FreeObjectInstance(FNewWndProc);
FNewWndProc := nil;
……
inherited Destroy;
end; //end of destructor

procedure TEoCSysTray.SetActive(Value: boolean);
begin
if Value <> FActive then
begin
FActive := Value;
if not (csDesigning in ComponentState) then //控件未处于设计状态
case Value of
True:
begin
……
HookParentForm; //替换父窗口的窗口过程
……
end;
False:
begin
……
UnHookParentForm; //还原父窗口的窗口过程
……
end;
end;
end;
end; //end of procedure SetActive

procedure TEoCSysTray.HookParentForm; //替换父窗口的窗口过程
var
P : Pointer;
begin
if Assigned(FParentWindow) and
not ((csDesigning in FParentWindow.ComponentState) or
(csDestroying in FParentWindow.ComponentState) or FDestroying) then
begin
FParentWindow.HandleNeeded;
P := Pointer(GetWindowLong(FParentWindow.Handle, GWL_WNDPROC));
if (P <> FNewWndProc) then
begin
FPrevWndProc := P;
SetWindowLong(FParentWindow.Handle,
  GWL_WNDPROC, LongInt(FNewWndProc)); //替换父窗口的窗口过程
end;
end;
end; //end of procedure HookParentForm

procedure TEoCSysTray.UnHookParentForm; //还原父窗口的窗口过程
begin
if Assigned(FParentWindow) then
begin
if Assigned(FPrevWndProc) and FParentWindow.HandleAllocated and
(Pointer(GetWindowLong(FParentWindow.Handle, GWL_WNDPROC)) = FNewWndProc) then
SetWindowLong(FParentWindow.Handle,
  GWL_WNDPROC, LongInt(FPrevWndProc)); //还原父窗口的窗口过程
end;
FPrevWndProc := nil;
end; //end of procedure UnHookParentForm

procedure TEoCSysTray.HookWndProc(var AMsg: TMessage);
begin
if Assigned(FParentWindow) then
begin
with AMsg do
begin
if Msg = MsgTaskbarCreated then //接收到任务栏重建消息
DoTaskBarCreated; //触发任务栏重建事件
if Assigned(FPrevWndProc) then //调用原窗口的窗口过程
Result := CallWindowProc(FPrevWndProc, FParentWindow.Handle,
  Msg, WParam, LParam)
else
Result := CallWindowProc(THack(FParentWindow).DefWndProc,
FParentWindow.Handle, Msg, WParam, LParam);
if Msg = WM_DESTROY then //窗口正被销毁
UnHookParentForm; //还原父窗口的窗口过程
end;
end;
end; //end of procedure HookWndProc

procedure TEoCSysTray.DoTaskBarCreated;
begin
…… //在这里重新添加通知栏图标
if Assigned(FTaskBarCreated) then
FTaskBarCreated(Self);
end; //end of procedure DoTaskBarCreated

initialization
//注册询问任务栏重建的消息
MsgTaskbarCreated := RegisterWindowMessage(''''TaskbarCreated'''');

end.

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!