- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在我的应用程序的两个部分中,主窗体在错误的时刻获得焦点:
错误 1。在特定打印机表单中单击“确定”时。
错误 2. 单击或拖动此特定滚动框会聚焦主窗体
我想解决这个奇怪的行为。所以,我的问题是:
What can be causing these focussing bugs?
关于申请:
编辑
所有其他表单,包括主表单,都由应用程序拥有,而不是由登录表单拥有。确实不是作为 parent ,而是作为所有者,就像@uwe-raabe 说的那样。
然后主窗体就创建好了。这是通过登录表单创建的:
Frm_DatabaseLogin.CreateForm(TFrm_MainMenu, Frm_MainMenu);
调用:
procedure TFrm_DataBaseLogin.CreateForm(InstanceClass: TComponentClass;
var Reference);
begin
Updateprogress(InstanceClass.ClassName);
Application.CreateForm(InstanceClass,Reference);
end;
在 UpdateProgress 中没有什么特别的事情发生。
之后,其他表单也被创建,由应用程序拥有。最后,登录表单隐藏,因此显示主表单。
最佳答案
我在这里对您的启动代码做了一些假设。
“主窗体”可能是一个令人困惑的术语。从 TApplication 的角度来看,Application.MainForm 始终是使用 Application.CreateForm 创建的第一个窗体。
由于您的登录表单创建了您的应用程序的主表单然后隐藏了自身,因此登录表单仍然是“主要”表单。
您的屏幕截图在任务栏上显示了两个图标。我假设您要么正在覆盖 CreateParams,要么正在调用 SetWindowLong 来实现这一点。
我有一个类似的设置,其中包含一个“主”登录表单,该表单随后被隐藏。
在我的应用程序中,我为应该独立且具有任务栏图标的表单覆盖了 CreateParams:
procedure TMgrMain.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent := 0;
end;
然后在显示弹出窗口时,我创建了带有所有者的表单(可能不需要),然后设置 PopupMode 和 PopupParent。自从我开始这个以来,我不再有弹出的表格。
procedure ShowAbout(Owner: TForm);
var
LocalForm: TAbout;
begin
LocalForm := TAbout.Create(Owner);
try
LocalForm.PopupMode := pmExplicit;
LocalForm.PopupParent := Owner;
LocalForm.ShowModal;
finally
FreeAndNil(LocalForm);
end;
end;
来自PopupParent help :
If the PopupMode property is set to pmExplicit and PopupParent is nil, then the Application.MainForm is implicitly used as the PopupParent. If no Application.MainForm is assigned, then Application.Handle is used as the PopupParent.
If the PopupMode property is set to pmAuto, Screen.ActiveForm is used as the PopupParent property.
我迈步的部分地方来自一位老 Peter Below newsgroup post .这也是现在非常古老的建议,并且是在添加 PopupParent/PopupMode 之前
Newsgroups: borland.public.delphi.winapi
From: "Peter Below (TeamB)" <100113.1...@compuXXserve.com>
Date: 2000/11/30
Subject: Re: Modeless window act like .exe.. cut ..
Note that this can cause some problems with modal forms shown from secondary forms. If the user switches away from the app while a modal form is up and then back to the form that showed it the modal form may hide beneath the form. It is possible to deal with this by making sure the modal form is parented to the form that showed it (using params.WndParent as above) but this is not possible with the standard dialogs from the Dialogs unit and exceptions, which need more effort to get them to work right (basically handling Application.OnActivate, looking for modal forms parented to Application via GetLastActivepopup and bringing them to the top of the Z-order via SetWindowPos).
.. cut ..
最后是一个blog post讨论了为什么要对 PopupMode 和 PopupParent 进行更改。
关于windows - Delphi - 应用程序主窗体的焦点不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47200322/
程序集,masm 嘿,我写了宏来打印存储在 dane1 段中的 1 字节值。 我将值除以 16,然后将提醒推送到堆栈,直到值==0。然后我弹出提醒将它们转换为 ASCII 码,并打印它们。 有人可以看
我在 Apache Geronimo 2.1.3 上有一个 Web 服务应用程序。 我正在使用 JAX-WS,使用 SOAP 1.1 注释 POJOS。 (使用 Sun JDK 1.5) 各种客户端都
我有一个数据变量,monthArray,它被多个消费者读取,并由单个定期更新程序线程定期更新数据。全部异步。 我已经考虑了这两个选项来安全地执行更新。 ArrayList tempArray
我有一组 3D 体。每个 Body 由 8 个点定义,每个点具有三个坐标。所有的物体都是立方体的或近似立方体的。我想用系统的点栅格“填充”立方体。坐标存储在简单的 data.frames 中。 我开发
我正在处理遗留代码,需要打补丁。 问题:一个古老的应用程序发送错误的 HTTP POST 请求。其中一个参数未经过 URL 编码。我知道这个参数总是排在最后而且我知道它的名字。我现在正尝试在运行在 t
我想在触摸屏幕时移动 sprite body ,但它不能发生...... -(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
这个问题在这里已经有了答案: Can a union be initialized in the declaration? (3 个答案) 关闭 7 年前。 如果它是一个struct那么它就可以完成
我正在尝试获取生成 sigsys 信号的系统调用的地址!但我从 gcc 收到以下错误: gcc emulator.c -fms-extensions error: ‘siginfo_t’ has no
当我使用 Postman 进行 API 调用时,我收到一个 JSON 对象..这是我所期望的。 但是,当我像这样与 Guzzle 进行相同的调用时: $client = new \GuzzleHttp
在编码时,出现了差异。通常在编写简单的方法或构造函数时,我经常使用表达式体技术。但是,当我产生以下内容时: public class Sample : ISample { private r
我正在使用 LibGDX 创建一个新项目。 我想做的是,我将 tmx 文件中的主体加载到工作正常的关卡中。尸体也有一个 Sprite 。 问题是,我想让用户触摸场景中的某些 body 。当他们触摸 b
我的意图:在不使用 union 的情况下循环遍历一个结构的 30 个成员,所有成员都是字符数组类型,每个成员都存储对 itoa 的调用结果。在下面的代码中,我将结构体成员命名为a-z、A-D。在调用函
我必须将我的代码段之一从 C 转换为 java。代码如下。 union commandString{ char commndStr[20]; struct{ char
#include union NumericType { float value; int intvalue; }Values; int main() { Values.va
我在此代码中收到错误: fun num(num:Int):Int { if (num > 0){ print(num % 10) return num / 10
我是一名优秀的程序员,十分优秀!