No.1 把TLable放在TPanel上
object Button1: TButton
Left = 128
Top = 120
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Panel1: TPanel
Left = 142
Top = 123
Width = 49
Height = 16
BevelOuter = bvNone
TabOrder = 1
object Label1: TLabel
Left = 8
Top = 1
Width = 32
Height = 13
Caption = 'Label1'
end
endNo.2 把TLabel放在TButton上 //不建议
Label1.Parent := Button1;
Label1.Left := 0;
Label1.Top := 0;
object Button1: TButton
Left = 128
Top = 120
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Panel1: TPanel
Left = 142
Top = 123
Width = 49
Height = 16
BevelOuter = bvNone
TabOrder = 1
object Label1: TLabel
Left = 8
Top = 1
Width = 32
Height = 13
Caption = 'Label1'
end
endNo.2 把TLabel放在TButton上 //不建议
Label1.Parent := Button1;
Label1.Left := 0;
Label1.Top := 0;
我在使用中发现只要一把lable放到button上。lable就自动跑到Button下了。我这样做的目的是,想把label设为透明,然后放到Button上。这样,就不能点击Button了。不要告诉我可以用button.enable:=false代替,我这样做有我的理由
button.Visible := False;
当然也可以自己继承TButton后自己实现 ,但还是没有把一个lable放到上面来的简单。
把lable放到上面,点的就是lable,Button当然就没反应啦。
点不动,???
我就想把BUTTON的图COPY过来一个,
就那种*好看的,
你非常想点的,
就是点不动,!!!
application.onmessage:=mymessage;
PUBLISH中:
procedure mymessage(var msg:tmsg;var handled:boolean);
实现:
procedure tform1.mymessage(var msg:tmsg;var handled:boolean);
begin
if (msg.message=wm_Lbuttondown) and (msg.hwnd=Button.handle) then
begin
if Locked then handled:=true;
end;
end;
label1.Align:=Alclient;
ControlStyle := ControlStyle + [csAcceptsControls];
否则,你说的无法做到,因为TButton控件不能做为其他控件的容器,就是
因为其ControlStyle属性中没有csAcceptsControls。