首页 > 代码库 > 按键处理 焦点处理
按键处理 焦点处理
procedure TFrameEntry.aplctnvnts1Message(var Msg: tagMSG; var Handled: Boolean); var aWinControl: TWinControl; begin if (Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP) then begin if Assigned(FCurrentEditBox) and (Msg.wParam = VK_F1) and (Screen.ActiveControl <> FCurrentEditBox) then begin if FCurrentEditBox.CanFocus then FCurrentEditBox.SetFocus; Handled := True; Exit; end; end; if not (Screen.ActiveControl is TEdit) then Exit; if (Msg.message = WM_RBUTTONDOWN) or (Msg.message = WM_PASTE) then begin Handled := True; end else if (Msg.message = WM_SYSKEYDOWN) or (Msg.message = WM_SYSKEYUP)then begin if Msg.wParam in [VK_TAB, VK_RWIN, VK_APPS, VK_SLEEP, VK_F10] then Handled := True; end else if (Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP) then begin if (ssCtrl in KeyDataToShiftState(Msg.lParam)) then begin if (Msg.wParam in [Ord(‘C‘), Ord(‘V‘)]) or (Msg.wParam in [VK_TAB, VK_RWIN, VK_APPS, VK_SLEEP]) then begin Handled := True; end else end else if Msg.message = WM_KEYDOWN then begin if Msg.wParam = VK_RETURN then begin aWinControl := FindNextControl(Screen.ActiveControl, true, false, false); if (aWinControl is TEdit) and aWinControl.CanFocus then begin aWinControl.SetFocus; if FIsFirstEditBox then FIsFirstEditBox := False; end else begin FIsLastEditBox := True; lbl3.Caption := ‘Last‘; end; Handled := True; end else if Msg.wParam = VK_F9 then begin aWinControl := FindNextControl(Screen.ActiveControl, False, false, false); if (aWinControl is TEdit) and aWinControl.CanFocus then begin aWinControl.SetFocus; if FIsLastEditBox then FIsLastEditBox := False; end else begin FIsFirstEditBox := True; lbl3.Caption := ‘First‘; end; Handled := True; end; end; end; end;
按键处理 焦点处理
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。