画在图标下面

时间:2011-12-20 07:49:54

标签: delphi

我正在寻找一种方法,使用delphi在windows桌面图标下绘制bmp / text。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您需要使用桌面画布。诀窍是,首先,onFormCreate,你在delphi TCanvas中捕获桌面画布句柄。

procedure TForm1.FormCreate(Sender: TObject);
begin
  FDesktopCanvas := TCanvas.Create;
  FDesktopCanvas.Handle := GetWindowDC(0);
end;

然后在onFormDestroy上销毁它。

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FDesktopCanvas.Free;
end;

在您的代码中,每次需要绘制时,只需将FDesktopCanvas用作常规画布...

FDesktopCanvas.pen.Color := clWhite;
FDesktopCanvas.pen.Width := 5;
FDesktopCanvas.moveto(Screen.Width, 2);
FDesktopCanvas.lineto(2, 2);

...

var  aBitmap: TBitmap;
....
aBitmap := TBitmap.Create;
try
  aBitmap.LoadFromFile('logo100px.bmp');
  FDesktopCanvas.draw(Screen.Width-200, 100, aBitmap);
finally
  aBitmap.Free;
end;

...

FDesktopCanvas.Font.Name := 'Segoe';
FDesktopCanvas.Font.Size   := 36;
FDesktopCanvas.Font.Color  := clWhite;
FDesktopCanvas.Brush.Style := bsclear;
FDesktopCanvas.textout(Screen.Width-200, Screen.Height-100,FormatDateTime('hh:nn:ss',now));