procedure DrawTextOnDesktop(TextToDraw:
string) ;
var
Handle: HWnd;
Dc: HDC;
ACanvas: TCanvas;
bmp: TBitmap;
iSz: TSize;
begin
bmp :=
nil;
Handle := GetDesktopWindow;
Dc := GetWindowDC(
Handle);
if Dc <> 0
then
try
ACanvas := TCanvas.Create;
ACanvas.Handle :=
DC;
bmp := TBitmap.Create;
bmp.Canvas.Font.Color := clRed;
bmp.Canvas.Font.
Name := '
Tahoma';
bmp.Canvas.Font.Size := 30;
bmp.Canvas.Brush.Style := bsClear;
iSz := bmp.Canvas.TextExtent(TextToDraw);
bmp.SetSize(iSz.cx, iSz.cy);
bmp.Canvas.CopyRect(Rect(0,0, iSz.cx, iSz.cy), ACanvas, Rect(10,10,10+iSz.cx, 10+iSz.cy) );
bmp.Canvas.TextOut(0, 0, TextToDraw) ;
ACanvas.Draw(10,10, bmp);
finally
bmp.Free;
ReleaseDC(
Handle,
Dc) ;
ACanvas.Free;
end;
end;