delphi中使用透明控件的几种方法

有时需要使用透明控件用于捕获鼠标消息

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,XP,null,Delphi)