jmc*_*jmc 5 delphi tform windowing
我目前正在为现有的Delphi应用程序编写一个窗口系统.
目前,该程序由许多全尺寸表格组成,这些表格按照所需的顺序以模态方式显示,并且用户不能移动任何形式.我的目标是让所有这些形式都可以移动.以前的表单堆叠在彼此之上,但由于没有可以移动,因此用户看不到背景表单.到目前为止,我的解决方案是在打开一个新孩子时隐藏"父母"表格,并在孩子关闭时重新显示它.
不幸的是,由于使用showModal调用每个子节点,因此直到模态过程完成之后,才会调用make父表单可见,因此在隐藏子表单之后,用户会看到没有表单可见的瞬间闪存.
有没有办法阻止模态表单在完成进程后自动隐藏?一旦父表单再次可见,这将允许我手动隐藏它们.我试图在每个子表单的FormHide事件中安排此操作但这不起作用,因为在打开其自己的子项时也会隐藏子表单.
编辑:
以下是我根据雷米的建议给出的内容
procedure openModalChild(child: TForm; parent: TForm);
var
WindowList: Pointer;
SaveFocusCount: Integer;
SaveCursor: TCursor;
SaveCount: Integer;
ActiveWindow: HWnd;
Result: integer;
begin
CancelDrag;
with child do begin
Application.ModalStarted;
try
ActiveWindow := GetActiveWindow;
WindowList := DisableTaskWindows(0);
//set the window to fullscreen if required
setScreenMode(child);
try
Show; //show the child form
try
SendMessage(Handle, CM_ACTIVATE, 0, 0);
ModalResult := 0;
repeat
Application.HandleMessage;
//if Forms.Application.FTerminate then ModalResult := mrCancel else
if ModalResult <> 0 then closeModal(child as TCustomForm);
until ModalResult <> 0;
Result := ModalResult;
SendMessage(Handle, CM_DEACTIVATE, 0, 0);
if GetActiveWindow <> Handle then ActiveWindow := 0;
finally
parent.Show;
Hide;
end;
finally
EnableTaskWindows(WindowList);
parent.Show; //reshow the parent form
if ActiveWindow <> 0 then SetActiveWindow(ActiveWindow);
end;
finally
Application.ModalFinished;
end;
end;
end;
Run Code Online (Sandbox Code Playgroud)
这很有效,但唯一的问题是主动重复循环永远不会中断,即使在子进程被转义后也是如此,因此父表单永远不会被重新表示.有什么办法可以解决这个问题吗?
Rem*_*eau 10
ShowModal()
explicitally调用Show()
刚刚进入它的模式处理循环之前,和explicitally调用Hide()
退出循环之后.如果不更改VCL的Forms.pas源文件中的代码,则无法更改.
如果您需要更好地控制窗口,而无需编辑VCL源代码,则根本不要使用ShowModal()
.使用Show()
,Hide()
,DisableTaskWindows()
,和EnableTaskWindows()
自己的需要.我想你会看看Forms.pas,看看它们是如何被使用的.将实现复制ShowModal()
到您自己的函数中,然后您可以根据需要自定义它.
归档时间: |
|
查看次数: |
2957 次 |
最近记录: |