我用上面的代码实现窗体逶明。
procedure TForm2.SetTranSparent(form: TForm);
var
AControl : TControl;
i, Margin, X, Y, CtlX, CtlY : Integer;
begin Margin := (form.Width - form.ClientWidth) div 2;
FullRgn := CreateRectRgn(0,0,form.Width,form.Height);
X := Margin;
Y := form.Height - form.ClientHeight - Margin;
ClientRgn := CreateRectRgn(X,Y,X + form.ClientWidth, Y + form.ClientHeight );
CombineRgn(FullRgn,FullRgn,ClientRgn,RGN_DIFF );
for i := 0 to form.ControlCount - 1 do
begin
AControl := form.Controls[i];
if (AControl is TWinControl ) or (AControl is TGraphicControl) then
begin
with AControl do
begin
if Visible then
begin
CtlX := X + Left;
CtlY := Y + Top;
TransparentColor := false;
CtlRgn := CreateRectRgn(CtlX,CtlY,CtlX + Width,CtlY + Height );
Brush.Style := bsClear;
TextOut(Handle,10,10,'123',3);
CombineRgn(FullRgn,FullRgn,CtlRgn, RGN_OR );
end;
end;
end;
end;
SetWindowRgn(form.Handle, FullRgn, TRUE);
end;
现在的问题是:逶明窗体上放了Label控件,想让Label也是逶明的及只能看到文本!
注:背景播放的视频图象
procedure TForm2.SetTranSparent(form: TForm);
var
AControl : TControl;
i, Margin, X, Y, CtlX, CtlY : Integer;
begin Margin := (form.Width - form.ClientWidth) div 2;
FullRgn := CreateRectRgn(0,0,form.Width,form.Height);
X := Margin;
Y := form.Height - form.ClientHeight - Margin;
ClientRgn := CreateRectRgn(X,Y,X + form.ClientWidth, Y + form.ClientHeight );
CombineRgn(FullRgn,FullRgn,ClientRgn,RGN_DIFF );
for i := 0 to form.ControlCount - 1 do
begin
AControl := form.Controls[i];
if (AControl is TWinControl ) or (AControl is TGraphicControl) then
begin
with AControl do
begin
if Visible then
begin
CtlX := X + Left;
CtlY := Y + Top;
TransparentColor := false;
CtlRgn := CreateRectRgn(CtlX,CtlY,CtlX + Width,CtlY + Height );
Brush.Style := bsClear;
TextOut(Handle,10,10,'123',3);
CombineRgn(FullRgn,FullRgn,CtlRgn, RGN_OR );
end;
end;
end;
end;
SetWindowRgn(form.Handle, FullRgn, TRUE);
end;
现在的问题是:逶明窗体上放了Label控件,想让Label也是逶明的及只能看到文本!
注:背景播放的视频图象
解决方案 »
- 不知道什么原因,我数据库中的productid类型是int 的
- 求票打的最快方法,直接对“LPT1”端口进行输出
- 存储过程的参数怎么用啊???
- 有没有即时通软件的原码,现金求购
- 请问刚装好的Delphi7,打开项目的时候提示找不到TNMFTP类,怎么办啊?
- 怎麽今年都生兒子呀,有生女儿的来报到,真是担心下代光棍太多!
- 请教,如何在TreeView控件中用代码来选中树中的某一项?
- 如何获取窗体上webbrowser控件上一个提交按钮的屏幕位置?
- 如何获得系统的区域设置?
- dbgrid彩色显示
- Delphi 2005 -> Failed to initialize the VCL for .NET Form Designer
- 谁能介绍个Office2003风格的界面控件
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, TeeProcs, TeEngine, Chart, Series;const WS_EX_LAYERED = $80000; AC_SRC_OVER = $0; AC_SRC_ALPHA = $1; AC_SRC_NO_PREMULT_ALPHA = $1; AC_SRC_NO_ALPHA = $2; AC_DST_NO_PREMULT_ALPHA = $10; AC_DST_NO_ALPHA = $20; LWA_COLORKEY = $1; LWA_ALPHA = $2; ULW_COLORKEY = $1; ULW_ALPHA = $2; ULW_OPAQUE = $4;
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TBarSeries;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function SetLayeredWindowAttributes(hwnd:HWND; crKey:Longint; bAlpha:byte; dwFlags:longint ):longint; stdcall; external user32;//函数声明
var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var l:longint;begin l:=getWindowLong(Handle, GWL_EXSTYLE); l := l Or WS_EX_LAYERED; SetWindowLong (handle, GWL_EXSTYLE, l); SetLayeredWindowAttributes (handle, 0, 150, LWA_ALPHA); Series1.AddBar(100,'',clBackground);//第二个参数是指定透明颜色//第二个参数为0则使用第四个参数设置alpha值,从0到255,其他的我不太清楚,因为没有api帮助end;
end.
Form1.BorderStyle := bsNone