WinAPI: GetKeyNameText - 根据键盘消息获取按键名称
2008-05-02 17:51
495 查看
本例效果图:
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.
相关文章推荐
- WinAPI: GetKeyNameText - 根据键盘消息获取按键名称
- [Windows API 函数] WinAPI: GetKeyNameText - 根据键盘消息获取按键名称
- GetKeyNameText - 根据键盘消息获取按键名称
- WinAPI: GetTextFace - 获取字体名称
- getkeynametext(键盘消息类型,指针,长度)返回字符串
- WinAPI: GetTextFace - 获取字体名称
- WinAPI: midiInGetErrorText - 根据错误号得到错误描述
- 键盘按键消息的获取
- WinAPI: waveInGetErrorText - 根据错误号得到错误描述
- WinAPI: midiOutGetErrorText - 根据错误号得到错误描述
- 根据 GetLastError 来获取出错处理字符串的消息
- [转]利用winapi向其它进程发送键盘按键消息
- c#.net使用WinAPI: GetComputerName - 获取计算机名称
- WinAPI: GetTextAlign - 获取绘图环境的文本对齐方式
- 键盘钩子监测按键后,获取键码及按键名称(MFC)
- WinAPI: GetKeyboardType - 获取键盘的类型信息
- WinAPI: GetComputerName - 获取计算机名称
- WinAPI: GetTextAlign - 获取绘图环境的文本对齐方式
- WinAPI: waveOutGetErrorText - 根据错误号得到错误描述
- WinAPI: midiInGetErrorText - 根据错误号得到错误描述