- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何解决?表单样式:fsStayOnTop。我在线程中调用输入查询,但它出现在主窗体后面或不可见!
我在线程中动态创建 ZipForge。
procedure StartUpdating.DoPassword;
var
S: String;
begin
if PassSkip then
FSkipFile := True
else if InputQuery('Pas', FFileName, S) then
FPassword := AnsiString(S)
else
begin
PassSkip := True;
FSkipFile := True;
Terminate;
end;
end;
procedure StartUpdating.ZipForgePassword(Sender: TObject; FileName: String;
var NewPassword: AnsiString; var SkipFile: Boolean);
begin
FFileName := FileName;
FPassword := NewPassword;
FSkipFile := SkipFile;
Synchronize(DoPassword);
FileName := FFileName;
NewPassword := FPassword;
SkipFile := FSkipFile;
end;
即使我从线程中调用它,它也对我没有帮助:
Function TForm1.InQuery(cap1: string; cap2: string):bool;
var s:string;
begin
if InputQuery(cap1,cap2,s) then
begin
ThreadUpdating.MainPas:=s;
result:=true;
end else result:=false;
end;
最佳答案
InputQuery()
显示的表单是一个模态表单(使用 .ShowModal
显示,Delphi 的 VCL 足够智能,可以确保在 a 后面不显示模态表单)最顶层的窗口。本质上是对 DisableTaskWindows
和 NormalizeAllTopMosts
进行调用,有趣的是 NormalizeAllTopMosts
:这确保没有最顶层的窗口显示模态窗体时会显示窗口。这些调用不是直接进行的,VCL 使用了许多技巧来实现它。详细信息可以通过阅读 TCustomForm.ShowModal
的代码找到,Forms.DisableTaskWindows
、TApplication.WndProc
- 特别是 WM_ENABLE
消息的处理。
需要知道的是,如果主窗体位于最顶层,则似乎存在一个错误,允许在应用程序的主窗体后面显示模态窗体。 Delphi 2010 和 Delphi XE 上都会发生这种情况,没有用旧版本进行测试。测试非常简单:创建一个新的 Delphi VCL 应用程序,在 Form1
上设置 FormStyle=fsStayOnTop
,放置一个按钮,然后在按钮的 OnClick 中执行以下操作:
procedure TForm2.Button1Click(Sender: TObject);
var s:string;
begin
s := '';
InputQuery('a', 'b', s);
end;
这应该被视为临时修复,因为显然设计要求在显示模式表单之前“降级”最顶层的窗口。如果您知道您的主窗体位于最顶层,则应该在调用 ShowModal
进行任何操作之前执行类似的操作:
MainForm.FormStyle := fsNormal;
try
YourDialog.ShowModal;
finally MainForm.FormStyle := fsStayOnTop;
end;
在 InputQuery
的特定情况下,可以使用类似于以下函数的函数。请注意,根据OP在其他问题中的要求,我包含了将文本编辑器变成密码编辑器的功能:
function CustomInputQuery(const Caption, Prompt: string; const Password:Boolean; var Value:string): Boolean;
var F: TForm;
Ed: TEdit;
Lb: TLabel;
Bt: TButton;
WasStayOnTop:Boolean;
begin
F := TForm.Create(nil);
try
F.Caption := Caption;
Lb := TLabel.Create(F);
Lb.Parent := F;
Lb.Caption := Prompt;
Lb.Left := 8;
Lb.Top := 8;
Ed := TEdit.Create(F);
Ed.Parent := F;
Ed.Left := Lb.Left + Lb.Width + 8;
Ed.Top := 8;
Ed.Width := 150;
Ed.Text := Value;
if Password then
Ed.PasswordChar := '*';
Bt := TButton.Create(F);
Bt.Caption := 'Ok';
Bt.Default := True;
Bt.ModalResult := mrOk;
Bt.Left := 8;
Bt.Top := Ed.Top + Ed.Height + 8;
Bt.Parent := F;
Bt := TButton.Create(F);
Bt.Caption := 'Cancel';
Bt.Cancel := True;
Bt.ModalResult := mrCancel;
Bt.Left := 8 + Bt.Width + 8;
Bt.Top := Ed.Top + Ed.Height + 8;
Bt.Parent := F;
F.Width := F.Width - F.ClientWidth + Ed.Left + Ed.Width + 8;
F.Height := F.Height - F.ClientHeight + Bt.Top + Bt.Height + 8;
F.Position := poDesktopCenter;
WasStayOnTop := Assigned(Application.MainForm) and (Application.MainForm.FormStyle = fsStayOnTop);
if WasStayOnTop then Application.MainForm.FormStyle := fsNormal;
try
if F.ShowModal = mrOk then
begin
Value := Ed.Text;
Result := True;
end
else
Result := False;
finally if WasStayOnTop then Application.MainForm.FormStyle := fsStayOnTop;
end;
finally F.Free;
end;
end;
关于multithreading - Delphi:FormStyle:fsStayOnTop.InputQuery 在线程中并且位于表单后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6351648/
这是交易。主窗体设置为fsNormal。该主窗体最大化全屏并带有 float 工具栏。工具栏是正常形式,样式设置为fsStayOnTop。 大多数情况下这会按预期工作。主窗体显示,工具栏浮在其顶部。
我有一个表单(下例中的 TBigForm),它允许操作一些复杂的数据并需要显示其他信息。我将此信息放入 fsStayOnTop 表单(示例中为 OnTopForm)中,以确保它始终可见,但可以在必要时
我有一个类似于 question asked here 的主窗体和状态窗体.但是,我的状态窗口的 FormStyle 是 fsStayOnTop,当我在显示状态窗口时尝试最小化主窗体时,这会导致一
如何解决?表单样式:fsStayOnTop。我在线程中调用输入查询,但它出现在主窗体后面或不可见! 我在线程中动态创建 ZipForge。 procedure StartUpdating.DoPass
我有一个使用我自己的气球表单的应用程序。这是一种无边框、fsStayOnTop 类型的表单。 我用这段代码展示它: ShowWindow(Handle, SW_SHOWNOACTIVATE); Vis
总结: 请参阅下面来自 Craig 和 Sertac 的有用评论。 ================================================== ======= 如下面的最小化
我是一名优秀的程序员,十分优秀!