📄 ikeyboard.pas
字号:
Row := 4;
CreateButton(iVK_SHIFT, Row, 5, False);
CreateButton(iVK_Z, Row, 2, False);
CreateButton(iVK_X, Row, 2, False);
CreateButton(iVK_C, Row, 2, False);
CreateButton(iVK_V, Row, 2, False);
CreateButton(iVK_B, Row, 2, False);
CreateButton(iVK_N, Row, 2, False);
CreateButton(iVK_M, Row, 2, False);
CreateButton(iVK_OEM_COMMA, Row, 2, False);
CreateButton(iVK_OEM_PERIOD, Row, 2, False);
CreateButton(iVK_OEM_2, Row, 2, False); // / and ?
CreateButton(iVK_SHIFT, Row, 5, False);
Row := 5;
CreateButton(iVK_CONTROL, Row, 3, False);
CreateButton(iVK_LWIN, Row, 2, False);
CreateButton(iVK_MENU, Row, 3, False);
CreateButton(iVK_SPACE, Row, 12, False);
CreateButton(iVK_MENU, Row, 3, False);
CreateButton(iVK_RWIN, Row, 2, False);
CreateButton(iVK_APPS, Row, 2, False);
CreateButton(iVK_CONTROL, Row, 3, False);
end;
//*************************************************************************************************************************************
procedure TiKeyBoard.Setup061;
var
Row : Integer;
begin
RemoveAllButtons;
Row := 0;
CreateButton(iVK_OEM_3, Row, 2, False);
CreateButton(iVK_1, Row, 2, False);
CreateButton(iVK_2, Row, 2, False);
CreateButton(iVK_3, Row, 2, False);
CreateButton(iVK_4, Row, 2, False);
CreateButton(iVK_5, Row, 2, False);
CreateButton(iVK_6, Row, 2, False);
CreateButton(iVK_7, Row, 2, False);
CreateButton(iVK_8, Row, 2, False);
CreateButton(iVK_9, Row, 2, False);
CreateButton(iVK_0, Row, 2, False);
CreateButton(iVK_OEM_MINUS, Row, 2, False);
CreateButton(iVK_OEM_PLUS, Row, 2, False);
CreateButton(iVK_BACK, Row, 4, False);
Row := 1;
CreateButton(iVK_TAB, Row, 3, False);
CreateButton(iVK_Q, Row, 2, False);
CreateButton(iVK_W, Row, 2, False);
CreateButton(iVK_E, Row, 2, False);
CreateButton(iVK_R, Row, 2, False);
CreateButton(iVK_T, Row, 2, False);
CreateButton(iVK_Y, Row, 2, False);
CreateButton(iVK_U, Row, 2, False);
CreateButton(iVK_I, Row, 2, False);
CreateButton(iVK_O, Row, 2, False);
CreateButton(iVK_P, Row, 2, False);
CreateButton(iVK_OEM_4, Row, 2, False); // [ and {
CreateButton(iVK_OEM_6, Row, 2, False); // ] and }
CreateButton(iVK_OEM_5, Row, 3, False); // \ and |
Row := 2;
CreateButton(iVK_CAPITAL, Row, 4, False);
CreateButton(iVK_A, Row, 2, False);
CreateButton(iVK_S, Row, 2, False);
CreateButton(iVK_D, Row, 2, False);
CreateButton(iVK_F, Row, 2, False);
CreateButton(iVK_G, Row, 2, False);
CreateButton(iVK_H, Row, 2, False);
CreateButton(iVK_J, Row, 2, False);
CreateButton(iVK_K, Row, 2, False);
CreateButton(iVK_L, Row, 2, False);
CreateButton(iVK_OEM_1, Row, 2, False); // ; and :
CreateButton(iVK_OEM_7, Row, 2, False); // ' and "
CreateButton(iVK_RETURN, Row, 4, False);
Row := 3;
CreateButton(iVK_SHIFT, Row, 5, False);
CreateButton(iVK_Z, Row, 2, False);
CreateButton(iVK_X, Row, 2, False);
CreateButton(iVK_C, Row, 2, False);
CreateButton(iVK_V, Row, 2, False);
CreateButton(iVK_B, Row, 2, False);
CreateButton(iVK_N, Row, 2, False);
CreateButton(iVK_M, Row, 2, False);
CreateButton(iVK_OEM_COMMA, Row, 2, False);
CreateButton(iVK_OEM_PERIOD, Row, 2, False);
CreateButton(iVK_OEM_2, Row, 2, False); // / and ?
CreateButton(iVK_SHIFT, Row, 5, False);
Row := 4;
CreateButton(iVK_CONTROL, Row, 3, False);
CreateButton(iVK_LWIN, Row, 2, False);
CreateButton(iVK_MENU, Row, 3, False);
CreateButton(iVK_SPACE, Row, 12, False);
CreateButton(iVK_MENU, Row, 3, False);
CreateButton(iVK_RWIN, Row, 2, False);
CreateButton(iVK_APPS, Row, 2, False);
CreateButton(iVK_CONTROL, Row, 3, False);
end;
//*************************************************************************************************************************************
constructor TiKeyBoardButton.Create;
begin
inherited;
UpdateKeyState;
end;
//*************************************************************************************************************************************
procedure TiKeyBoardButton.SetAcceptLock (const Value:Boolean );begin if FAcceptLock <>Value then begin FAcceptLock :=Value;Invalidate;end;end;
procedure TiKeyBoardButton.SetCaptionShift (const Value:String );begin if FCaptionShift <>Value then begin FCaptionShift :=Value;Invalidate;end;end;
procedure TiKeyBoardButton.SetCaptionStandard(const Value:String );begin if FCaptionStandard<>Value then begin FCaptionStandard:=Value;Invalidate;end;end;
procedure TiKeyBoardButton.SetDoubleHeight (const Value:Boolean );begin if FDoubleHeight <>Value then begin FDoubleHeight :=Value;Invalidate;end;end;
procedure TiKeyBoardButton.SetRow (const Value:Integer );begin if FRow <>Value then begin FRow :=Value;Invalidate;end;end;
procedure TiKeyBoardButton.SetSize (const Value:Integer );begin if FSize <>Value then begin FSize :=Value;Invalidate;end;end;
procedure TiKeyBoardButton.SetStyle (const Value:TiKeyBoardButtonStyle);begin if FStyle <>Value then begin FStyle :=Value;Invalidate;end;end;
procedure TiKeyBoardButton.SetVirtualKeyCode (const Value:Integer );begin if FVirtualKeyCode <>Value then begin FVirtualKeyCode :=Value;Invalidate;end;end;
//*************************************************************************************************************************************
procedure TiKeyBoardButton.iMouseDown(Button: TMouseButton; Shift: TShiftState; X, Y, ScreenX, ScreenY: Integer);
begin
if not Enabled then Exit;
if IsToggle then
begin
MouseDown := not MouseDown;
end
else MouseDown := True;
end;
//*************************************************************************************************************************************
procedure TiKeyBoardButton.iMouseUp(Button: TMouseButton; Shift: TShiftState; X, Y, ScreenX, ScreenY: Integer);
begin
if not Enabled then Exit;
begin
MouseDown := False;
if PtInRect(DrawRect, Point(X, Y)) then
begin
if IsToggle then
begin
Down := not Down;
end;
if (FStyle = ikbbsStandard) or (FStyle = ikbbsAccent) then
begin
//KYLIX TODO
{$ifndef iCLX}
Windows.SetFocus(FFocusHandle);
if FShowShift then keybd_event(iVK_SHIFT, 0, 0, 0);
if FCtrlActive then keybd_event(iVK_CONTROL, 0, 0, 0);
if FAltActive then keybd_event(iVK_MENU, 0, 0, 0);
keybd_event(FVirtualKeyCode, 0, 0, 0);
keybd_event(FVirtualKeyCode, 0, KEYEVENTF_KEYUP, 0);
if FAltActive then keybd_event(iVK_MENU, 0, KEYEVENTF_KEYUP, 0);
if FCtrlActive then keybd_event(iVK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
if FShowShift then keybd_event(iVK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
{$endif}
end;
DoChange;
if Assigned(OnClick) then OnClick(Self);
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiKeyBoardButton.Draw(const Canvas: TCanvas);
var
ARect : TRect;
AText : String;
AFlags : TiTextFlags;
begin
UpdateKeyState;
with Canvas do
begin
ARect := DrawRect;
InflateRect(ARect, -1, -1);
AFlags := [itfHCenter, itfVCenter, itfSingleLine];
AText := DisplayString;
if MouseDown then
begin
Brush.Style := bsSolid;
Brush.Color := clWhite;
FillRect(Rect(ARect.Left+1, ARect.Top+1, ARect.Right, ARect.Bottom));
iDrawEdge(Canvas, ARect, idesSunken);
if not Enabled then
begin
Brush.Style := bsClear;
Font.Color := clBtnHighlight; OffsetRect(ARect, 1 , 1); iDrawText(Canvas, AText, ARect, AFlags);
Font.Color := clBtnShadow; OffsetRect(ARect,-1 ,-1); iDrawText(Canvas, AText, ARect, AFlags);
end
else
begin
OffsetRect(ARect,1 ,1);
iDrawText(Canvas, AText, ARect, AFlags);
end;
end
else
if Down then
begin
Brush.Style := bsSolid;
Brush.Color := clLime;
FillRect(Rect(ARect.Left+1, ARect.Top+1, ARect.Right, ARect.Bottom));
iDrawEdge(Canvas, ARect, idesSunken);
Brush.Style := bsClear;
Font.Color := clWhite;
OffsetRect(ARect, 2, 2);
iDrawText(Canvas, AText, ARect, AFlags);
Font.Color := clBlack;
OffsetRect(ARect, -1, -1);
iDrawText(Canvas, AText, ARect, AFlags);
end
else
begin
Brush.Style := bsSolid;
Brush.Color := clBtnFace;
FillRect(Rect(ARect.Left+1, ARect.Top+1, ARect.Right, ARect.Bottom));
iDrawEdge(Canvas, ARect, idesRaised);
if not Enabled then
begin
Brush.Style := bsClear;
Font.Color := clBtnHighlight; OffsetRect(ARect, 1 , 1); iDrawText(Canvas, AText, ARect, AFlags);
Font.Color := clBtnShadow; OffsetRect(ARect,-1 ,-1); iDrawText(Canvas, AText, ARect, AFlags);
end
else iDrawText(Canvas, AText, ARect, AFlags);
end;
end;
end;
//*************************************************************************************************************************************
procedure TiKeyBoardButton.UpdateKeyState;
begin
if Style = ikbbsStandard then
begin
FShowShift := FShiftActive;
if Trim(FCaptionShift) = '' then FShowShift := False
else if FAcceptLock then if FLockActive then FShowShift := not FShowShift;
Enabled := FVirtualKeyCode <> 0;
end
else
begin
FShowShift := False;
Enabled := True;
end;
end;
//*************************************************************************************************************************************
function TiKeyBoardButton.GetDisplayString: String;
begin
if FShowShift then Result := FCaptionShift else Result := FCaptionStandard;
end;
//*************************************************************************************************************************************
procedure TiKeyBoard.SavePropertiesToFile(FileName: String);
var
x : Integer;
AList : TStringList;
IgnoreList : TStringList;
begin
try
AList := TStringList.Create;
try
IgnoreList := TStringList.Create;
try
IgnoreList.Add('Name');
if not OptionSaveAllProperties then
begin
IgnoreList.Add('Left');
IgnoreList.Add('Top');
IgnoreList.Add('Width');
IgnoreList.Add('Height');
IgnoreList.Add('Align');
IgnoreList.Add('Cursor');
IgnoreList.Add('ShowHint');
IgnoreList.Add('Tag');
IgnoreList.Add('Visible');
IgnoreList.Add('Enabled');
IgnoreList.Add('Hint');
IgnoreList.Add('HelpContext');
end;
AList.Add('File Type = ' + Self.ClassName);
SaveObjectToStringList(Self, '', AList, IgnoreList);
AList.Add('KeyCount = ' + IntToStr(KeyCount));
for x := 0 to KeyCount-1 do SaveObjectToStringList(KeyButton[x], 'Key' + IntToStr(x), AList, nil);
AList.SaveToFile(FileName);
finally
IgnoreList.Free;
end;
finally
AList.Free;
end;
except
on e: Exception do raise Exception.Create('Error Saving Properties - ' + e.message);
end;
end;
//*************************************************************************************************************************************
procedure TiKeyBoard.LoadProperti
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -