CWMFoundation – Keyboard

CWMFoundation

CWMFoundation 意为 Charlie.Wang Foundation Mini(迷你版)

是作者工作中为方便代码编写,逐渐整理归档的一些代码集。

在原有CWFoundation的基础上,去除了大量窗体上的控件,只留下一个Delphi Pas文件的轻量级类。

Keyboard主要用来处理按键,节约代码输入的时间。

//***********************************
//***** CWMFoundation KeyBoard ******
//***********************************
{$REGION ' CWMFoundation KeyBoard '}
function TCWKey.KEY_TO_ASCII(const KeyChar:AnsiChar):Integer;
begin
  try
    Result := Ord(KeyChar);
  except
    Result := 0;
  end;
end;
 
function TCWKey.IFDOWN_SHIFT:Boolean;
begin
  if GetKeyState(VK_SHIFT)<0 then Result:=True else Result:=False;
end;
 
function TCWKey.IFDOWN_ALT:Boolean;
begin
  if GetKeyState(VK_MENU)<0 then Result:=True else Result:=False;
end;
 
function TCWKey.IFDOWN_CTRL:Boolean;
begin
  if GetKeyState(VK_CONTROL)<0 then Result:=True else Result:=False;
end;
 
function TCWKey.IFDOWN_KEY(const KeyChar:AnsiChar):Boolean;
begin
  if GetKeyState(KEY_TO_ASCII(KeyChar))<0 then Result:=True else Result:=False;
end;
 
function TCWKey.IFDOWN_ENTER:Boolean;
begin
  if GetKeyState(VK_RETURN)<0 then Result:=True else Result:=False;
end;
{$ENDREGION}