使 Delphi 应用程序完全全屏的最佳方法是什么?
使 Delphi 应用程序(Delphi 2007 for Win32)完全全屏、删除应用程序边框并覆盖 Windows 任务栏的最佳方法是什么?
我正在寻找类似于 Internet Explorer (IE) 在按 F11 时执行的操作。
我希望这是用户的运行时选项,而不是我自己的设计时决定。
正如已接受的答案中提到的,
BorderStyle := bsNone;
这是做到这一点的一部分。 奇怪的是,在使用该行时,我不断收到 E2010 不兼容类型:'TFormBorderStyle' 和 'TBackGroundSymbol'
错误(另一种类型已定义 bsNone
)。
为了克服这个问题,我必须使用:
BorderStyle := Forms.bsNone;
What is the best way to make a Delphi application (Delphi 2007 for Win32) go completely full screen, removing the application border and covering the Windows Taskbar?
I am looking for something similar to what Internet Explorer (IE) does when you hit F11.
I wish this to be a run time option for the user not a design time decision by my good self.
As mentioned in the accepted answer
BorderStyle := bsNone;
was part of the way to do it. Strangely I kept getting an E2010 Incompatible types: 'TFormBorderStyle' and 'TBackGroundSymbol'
error when using that line (another type had bsNone
defined).
To overcome this I had to use:
BorderStyle := Forms.bsNone;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
嗯,这一直对我有用。 好像简单了一些...
Well, this has always worked for me. Seems a bit simpler...
谷歌搜索发现了以下附加方法:(
尽管我想我会先尝试罗迪的方法)
手动填充屏幕(来自:关于 Delphi)
Roddy 主题的变体
WinAPI 方式(来自 TeamB 的 Peter Below)
A Google search turned up the following, additional methods:
(though I think I'd try Roddy's method first)
Manually fill the screen (from: About Delphi)
Variation on a theme by Roddy
The WinAPI way (by Peter Below from TeamB)
最大化表单并隐藏标题栏。 最大化线是从内存中完成的,但我很确定 WindowState 是您想要的属性。
还有这篇文章,但这对我来说似乎太复杂了。
编辑:这是一个完整的示例,带有“全屏”和“恢复”选项。 为了最大程度地清晰起见,我已将不同的部分分解为小程序,因此可以将其大大压缩为几行。
Maximize the form and hide the title bar. The maximize line is done from memory, but I'm pretty sure WindowState is the property you want.
There's also this article, but that seems too complicated to me.
Edit: Here's a complete example, with "full screen" and "restore" options. I've broken out the different parts into little procedures for maximum clarity, so this could be greatly compressed into just a few lines.
将这样的代码放入表单 onShow 事件中:
并将以下代码放入 OnCanResize 中:
Put to the form onShow event such code:
And to the OnCanResize this:
如何像 MDI 应用程序一样约束 Mainform 中的子表单,但又不会令人头疼! (注意:此页面上的回复帮助我完成了这项工作,所以这就是我在这里发布我的解决方案的原因)
稍后......
还有更多......
How to constrain a sub-form within the Mainform like it was an MDI app., but without the headaches! (Note: The replies on this page helped me get this working, so that's why I posted my solution here)
later...
and yet more...
就我而言,唯一有效的解决方案是:
In my case, the only working solution is:
您需要确保表单位置为 poDefaultPosOnly。
已在 Win7 x64 上测试并运行。
You need to make sure Form position is poDefaultPosOnly.
Tested and works on Win7 x64.
尝试:
这始终与主显示器对齐;
Try:
This always align to the primary monitor;
嗯。 看着这些回复,我似乎记得大约 8 年前我编写游戏代码时处理过这个问题。 为了使调试更容易,我使用普通的 Delphi 表单的设备上下文作为全屏显示的源。
重点是,DirectX 能够全屏运行任何设备上下文 - 包括由您的表单分配的设备上下文。
因此,要为应用程序提供“真正的”全屏功能,请查找 Delphi 的 DirectX 库,它可能包含您开箱即用所需的内容。
Hm. Looking at the responses I seem to remember dealing with this about 8 years ago when I coded a game. To make debugging easier, I used the device-context of a normal, Delphi form as the source for a fullscreen display.
The point being, that DirectX is capable of running any device context fullscreen - including the one allocated by your form.
So to give an app "true" fullscreen capabilities, track down a DirectX library for Delphi and it will probably contain what you need out of the box.
VCL
这里有两个按钮单击事件,用于进入全屏和退出全屏:
FMX
对于那些希望在 FireMonkey (FMX) 中执行相同操作的人来说。 更改
BorderStyle
和WindowState
的 VCL 方法在 FMX 中会起作用,但正确的方法是使用窗体上的FullScreen
属性机动MX:VCL
Here are two button click events to go into FullScreen and to exit FullScreen:
FMX
And for those finding themselves here looking to do the same in FireMonkey (FMX). The VCL method of changing
BorderStyle
andWindowState
will kind of work in FMX, but the correct way is to use theFullScreen
property on the form in FMX: