Einzelnen Beitrag anzeigen

Whookie

Registriert seit: 3. Mai 2006
Ort: Graz
441 Beiträge
 
Delphi 10.3 Rio
 
#2

AW: transparenten Text auf Desktop

  Alt 1. Sep 2014, 21:17
Eine Variante die auf jeden Fall geht (..unter Windows 7):

Delphi-Quellcode:
procedure DrawTextOnDesktop(TextToDraw: string) ;
 var
    Handle: HWND;
    Dc: HDC;
    ACanvas: TCanvas;
    bmp: TBitmap;
    iSz: TSize;
 begin
    Handle := GetDesktopWindow;
    Dc := GetWindowDC(Handle) ;
    ACanvas := TCanvas.Create;
    bmp := TBitmap.Create;
    try
      ACanvas.Handle := DC;

      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, ACanvas.Handle) ;
      ACanvas.Free;
    end;
 end;
Whookie

Software isn't released ... it is allowed to escape!
  Mit Zitat antworten Zitat