procedure SetFocusToNext(Form: TObject; Key: Word);
begin
with Form as TForm do
case Key of
VK_Return://响应回车键。
begin
if not (ActiveControl is TDBGrid) and not (ActiveControl is TMemo) then
begin
PerForm(WM_NEXTDLGCTL, 0, 0);
end
else if (ActiveControl is TDBGrid) then
with TDBGrid(ActiveControl) do
if selectedIndex < (FieldCount - 1) then
selectedIndex := selectedIndex + 1
else
selectedIndex := 0;
end;
VK_ESCape://响应ESC键。
begin
if application.MessageBox('是否关闭当前窗口?', 'RelTest', MB_YesNo + MB_ICONQUESTION) = id_yes then
Close;
end;
44 {VK_Print}://响应打印键。
if application.MessageBox('打印当前窗口吗?', 'RelTest', MB_YesNo + MB_ICONQUESTION) = id_yes then
begin
Print;
end;
end;
end;
procedure TParentForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action := cafree;
end;
procedure TParentForm.FormCreate(Sender: TObject);
begin
Scaled := true;
if (screen.width <> orignwidth) then begin//实现分辨率的自适应。
height := longint(height) * longint(screen.height) div orignheight;
width := longint(width) * longint(screen.width) div orignwidth;
scaleby(screen.width, orignwidth);
end;
end;
procedure TParentForm.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = 13 then //回车实现焦点的移动。
SetFocusTonext(Sender as Tform, Key);
end;
procedure TParentForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if ActiveControl is TMemo then
HideCaret(ActiveControl.handle);
end;
把一个窗体作为父窗体,以后都
TMonitorW = class(TParentForm)