ugetbkcolor.pas
来自「Delphi Win32核心API参考光盘源码 本书包含了常用的Windows」· PAS 代码 · 共 44 行
PAS
44 行
unit UGetBkColor;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
{if the background color is not red, make it so}
if GetBkColor(Canvas.Handle)<>clRed then
SetBkColor(Canvas.Handle, clRed);
{output some text. the background color will be used}
Canvas.TextOut(20, 20, 'Text with a background color');
{if the background mode is not transparent, make it so}
if GetBkMode(Canvas.Handle)<>TRANSPARENT then
SetBkMode(Canvas.Handle, TRANSPARENT);
{draw some text. the background color will not be used}
Canvas.TextOut(20, 40, 'Text drawn with a transparent background');
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?