Einzelnen Beitrag anzeigen

Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#9

AW: transparenten Text auf Desktop

  Alt 3. Sep 2014, 11:09
Du kannst es ja mal so versuchen, wenn Du noch glattere Schriften brauchst kannst Du statt per Canvasroutinen per hier im Formum unbeliebten GDI+ Routinen den Text auf das Bitmap aufbringen.

Delphi-Quellcode:
type
  TForm5 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form5: TForm5;

implementation

{$R *.dfm}
var
  Bitmap: TBitmap;


procedure TForm5.FormCreate(Sender: TObject);
var
  BlendFunction: TBlendFunction;
  BitmapPos: TPoint;
  BitmapSize: TSize;
  exStyle: DWORD;
begin
  BorderStyle := bsNone;
  Left := 0;
  Top := 0;
  Width := Screen.Width;
  Height := Screen.Height;
  // Enable window layering
  exStyle := GetWindowLongA(Handle, GWL_EXSTYLE);
  if (exStyle and WS_EX_LAYERED = 0) then
    SetWindowLong(Handle, GWL_EXSTYLE, exStyle or WS_EX_LAYERED);

  Bitmap := TBitmap.Create;
  Bitmap.Canvas.Brush.Color := clBlack;
  Bitmap.Width := Width;
  Bitmap.Height := height;
  Bitmap.Canvas.Font.Color := clWhite;
  Bitmap.Canvas.Font.Size := 10;
  Bitmap.Canvas.TextOut(10,10,'Hallo die ist ein Test');


  BitmapPos := Point(0, 0);
  BitmapSize.cx := Bitmap.Width;
  BitmapSize.cy := Bitmap.Height;

  BlendFunction.BlendOp := AC_SRC_OVER;
  BlendFunction.BlendFlags := 0;
  BlendFunction.SourceConstantAlpha := 255;
  BlendFunction.AlphaFormat := AC_SRC_ALPHA;

  // ... and action!
  UpdateLayeredWindow(Handle, 0, nil, @BitmapSize, Bitmap.Canvas.Handle,
    @BitmapPos, 0, @BlendFunction, ULW_ALPHA);

end;
procedure TForm5.FormDestroy(Sender: TObject);
begin
  Bitmap.Free;
end;
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
  Mit Zitat antworten Zitat