关于制作控件的问题?(50分)

  • 主题发起人 主题发起人 snows
  • 开始时间 开始时间
S

snows

Unregistered / Unconfirmed
GUEST, unregistred user!
我自己做了一个按钮控件,实现当鼠标移动到它上面时变图象,功能上没有
什么问题,但只要我在窗口中加入这个控件,当我双击要编写的新事件时,程序
会自动加上inherted,请问我的控件哪儿有问题?
 
OVERRIDE?
 
Override, virtual
 
请详细点
 
从来没遇到过.
把你控件的published声明部分贴出来看看.
 
代码如下:
public
{ Public declarations }
constructor Create(AOwner : TComponent); override;
property Canvas : TCanvas read GetCanvas;

............

constructor TFlatImage.Create(AOwner : TComponent);
{ Overrides the constructor to initialize variables }
begin
inherited Create(AOwner);
ImageActive:=false;
Height := 48;
Width := 48;
FImageMovePixel:=1;
end;
 
不是public, 是published部分的定义
 
published
{ Published declarations }
property OnMouseEnter : TNotifyEvent read FOnMouseEnter
write FOnMouseEnter;
property OnMouseLeave : TNotifyEvent read FOnMouseLeave
write FOnMouseLeave;
property ImageMovePixel:Integer read FImageMovePixel
write FImageMovePixel;

 
snows
你以前问delphi怎样访问Access的查询,我发现
用TQuery 同样可访问Access的查询
只需在 query 的 SQL 属性如下: select * from 查询名称
可惜没有分了.

 
非常感谢gxg8816!
 
为什么没有人回答我的问题?
 
看来你得把interface部分都贴出来
 
unit FlatImage;

interface

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

type
TFlatImage = class(TImage)
private
{ Private declarations }
FOnMouseEnter : TNotifyEvent;
FOnMouseLeave : TNotifyEvent;
ImageActive:Boolean;
FImageMovePixel:Integer;

function GetCanvas : TCanvas;
procedure CMMouseEnter(var Message : TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message : TMessage); message CM_MOUSELEAVE;
protected
{ Protected declarations }
procedure MouseEnter; dynamic;
procedure MouseLeave; dynamic;
public
{ Public declarations }
constructor Create(AOwner : TComponent); override;
property Canvas : TCanvas read GetCanvas;
published
{ Published declarations }
property OnMouseEnter : TNotifyEvent read FOnMouseEnter
write FOnMouseEnter;
property OnMouseLeave : TNotifyEvent read FOnMouseLeave
write FOnMouseLeave;
property ImageMovePixel:Integer read FImageMovePixel
write FImageMovePixel;

end;
 
后退
顶部