W
wuyaobin
Unregistered / Unconfirmed
GUEST, unregistred user!
代码:
//用如下过程建立Form2后,如何使Form2的FormKeyDown响应?
//已设Form2.KeyPreview:=True
//**************Form1**************
procedure ShowForm(FormClass:TFormClass;Form:TForm;FParent:TPanel);//窗口融合
begin
if Form=nil then
Form:=FormClass.Create(nil);
FParent.DockSite:=True;
with Form do
begin
do
ckSite:=True;
DragKind:=DkDock;
Align:=alClient;
HostDockSite:=FParent;
Show;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ShowForm(TForm2,Form2,Panel1);//建立Form2
end;
//**************Form2**************
procedure TForm2.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
if key=VK_Return then
ShowMessage('Form2 VK_Return');//没有响应
end;