- 92
- 0
- 约7.42千字
- 约 15页
- 2016-12-31 发布于重庆
- 举报
【转】XE6/XE7多窗口操作的Z轴序列错乱问题解决办法
(2014-09-26 08:01:46)
xe7 分类: DelphiXE7
盒子中的cywyes发现这个问题,并给出的答案,转贴过来,学习了!
以下为原文:
----------
XE6/XE7多窗口操作的Z轴序列错乱问题解决办法 by cyw(QQ 14.9.25
----------
一、问题现象:
1、Win32/64
MainForm -- 显示Form2 -- 显示Form3 -- 关闭Form3,MainForm显示在最前面,遮挡了Form2。(理论上:
应该是Form2在前)。
2、Android
MainForm -- 显示Form2 -- 显示Form3 -- 关闭Form3 -- 点击Form2上的TEdit控件,输入法不会弹出!
二、演示步骤:
1、在Form1上,Form2.Show;
2、在Form2上,Form3.Show;
3、在Form3上,Close;
4、Android:再点击Form2上的TEdit控件,输入法不会弹出!
Windows:Form1遮挡了Form2。
三、解决方法(适用于XE6和XE7):
修改FMX.Form.pas的以下代码:
1、function TScreen.NextActiveForm(const OldActiveForm: TCommonCustomForm): TCommonCustomForm;
整个函数改为如下:
function TScreen.NextActiveForm(const OldActiveForm: TCommonCustomForm): TCommonCustomForm;
var
I, CurrIndex: integer;
begin
Result := nil;
CurrIndex := IndexFormOfObject(OldActiveForm);
(* 总是优先找到OldActiveForm的前一个窗口(Z序列中的下一层). add by cyw 14.9.25 *)
I := -1;
if CurrIndex 0 then
begin
I := CurrIndex - 1;
while (I = 0) and (not Forms[I].Visible) do Dec(I);
end;
if I = -1 then //如果找不到,再依据原来的逻辑,先找OldActiveForm的最上层第1个窗口可视窗口。
(* add over *)
begin
I := FormCount - 1;
while (I = 0) and (I CurrIndex) and (not Forms[I].Visible) do Dec(I);
if (I 0) or (I = CurrIndex) then
begin
I := 0;
while (I FormCount) and (I CurrIndex) and (not Forms[I].Visible) do Inc(I);
end;
end;
if (I FormCount) and (I CurrIndex) then
begin
Result := Forms[I];
ActiveForm := Result;
end;
end;
2、procedure TScreen.SetActiveForm(const Value: TCommonCustomForm);
整个函数改为如下:
procedure TScreen.SetActiveForm(const Value: TCommonCustomForm);
var
NewActiveForm: TCommonCustomForm;
I: Integer;
begin
if Assigned(Value) then
begin
if not Value.Released then
begin
I := IndexFormOfObject(Value);
if I 0 then
raise EInvalidFmxHandle.Create(sArgumentInvalid);
NewActiveForm := Forms[I];
//下面一行的条件屏蔽 by cyw 14.9.25
//原因:因为在TCommonCustomForm.Activate里调用Screen.ActiveForm := Self;之前,
// 已经设置了FActive := True。如果这里保留条件“not NewActiveForm.Active”,
// 则Value窗口的Z序列就没有更新
原创力文档

文档评论(0)