delphi 透明窗体


本文整理自网络,侵删。

 
procedure TForm1.FormCreate(Sender: TObject);
  var
  rgn:HRGN;
  begin
    Self.Color := clRed;
    BeginPath(Canvas.Handle);
    SetBkMode(Canvas.Handle,TRANSPARENT   );
    Canvas.Font.Name:='宋体';
    Canvas.Font.Size:=100;
    Canvas.TextOut(20,20,'My Baby?');
    EndPath(Canvas.Handle);
    rgn:=   PathToRegion(Canvas.Handle);
    SetWindowRgn(Handle,rgn,true);
  end;
 
透明五星
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
  const   
        {An   array   of   points   for   the   star   region}   
        RgnPoints:array[1..10]   of   TPoint=   
        ((x:203;y:22),(x:157;y:168),(x:3;y:168),(x:128;y:257),   
        (x:81;y:402),(x:203;y:334),(x:325;y:422),(x:278;y:257),   
        (x:402;y:168),(x:249;y:168));//确定顶点   
        LinePoints:array[1..11]   of   Tpoint=   
        ((x:199;y:0),(x:154;y:146),(x:2;y:146),(x:127;y:235),   
        (x:79;y:377),(x:198;y:308),(x:320;Y:396),(x:272;y:234),   
        (x:396;y:146),(x:244;y:146),(x:199;Y:0));
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormCreate(Sender: TObject);
var   Rgn:HRGN;
begin
    Setwindowpos(Form1.Handle,HWND_TOPMOST,Form1.Left,form1.Top,Form1.Width,Form1.Height,0);
    Rgn:=CreatepolygonRgn(Rgnpoints,High(RgnPoints),ALTERNATE);
    SetWindowRgn(Handle,rgn,True);
    Form1.color:=clgreen;
end;
 
end.
 
以下是用Api实现透明窗体的代码,最的一次第三个参数为透明的程度,范围为0~255,0为完全透明,255完全不透明.具体可参考
 
  SetWindowLong(self.Handle,GWL_EXSTYLE,
     GetWindowLong(Self.Handle,GWL_EXSTYLE) xor $80000);
  SetLayeredWindowAttributes(Self.Handle,0,100,LWA_ALPHA);

相关阅读 >>

apk权限大全 android必懂知识

Delphi中关于canvas.textout的用法

Delphi idhttp用法详解

Delphi 比较两数字大小取最大值

android : assets与res/raw资源目录的区别

Delphi的窗体文件(dfm)文件中的汉字提取出来?

Delphi 中判断windows系统是否是64位系统

Delphi 检查当前用户权限

Delphi 系统日期时间格式设置

Delphi cardpanel1 简单的切换

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...