procedure dodo(v: TComponent; Command: string);
var
i: integer;
begin
if (v is Tform) then
with V as Tform do
begin
for i := 0 to ComponentCount - 1 do
begin
if (Components is TRzBitBtn) or (Components is TRzBmpButton) or (Components is TButtonControl) then
if TWinControl(Components).CanFocus then
if TWinControl(Components).Parent.CanFocus then
if pos(Command, TRzBitBtn(Components).Caption) > 0 then
begin
try
TWinControl(Components).SetFocus;
TButton(Components).Click;
except
;
end
end;
if (Components is TFrame) then
dodo(Components, Command);
end;
end;
if (v is TFrame) then
with V as TFrame do
begin
for i := 0 to ComponentCount - 1 do
begin
if Components is TRzBitBtn then
if TRzBitBtn(Components).CanFocus then
if TRzBitBtn(Components).Parent.CanFocus then
if pos(Command, TRzBitBtn(Components).Caption) > 0 then
begin
TRzBitBtn(Components).SetFocus;
TRzBitBtn(Components).Click;
end;
if (Components is TFrame) then
dodo(Components, Command);
end;
end;
end;
procedure TFrm_main.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
var
OldAC: TWinControl;
function isLastInput(V: TWinControl): Boolean;
var
i: integer;
begin
result := false;
if v is TButton then
exit;
if v is TBitBtn then
exit;
if v is TRzBitBtn then
exit;
if v.Parent = nil then
exit;
with v.Parent do
begin
for i := 0 to ControlCount - 1 do
// if (Controls is TRzEdit) or (Controls is TRzNumericEdit) then
if (Controls is TWinControl) then
if TWinControl(Controls).CanFocus then
if v.TabOrder < TWinControl(Controls).TabOrder then
begin
exit;
end;
end;
result := true;
end;
begin
case Msg.message of
WM_CHAR:
case Msg.wParam of
34: Handled := true; //"
38: Handled := true; //'
39: Handled := true; //&
//94:Handled:=true; //^
124: Handled := true; //|
end;
WM_KEYDOWN:
begin
if screen.ActiveForm <> nil then
if screen.ActiveForm.Tag <> 999 then
exit;
OldAC := screen.ActiveControl;
case Msg.wParam of
vk_return:
if screen.ActiveControl is TRzButtonEdit then
with TRzButtonEdit(screen.ActiveControl) do
begin
if assigned(OnButtonClick) then
OnButtonClick(screen.ActiveControl);
end
else
if not (screen.ActiveControl is TCustomGrid) then
if not (screen.ActiveControl is TRzBitBtn) then
if not (screen.ActiveControl is TBitBtn) then
if not (screen.ActiveControl is TButton) then
if (not (screen.ActiveControl is Tmemo)) then
if screen.ActiveControl.Tag <> 999 then
begin
if isLastInput(screen.ActiveControl) then
begin
keybd_event(VK_F2, 0, 0, 0);
Handled := true;
exit;
end;
screen.ActiveForm.Perform(WM_NEXTDLGCTL, 0, 0);
Handled := true;
if screen.ActiveControl is TRzBitBtn then
begin
TRzBitBtn(screen.ActiveControl).Click;
end;
end;
VK_ESCAPE:
begin
if screen.ActiveForm <> nil then
dodo(screen.ActiveForm, 'Esc');
end;
VK_F2:
begin
if screen.ActiveForm <> nil then
begin
dodo(screen.ActiveForm, 'F2');
dodo(screen.ActiveForm, '确定');
setFouceFirst(OldAC);
end;
end;
VK_F3:
begin
if screen.ActiveForm <> nil then
dodo(screen.ActiveForm, 'F3');
end;
VK_F4:
begin
if screen.ActiveForm <> nil then
dodo(screen.ActiveForm, 'F4');
end;
VK_F5:
begin
if screen.ActiveForm <> nil then
dodo(screen.ActiveForm, 'F5');
end;
VK_F6:
begin
if screen.ActiveForm <> nil then
dodo(screen.ActiveForm, 'F6');
end;
VK_F7:
begin
if screen.ActiveForm <> nil then
dodo(screen.ActiveForm, 'F7');
end;
VK_F8:
begin
if screen.ActiveForm <> nil then
dodo(screen.ActiveForm, 'F8');
end;
VK_F9:
begin
if screen.ActiveForm <> nil then
dodo(screen.ActiveForm, 'F9');
end;
VK_F10:
begin
if screen.ActiveForm <> nil then
dodo(screen.ActiveForm, 'F10');
end;
end;
end;
end;
end;