[英]How to move a panel or frame by dragging it or any component inside it?
[英]How to move to the next control inside a frame?
在我的应用程序的一种形式中,我们通过向表单添加框架来添加数据集。 对于每个帧,我们希望能够通过按Enter键从一个编辑(Dev Express Editors)控件移动到下一个控件。 到目前为止,我已经在我的控件的KeyPress和KeyUp事件中尝试了四种不同的方法。
SelectNext(TcxCurrencyEdit(Sender), True, True); // also base types attempted
SelectNext(Sender as TWinControl, True, True);
Perform(WM_NEXTDLGCTL, 0, 0);
f := TForm(self.Parent); // f is TForm or my form c := f.FindNextControl(f.ActiveControl, true, true, false); // c is TWinControl or TcxCurrencyEdit if assigned(c) then c.SetFocus;
这些方法都不适用于Delphi 5.任何人都可以指导我使用它吗? 谢谢。
当用户按下Enter键然后它触发VK_TAB
键时,我找到了一个捕获CM_DIALOGKEY
消息的旧项目。 它适用于许多不同的控件。
interface
...
procedure CMDialogKey(var Message: TCMDialogKey);message CM_DIALOGKEY;
implementation
...
procedure TSomeForm.CMDialogKey(var Message : TCMDialogKey);
begin
case Message.CharCode of
VK_RETURN : Perform(CM_DialogKey, VK_TAB, 0);
...
else
inherited;
end;
end;
这适用于Delphi 3,5和6:
将表单的KeyPreview属性设置为True。
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
If (Key = #13) then
Begin
SelectNext(ActiveControl as TWinControl, True, True);
Key := #0;
End;
end;
事件onKeyPress像任何其他形式一样被触发。
问题是程序执行(wm_nextdlgctl,0,0)在框架内不起作用。
您必须知道主动控件才能使正确的事件发生变化。
procedure TFrmDadosCliente.EditKeyPress(Sender: TObject; var Key: Char);
var
AParent:TComponent;
begin
if key = #13 then
begin
key := #0;
AParent:= TComponent(Sender).GetParentComponent;
while not (AParent is TCustomForm) do
AParent:= AParent.GetParentComponent;
SelectNext(TCustomForm(AParent).ActiveControl, true, true);
end;
end;
您可以在表单上放置TButton,将其缩小并将其隐藏在其他控件下。 将Default属性设置为true(使其获得Enter键)并将以下内容放入OnClick事件:
SelectNext(ActiveControl, true, true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.