发一个专门操作任务栏的类

本文介绍了一个用于操控Windows任务栏的类,包括其构造、析构、功能函数等核心内容,旨在提供一种便捷的方式进行任务栏的定制和管理。
摘要由CSDN通过智能技术生成

发一个专门操作任务栏的类

忽然在CSDN上看到别人问怎样操作windows任务栏上的元素,如隐藏任务栏、获得任务栏上的所有托盘图标等信息。在闲暇的时候用Spy++捕捉了一下任务栏的相关消息和各控件句柄。于是将各种操作封装到了一个类中。大致代码如下: (******************************************************) (*              WindowsOperate Unit                   *) (*    Copyright(c) 2007    不得闲                     *) (*    email:appleak46@yahoo.com.cn     QQ:75492895    *) (******************************************************) unit WindowsOperate; interface uses windows,Classes,Messages,SysUtils,forms,ComObj,winsvc, shellapi,CommCtrl,Graphics; type   {任务栏上的任务按扭}   TSysToolbarBtn = class(TPersistent)   private     FBtnInfo: TTBButton;     FBtnIndex: integer;     FBtnCaption: string;     SysHide: boolean;//是否为系统隐藏图标     EventHandle: THandle; //事件处理句柄     FPicture: TBitmap; //图标     FBtnRect: TRect;  //区域     FVisible: boolean;     function GetBtnInfo: TTBButton;     procedure SetVisible(const Value: boolean);   public     Constructor Create;     Destructor Destroy;override;     property BtnInfo: TTBButton read GetBtnInfo;     property BtnIndex: integer read FBtnIndex;     property BtnCaption: string read FBtnCaption;     property BtnRect: TRect read FBtnRect;     procedure AssignBtnInfo(Info: TTBButton);     property isSysHide: boolean read SysHide;     property Picture: TBitmap read FPicture;     property Visible: boolean read FVisible write SetVisible;     procedure Click;     procedure DbClick;     procedure RClick;   end;   TSysTaskBarOperate = Class(TComponent) //任务栏操作类   private     FTrayBtnList,FTaskBtnList: TStringList;     HigherThenXp: boolean; //是否为xp以上的系统版本     FTrayBarHandle: THandle;     FTaskBarHandle: THandle;     FStartBtnHandle: THandle;     FQuitLauchHandle: THandle;     FReBarHandle: THandle;     FProgramToolBarHandle: THandle;     FImeRecHandle: THandle;     FProgramContrainerHandle: THandle; //任务栏容器     FHideTrayBtnHandle: THandle;     FTrayNotifyHandle: THandle;     FClockHandle: THandle;     FShowHideBtn: boolean;     FVisible: boolean;     FquickBarVisible: boolean;     FTaskToolBarVisible: boolean;     FTaskBarVisible: boolean;     FRegBarVisible: boolean;     FStartBtnVisible: boolean;     FImeBarVisible: boolean;     FTrayBarVisible: boolean;     procedure GetIconList;     procedure GetTaskList;     function GetTrayBtnCount: integer;     function IsSysBtnHide(BtnState: Dword): boolean;     procedure SetShowHideBtn(const Value: boolean);     function GetTrayBtns(Index: integer): TSysToolbarBtn;     function GetTaskBtnCount: integer;     function GetTaskBtns(Index: integer): TSysToolbarBtn;     procedure SetVisible(const Value: boolean);     procedure SetquickBarVisible(const Value: boolean);     procedure SetTaskToolBarVisible(const Value: boolean);     procedure SetTaskBarVisible(const Value: boolean);     procedure SetReBaVisible(const Value: boolean);     procedure SetStartBtnVisible(const Value: boolean);     procedure SetImeBarVisible(const Value: boolean);     procedure SetTrayBarVisible(const Value: boolean);   protected     procedure StartBtnWndProc(var Message: TMessage);   public     Constructor Create(AOwner: TComponent);override;     Destructor Destroy;override;     property TrayBarHandle: THandle read FTrayBarHandle;//托盘区句柄     property TaskBarHandle: THandle read FTaskBarHandle;//任务栏句柄     property StartBtnHandle: THandle read FStartBtnHandle;//开始按扭句柄     property QuitLauchHandle: THandle read FQuitLauchHandle;//快速启动栏句柄     property ImeRecHandle: THandle read FImeRecHandle;//输入法选择区域句柄     property ProgramToolBarHandle: THandle read FProgramToolBarHandle;//程序最小化按扭容器     property HideTrayBtnHandle: THandle read FHideTrayBtnHandle;//显示隐藏图标的按扭     property ClockHandle: THandle read FClockHandle;//时钟显示区域句柄     procedure SetTimeDlg;       //设置时间对话框     procedure HideTrayBtnClick; //显示隐藏按扭单击     procedure ImeRectBtnClick;//输入法按扭单击     procedure ClearTrayBtnList; //清除托盘区列表     procedure ClearTaskBtnList;     procedure ShowTime;     procedure StartBtnClick;     procedure HideOn;     procedure ShowOn;     property  TrayBarVisible: boolean read FTrayBarVisible write SetTrayBarVisible;     property  ImeBarVisible: boolean read FImeBarVisible write SetImeBarVisible;     property  StartBtnVisible: boolean read FStartBtnVisible write SetStartBtnVisible;     property  ReBarVisible: boolean read FRegBarVisible write SetReBaVisible;     property  TaskToolBarVisible: boolean read FTaskToolBarVisible write SetTaskToolBarVisible;     property  TaskBarVisible: boolean read FTaskBarVisible write SetTaskBarVisible;     property  quickBarVisible: boolean read FquickBarVisible write SetquickBarVisible;     property  Visible: boolean read FVisible write SetVisible; //是否隐藏任务栏     property  ShowHideBtn: boolean read FShowHideBtn Write SetShowHideBtn;//是否显示系统隐藏的托盘按扭  
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值