转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
TNotifyIcon 控件1.01         ★★★★

TNotifyIcon 控件1.01

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1306 更新时间:2009/4/23 18:39:57
TNotifyIcon 控件1.01 (Build use Delphi 3.0) 说明:
作用:
 往通知区加图标,并可显示,隐藏,修改这个图标.
 

属性(properties):
 NotifyIcon:TIcon  欲加在通知区的图标
 IsVisible:boolean NotifyIcon是否显示的属性
 Title:string  通知区图标上的提示(最多64个字符)
 PopupMenu:TPopupMenu 点击通知区图标弹出的菜单
 PopupStyle:TPopupStyle 弹出菜单的方式            
  TPopupStyle=Set of
(Left_Click,Right_Click,Left_DbClick,Right_DbClick);
方法(methods):  
   ShowIcon  将图标显示在通知区上
   HideIcon  将通知区上的图标隐藏
   ModifyIcon 修改通知区上的图标(若IsVisible=false,则不显示出来)
   Create(AOwner: TComponent); override; 构造方法
   Destroy; override; 析构方法
事件(Events):
    OnIconMouseDown:
      procedure(Sender:TObject;x,y:Word;WhoButton:TWhoButton) of
Object;
      (
       在Mouse点击通知区上的图标时发生,x,y为Mouse在屏幕上的坐标,
       WhoButton=b_Left为点击左键,WhoButton=b_Right为点击右键,
      )
    OnIconDoubleClick:
      procedure(Sender:TObject;x,y:Word;WhoButton:TWhoButton) of
Object;
     (
      在Mouse双击通知区上的图标时发生,x,y为Mouse在屏幕上的坐标,
      WhoButton=b_Left为双击左键,WhoButton=b_Right为双击右键,
     )
关于Demo:
   这个演示程序给出了TNotifyIcon的基本用法.

包含文件:
 NotifyIcon.dcr
 NotifyIcon.pas
 DemoUnit.pas
 DemoUnit.dfm
 PopUnit.pas
 PopUnit.dfm
 Demo.dpr
 Readme.txt

声明:
TNotifyIcon 控件 V 1.01
1.这是一个免费控件.
2.如果你使用它,请发一个E-Mail给作者,谢谢.
3我在Delphi3.0 & 4.0 上使用成功
4.若要传播它,请完全分发上述8个文件

     作者  南昌大学计算系95(1)  付昱纲 1998.8.17  21:50
     E-mail   fyg@163.net 

unit NotifyIcon;

interface

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

const
      WM_MY_Notify=WM_USER+100;
type

  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(TCustomControl)
  private
    { Private declarations }
    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(''''MyControl'''', [TNotifyIcon]);
end;

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

procedure TNotifyIcon.Paint;
begin
if (csDesigning in ComponentState) then
begin
 Width:=33;
 Height:=33;
 With Canvas do
 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;

procedure TNotifyIcon.NotifyIconClick(var msg : TMessage);
 var p:TPoint;
begin
 try
     case msg.LParam of
      WM_LBUTTONDOWN:
        begin
         GetCursorPos(p);
         if Left_Click in FPopupStyle then
         begin
           SetForegroundWindow(ParentWindow);
           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(ParentWindow);
           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(ParentWindow);
           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(ParentWindow);
           FPopupMenu.Popup(p.x,p.y);
         end;
         if Assigned(FOnIconDoubleClick) then
         begin
           FOnIconDoubleClick(Self,p.x,p.y,b_Right);
         end;
        end;
     end;
 except
 end;
end;

function MAKELANGID(p, s:word):Cardinal;
begin
  result:= (((s)shl 10) or(p));
end;

constructor TNotifyIcon.Create(AOwner: TComponent);
begin
try
 inherited Create(AOwner);
 FIcon:=TIcon.Create;
 Height:=36;
 Width:=36;
 Visible:=false;
 FTitle:=''''Welcome'''';
 FIconVisible:=false;
 //-------------set tray info---------
 ParentWindow:=TWin

[1] [2]  下一页


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台