有时需要使用透明控件用于捕获鼠标消息
1.调用Windows2000,xp新的API函数实现这一功能的过程。使用SetLayeredWindowAttributes
2.直接设置控件的alphablend,alphablendvalue,间接调用上述api.
3.使用TStaticText控件
procedure WMCtrlColor(var Message: TWMCtlColor); message WM_CTLCOLOR;
procedure TForm3.WMCtrlColor(var Message:TWMCtlColor);
begin
if (Message.ChildWnd = StaticText1.Handle)then
begin
SetBkMode(Canvas.Handle,TRANSPARENT);
Message.Result:= GetStockObject(NULL_BRUSH);
end;
end;
4.使用TShape或TLabel无句柄控件,transparent属性.
本文介绍了几种实现透明控件的方法,包括调用Windows API函数SetLayeredWindowAttributes、设置控件的alpha混合属性、使用TStaticText控件及TShape或TLabel无句柄控件等。

617

被折叠的 条评论
为什么被折叠?



