标签:des style blog http io color ar sp for
最主要是取得了桌面的DC,并且设置为背景色透明:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} //把文字输出到屏幕 procedure TForm1.Button1Click(Sender: TObject); var cvs: TCanvas; Rect: TRect; Str: string; begin cvs := TCanvas.Create; // 现场创建 cvs.Handle := GetDC(0); SetBkMode(cvs.Handle, TRANSPARENT); // 设置指定DC的背景混合模式,应用于文字、画刷和画笔风格(当它们不是sold风格的时候),有OPAQUE和TRANSPARENT两种模式 //cvs.Font.Name := ‘宋体‘; cvs.Font.Style := [fsBold, fsItalic]; cvs.Font.Size := 48; Randomize; cvs.Font.Color := Random($FFFFFF); Rect := Screen.DesktopRect; // 取得屏幕的区域 Str := ‘万一的 Delphi 博客‘; cvs.TextRect(Rect, Str, [tfSingleLine, tfCenter, tfVerticalCenter]); // 在指定区域内输出文字,单行,居中,竖向居中 cvs.Free; end; //刷新显示 procedure TForm1.Button2Click(Sender: TObject); begin InvalidateRect(0, nil, False); end; end.
参考:
http://www.cnblogs.com/del/archive/2008/05/22/1204672.html
标签:des style blog http io color ar sp for
原文地址:http://www.cnblogs.com/findumars/p/4104227.html