procedure TClockForm.FormShow(Sender: TObject);
var
tempBI : BITMAPINFO;
ImgW : Cardinal;
ImgH : Cardinal;
graphics : Cardinal;
curWinStyle: Integer;
winSize : TSize;
srcPoint : TPoint;
hBM1 : HBitmap;
DC : HDC;
blendfunc : BLENDFUNCTION;
P4 : Pointer;
hbmReturn : HBitmap;
begin
DoubleBuffered := True;
if GDIReady
then
begin
With tempBI.bmiHeader
do
begin
biSize := SizeOf(tempBI.bmiHeader);
biBitCount := 32;
biHeight := Height;
biWidth := Width;
biPlanes := 1;
biSizeImage := biWidth * biHeight * (biBitCount
div 8);
end;
DC := CreateCompatibleDC(Canvas.Handle);
hBM1 := CreateDIBSection(
DC, tempBI, DIB_RGB_COLORS, P4, 0, 0);
SelectObject(
DC, hBM1);
GdipCreateFromHDC(
DC, graphics);
ImgBack := CreateImageFromFile('
wall.png');
GetImageSize(ImgBack, ImgW, ImgH);
if ImgBack <> 0
then
begin
GdipDrawImageRect(graphics, ImgBack, 0, 0, ImgW, ImgH);
curWinStyle := GetWindowLong(
Handle, GWL_EXSTYLE);
SetWindowLong(
Handle, GWL_EXSTYLE, curWinStyle
Or WS_EX_LAYERED);
SetWindowPos(
Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE
Or SWP_NOSIZE);
srcPoint.x := 0;
srcPoint.y := 0;
winSize.cx := ImgW;
winSize.cy := ImgH;
With blendFunc
do
begin
AlphaFormat := AC_SRC_ALPHA;
BlendFlags := 0;
BlendOp := AC_SRC_OVER;
SourceConstantAlpha := 255;
// here you can set Alpha
end;
GdipDisposeImage(ImgBack);
GdipDeleteGraphics(graphics);
UpdateLayeredWindow(
Handle, Canvas.Handle,
nil, @winSize,
DC, @srcPoint, 0, @blendFunc, ULW_ALPHA);
(*hbmReturn := LoadSourceImage('wall.png');
if hbmReturn <> 0 then
begin
ClockBack := TBitmap.Create;
ClockBack.Handle := hbmReturn;
CombineImage(BackImage.Picture.Bitmap.Handle, ClockBack.Handle, 0, 0,
true);
end;*)
end;
InitHand;
end;
end;