你的 Label 的 AutoSize 是不是 true ?
解决方案 »
- dephi treeview treeview.selected.data
- [程序中函数中址]与串口有关,没法调试,想请教大家,串口发送程序终止的原因?
- 增加自动排序和滚轮的DBGrid
- SOS!设计急用,诚请高手相救!
- 怎样释放ActiveXForm的ocx
- 关于分辨率,和Post速度慢的问题
- 那里有Delphi6.0中文版下载?(6月20日发布的)
- 用了SetLayeredWindowAttributes不可以在MTV上显示出来? 500分
- 如何取出已删除但尚未在数据库提交的记录
- 我的OFFICES2000序列号没了,请大家告诉我吧! 在线等
- Delphi中如何实现删除磁盘目录
- 高分悬赏,再次求助:关于socket控件如何同线程结合使用?
与label毫无关系!
2)调整位置在Paint中?,太奇怪了,要么重载SetBounds,要么处理WM_SIZE
3)Onclik处理的不好,你这样也可以吗?
4); fbutton.parent:=twincontrol(aowner);
flabel:=tlabel.create(self);
flabel.parent:=twincontrol(aowner);
fbutton.width:=10;
fbutton.height:=10;
fbutton.top:=top;
fbutton.left:=Left;
flabel.caption:='newcom';
flabel.width:=100;
flabel.height:=20;
flabel.left:=left-10;
flabel.top:=top+20;
flabel.Transparent:=true;
位置的调整有很多错误。left,top的含义理解的不对。
现在要求做的东西是全部是透明的,所以twincontrol是不行的!
因为TGraphicControl没有焦点,你在Create设置它的位置是没用的,
Onclick我测试没问题啊!
你现在用Wincontrol当然会认为我的left不对;
但用TGraphicControl,你安装一下我写的,你会发现位置没错
毕竟TGraphicControl是没焦点的!
对于TWinControl要做成透明的效果,可以取得父窗口的dc,然后把父窗口的图像绘制出来.
unit SButton;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls,
Math;type
TSButton = class(TWinControl)
private
FButton: TSpeedButton;
FLabel: TLabel;
protected
procedure Resize; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('OwnComponents', [TSButton]);
end;{ TSButton }constructor TSButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Parent := TWinControl(AOwner); FButton := TSpeedButton.Create(Self);
FLabel := TLabel.Create(Self);
with FButton do
begin
Parent := Self;
Flat := true;
Top := 0;
Width := 10;
Height := 10;
end;
with FLabel do
begin
Parent := Self;
Caption := 'abcdefg';
Top := FButton.Top + FButton.Height + 2;
end;
Width := Max(FButton.Width, FLabel.Width);
Height := FButton.Height + FLabel.Height + 2;
end;destructor TSButton.Destroy;
begin
FButton.Free;
FLabel.Free;
inherited Destroy;
end;procedure TSButton.Resize;
begin
inherited Resize;
if Assigned(FButton) and Assigned(FLabel) then
begin
FButton.Left := (Width - FButton.Width) div 2;
FLabel.Left := (Width - FLabel.Width) div 2;
Height := FButton.Height + FLabel.Height + 2;
end;
end;end.
zengyufeng:是TGraphicControl
kxy:怎么没回音了??