WinAPI: GetKeyNameText - 根据键盘消息获取按键名称

时间:2023-03-09 21:32:46
WinAPI: GetKeyNameText - 根据键盘消息获取按键名称

;
  Canvas.Font.Style := [fsBold];
  Canvas.Font.Color := clRed;
  Canvas.Brush.Color := clWhite;
..] 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.