可以这样思维,建2个窗体,一个放图片(假主窗体),把所用控件放到另一个窗体上,然后使这个窗体透明就很容易了[
],然后把这个放到主窗体上就OK了。
工程文件里是这样的:
begin
Application.Initialize;
Application.CreateForm(TfrmShell, frmShell);
Application.Run;
end.
使frmShell窗体透明就可以了
frmShell.AlphaBlendValue := tbAlpha.Position; //调节透明度
frmShell窗体的单元文件
unit UShell;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TfrmShell = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
public
procedure WM_Move(var Msg:TMessage);message WM_MOVE;
{ Public declarations }
end;
var
frmShell: TfrmShell;
implementation
uses UMain;
{$R *.dfm}procedure TfrmShell.FormCreate(Sender: TObject);
begin
frmMain:=TfrmMain.Create(Self);//假的主窗体,放你的图片用
frmMain.Show;
FormResize(Self);
end;
procedure TfrmShell.FormResize(Sender: TObject);
begin
frmMain.Left:= Left + ((Width - ClientWidth) shr 1);
frmMain.Top := Top + (Height - ClientHeight-4);
frmMain.Width := ClientWidth;
frmMain.Height := ClientHeight;
end;
procedure TfrmShell.WM_Move;
begin
inherited;
if Assigned(frmMain) then FormResize(Self);
end;