分享

WinAPI: GetKeyNameText

 独孤求财 2012-03-30
本例效果图:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure MyMsg(var msg: TWMKeyDown); message WM_KEYDOWN;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Canvas.Font.Size := 24;
  Canvas.Font.Style := [fsBold];
  Canvas.Font.Color := clRed;
  Canvas.Brush.Color := clWhite;
end;

procedure TForm1.MyMsg(var msg: TWMKeyDown);
var
  buf: array[0..31] of Char;
  rect: TRect;
  str: string;
begin
  {获取}
  GetKeyNameText(msg.KeyData, buf, Length(buf));
  {画出来}
  str := buf;
  rect := ClientRect;
  Canvas.FillRect(rect);
  Canvas.TextRect(rect, str, [tfSingleLine, tfCenter, tfVerticalCenter]);
  inherited;
end;

end.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多