自定义控件提示窗口显示问题(50分)

  • 主题发起人 主题发起人 ChJK
  • 开始时间 开始时间
C

ChJK

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下(由于时间关系,注释没有写,也没有排版)
unit ClassButton;
interface
uses
Classes, Graphics, Controls, ExtCtrls, ImgList, Messages;
type
TIcoButton = class(TButton)
private
FShowHintChange: TNotifyEvent;
FShowHint: Boolean;
function IsShowHintStored: Boolean;
procedure SetShowHint(Value: Boolean);
protected
property ShowHintChange: TNotifyEvent read FShowHintChange write FShowHintChange;//注释改变事件
public
property ShowHint: Boolean read FShowHint write SetShowHint stored IsShowHintStored;
end;

type
ItemPanel = class(TPanel)
private
protected
procedure ItemShowHintChange(Sender: TObject);
public
myimage: TImage;
myButton: TIcoButton;
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
end;

procedure Register;
implementation
procedure Register;
begin
RegisterComponents('myPanel', [ItemPanel]);
end;

procedure TIcoButton.SetShowHint(Value: Boolean);
begin
if FShowHint <> Value then
begin
FShowHint := Value;
self.ParentShowHint := False;
ShowHintChange(self);
self.Perform(CM_SHOWHINTCHANGED, 0, 0);
end;
end;

constructor ItemPanel.Create(AOwner: TComponent);
begin

inherited;
icoButton:= TIcoButton.Create(self);
icoButton.Visible := true;
icoButton.Parent := self;
icoButton.Height := 30;
icoButton.Width := 100;
icoButton.Left := 10;
icoButton.top := 10;
icoButton.Caption:='test';
icoButton.ShowHintChange:= ItemShowHintChange;
TitleImage:= TImage.Create(self);
TitleImage.Visible := true;
TitleImage.Parent := self;
TitleImage.AutoSize:= True;
TitleImage.top := 10;
TitleImage.Left:= 200;
end;

destructor tpanel1.Destroy;

begin

myButton.free;
myimage.Free;
inherited;
end;

procedure ItemPanel.ItemShowHintChange(Sender: TObject);
var
i: integer;
begin

myimage.Hint :=TIcoButton(Sender).Hint;
myimage.ShowHint :=TIcoButton(Sender).ShowHint;
end;
end;

end.

窗口Show事件代码如下:
ItemPanel1.myButton.Hint:= '注释1';
ItemPanel1.myButton.ShowHint:= True;
不知道为什么按钮提示窗口不显示,只有图片注释可以出现提示窗口,怎么样能让按钮也可以显示提示窗口呢
 
看来这里已经没有高手了,再见了,大富翁!
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
539
import
I
S
回复
0
查看
763
SUNSTONE的Delphi笔记
S
I
回复
0
查看
740
import
I
后退
顶部