ag游戏庄闲|官方网站
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
?用户名
?密??码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: sy1368364703
今日帖子: 12
在线用户: 20
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil ?
作者:
男 vkow (vkow) ▲▲▲▲▲ -
普通会员
2019/8/14 8:38:06
标题:
请教个VCL的Form始终在另一个Form的前面的问题 浏览:436
加入我的收藏
楼主: 主Form1中创建一个Form2,不是多窗口的那种主子关系。

怎么做到能让Form2始终在Form1的前面?

fsStayOnTop属性虽然可以,但是变成了这个窗口在其他应用前面了。

还有其他方法吗?
----------------------------------------------
-
作者:
男 redhan (晓寒) ★☆☆☆☆ -
盒子活跃会员
2019/8/14 10:27:46
1楼: TForm2.create(form1);
----------------------------------------------
-
作者:
男 vkow (vkow) ▲▲▲▲▲ -
普通会员
2019/8/16 9:44:03
2楼: 难道这是个无解的题?
----------------------------------------------
-
作者:
男 wang_80919 (Flying Wang) ▲▲▲▲▲ -
普通会员
2019/8/16 9:46:04
3楼: 你先问问微软,他做过吗?
实现是肯定有办法的。
我们懒得做而已。
----------------------------------------------
(C)(P)Flying?Wang
作者:
男 vkow (vkow) ▲▲▲▲▲ -
普通会员
2019/8/16 10:56:38
4楼: 楼上这位2b,我记得曾经给你说过,我的帖子,不欢迎你。
懒得说你。
----------------------------------------------
-
作者:
男 wang_80919 (Flying Wang) ▲▲▲▲▲ -
普通会员
2019/8/16 11:05:40
5楼: 不欢迎就算了呗。
我对此不关心的。
不过,我只写了?顶多?2?行代码,就实现了啊。

可能是?效果不是楼主想要的吧。
无所谓了。
此帖子包含附件:wang_80919_2019816112652.zip 大小:948.9K
----------------------------------------------
(C)(P)Flying?Wang
作者:
男 abcjingtong (jingtong) ▲▲▲▲▲ -
注册会员
2019/8/16 11:12:26
6楼: form2.parent?:=?form1
----------------------------------------------
18114532@qq.com
作者:
男 dawnhawk (dawnhawk) ★☆☆☆☆ -
盒子活跃会员
2019/8/16 15:36:58
7楼: Form2?:=?TForm.Create(nil);
Form2.PopupParent?:=?Form1;
Form2.PopupMode?:=?pmExplicit;
----------------------------------------------
-
作者:
男 vkow (vkow) ▲▲▲▲▲ -
普通会员
2019/8/18 7:40:56
8楼: @dawnhawk?
太好了。以前一直没注意过这个属性。真的好使。

另外,其他人说的也算没错。如果建个应用,简单建两个Form,不调整属性的话,直接创建,也会窗口前置的效果。至于哪个属性影响了前后关系,我也没仔细尝试,不好说。还好,问题解决了。大赞。
----------------------------------------------
-
作者:
男 bcc2cc (bcc2cc) ▲▲△△△ -
注册会员
2019/8/21 18:12:01
9楼: @vkow?
完全认同你的观点
----------------------------------------------
-
作者:
男 dawnhawk (dawnhawk) ★☆☆☆☆ -
盒子活跃会员
2019/8/27 21:23:42
10楼: https://blog.therealoracleatdelphi.com/2004/02/popupmode-and-popupparent_10.html
需要爬墙

PopupMode?and?PopupParent

In?VCL.NET?(and?for?those?of?you?paying?attention,?also?in?the?version?of?Win32-VCL?used?in?the?IDE?integration?pack?for?Delphi?8)?there?is?a?new?property?on?TCustomForm?called?PopupMode.?This?controls?how?the?top-level?form?behaves?with?respect?to?Window's?WS_POPUP?style.?A?window?that?has?the?WS_POPUP?style?will?always?be?above?it's?"owner"?in?Z-order.?This?is?much?like?fsStayOnTop?except?it?allows?better?control?over?the?layering.?Forms?are?now?automatically?set?to?pmAuto?when?ShowModal?is?called.?One?side?effect?of?this?this?is?that?it?will?cause?the?window?handle?to?be?recreated,?which?at?times?can?cause?problems.?If?you?explicitly?set?the?PopupMode?property?to?pmAuto?prior?to?ShowModal,?like?at?design-time,?then?the?recreate?isn't?nessesary.

Also,?you?probably?want?to?set?the?PopupMode?to?pmExplicit?for?non-modal?design?windows?such?as?tool-palettes?and?other?floating?tool?windows,?which?will?cause?the?windows?to?always?remain?on?top?of?the?main?form.?In?the?case?of?a?snapped?together?IDE?(ie.?the?editor?is?docked?to?the?main?form),?then?the?design?window?will?remain?on?top?of?the?designer.?If?the?IDE?is?in?legacy?undocked?mode,?the?design?window?will?still?remain?above?the?main?form,?but?will?now?behave?very?close?to?before?as?it?will?allow?other?top-level?forms?to?obscure?the?design-window?(just?like?pre-Delphi?8).

There?is?another?new?property?called?PopupParent,?that?if?set?to?an?explicit?TCustomForm,?you?can?force?the?Z-Ordering?of?your?forms?and?create?a?"stacked"?appearance?which?the?user?cannot?change.?If?PopupMode?is?pmExplicit?and?PopupParent?is?nil,?then?the?Application.MainForm?is?implicitly?used?as?the?PopupParent.?If?there?is?no?Application.MainForm?assigned?(like?this?is?the?first?form?created),?then?the?PopupParent?is?Application.Handle,?just?like?in?previous?versions?of?VCL.?Finally,?as?long?as?the?PopupMode?is?pmNone,?then?the?behaviour?is?identical?to?pre-Delphi?8,?except?for?the?ShowModal?item?mentioned?above.?For?PopupMode?of?pmAuto,?Screen.ActiveForm?is?used?as?the?PopupParent.

Finally,?the?reason?for?adding?these?properties?is?that?it?fixes?an?long-running?bug?in?VCL?that?would?allow?a?modal?dialog?show?up?behind?another?form?on?the?screen?giving?the?appearance?of?a?hung?application.?The?Delphi?IDE?would?do?this?as?well?from?time-to-time.?With?the?introduction?of?Windows2000?and?WindowsXP,?Microsoft?added?a?new?feature?called?"window?ghosting."?If?a?top-level?window?hasn't?processed?a?message?within?5?seconds,?Windows?will?"ghost"?the?form?and?allow?you?to?drag,?resize,?and?change?the?Z-order?of?the?form,?even?though?the?application?isn't?processing?any?messages.?The?fact?that?it?allows?a?Z-order?change?is?what?caused?all?the?trouble.?However,?if?the?form?had?the?WS_POPUP?style?and?the?"owner"?was?the?correct?window,?even?a?"ghosted"?form?would?not?be?allowed?to?switch?Z-order?to?under?it's?owner,?thus?there?is?no?chance?for?a?modal?dialog?to?suddenly?disappear.
文字文字
----------------------------------------------
-
信息
登陆以后才能回复
Copyright ? 2CCC.Com 盒子论坛 v2.1 版权所有 页面执行19.53125毫秒 RSS