var
rtn : integer
MybAlpha : byte
begin
MybAlpha := 50//透明度可以自己试效果 0~255
Rtn:=GetWindowLong(Form1.Handle,GWL_EXSTYLE)
Rtn:=rtn+WS_EX_LAYERED
SetWindowLong(Form1.Handle,GWL_EXSTYLE,Rtn)
SetLayeredWindowAttributes(Form1.Handle ,0,MybAlpha,LWA_ALPHA)
end
//方法二:画布模式
//在窗体中放两个image
procedure TForm1.Image1MouseDown(Sender: TObjectButton: TMouseButton
Shift: TShiftStateX, Y: Integer)
begin
with tcanvas.Create do //针对这个控件的属性
try
handle:=getdc(0) //dc(0)代表桌面
draw(x-image2.Width,y-image2.Height,image2.Picture.Graphic) //显示图片的函数
finally
releasedc(0,handle)
free
end
end
procedure TForm1.FormCreate(Sender: TObject)
var
image:Timage
scrCanvas:Tcanvas
begin
self.BorderStyle := bsNone
self.WindowState := wsMaximized
image1.Align := alclient
image2.Picture.LoadFromFile('C:\aa.jpg')
image:=Timage.Create(self)
image.Width:=Screen.DesktopWidth
image.Height:=Screen.DesktopHeight
scrCanvas:=Tcanvas.Create
scrCanvas.Handle:=getDc(0)
bitblt(image.canvas.handle,0,0,
image.width,image.height,
scrcanvas.handle,0,0,srccopy)
Image1.Picture:=image.Picture
image.Free
scrCanvas.Free
end
procedure TForm1.FormShow(Sender: TObject)
begin
showwindow(application.Handle,SW_HIDE)
end
我不知道LAZARUS是什么玩意。纯用DELPHI的话。
procedure TForm1.FormCreate(Sender: TObject)
var
mStyle, mExStyle: Longint
FAlphaColor: TColor
begin
FAlphaColor:= clRed
//设置窗体为无标题
mStyle:= GetWindowLong(Handle, GWL_STYLE)
SetWindowLong(Handle, GWL_STYLE, mStyle and not WS_CAPTION)
BorderStyle:= bsNone
//加载背景图像,设置窗体分层
mExStyle:= GetWindowLong(Handle, GWL_EXSTYLE)
SetWindowLong(Handle, GWL_STYLE, mExStyle or WS_EX_LAYERED)
SetLayeredWindowAttributes(Handle, FAlphaColor, 255, LWA_COLORKEY)
end
FAlphaColor这里可以设成任意颜色,一般粉红。
就是说,窗体上只要与它一样的色都透明了。
控件还是照一般那样往上放就行。
(1)procedure TForm1.FormCreate(Sender: TObject)begin
brush.style:=bsClear
end
(2)把Form1 的 BorderStyle 属性设置为 bsSizeable
不知道行不行。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)