给构件添加 MouseLeave 事件
2009-10-11 00:47
211 查看
我不明白为何 Borland 的 Delphi 控制不支持 mouse leave 事件.下面是一个简易的例子,它不仅示范了怎样让 TIamge 控制实现 MouseLeave 事件,而且也示范了怎么样建立一个简单的 Delphi 构件.
{
Delphi 编程新手注意的问题:
本例是一个 Pascal 单元,请用 MyImg.pas 保存此单元.例子中的方法可应用于其它控制,所以你可以用 TLabel 或 TButton 等其它类来代替 TImage.
}
unit MyImg;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
ExtCtrls;
type
TMyImage = class(TImage)
private
FOnMouseLeave: TNotifyEvent;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
protected
public
published
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyImage]);
end;
procedure TMyImage.CMMouseLeave(var Message: TMessage);
begin
inherited;
if Assigned(FOnMouseLeave) then FOnMouseLeave(Self);
end;
{
Delphi 编程新手注意的问题:
本例是一个 Pascal 单元,请用 MyImg.pas 保存此单元.例子中的方法可应用于其它控制,所以你可以用 TLabel 或 TButton 等其它类来代替 TImage.
}
unit MyImg;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
ExtCtrls;
type
TMyImage = class(TImage)
private
FOnMouseLeave: TNotifyEvent;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
protected
public
published
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyImage]);
end;
procedure TMyImage.CMMouseLeave(var Message: TMessage);
begin
inherited;
if Assigned(FOnMouseLeave) then FOnMouseLeave(Self);
end;
相关文章推荐
- 给构件添加 MouseLeave 事件
- 为非IE浏览器添加mouseenter,mouseleave事件的实现代码
- gtk_widget_add_events为某个构件添加一个事件
- 为非IE浏览器添加mouseenter,mouseleave事件的实现代码
- 为非IE浏览器添加mouseenter,mouseleave事件
- 给控件添加点击响应事件UITapGestureRecognizer
- java实现对Google Calendar API event 事件的添加
- openGL 初试 绘制三角形 和添加鼠标键盘事件
- jQuery为动态生成的select元素添加事件
- 用友华表控件添加追踪事件
- Javascript添加事件的addEventListener()及attachEvent()区别分析
- 【iOS学习笔记】中将事件添加到系统日历
- 在asp.net2.0中手动写"添加"事件、判断重复--青蛙非王子(lostfrog)
- mysql添加事件觸發器
- c# 用户控件添加事件
- 点击事件添加高亮显示
- RecyclerView 添加头部和尾部,并实现Item的点击事件
- Extjs 中的添加事件总结
- 【GTK】GTK+图形化应用程序开发学习笔记(七)—标签构件.事件盒构件
- 给元素添加事件满足的条件