Delphi 窗体在显示时总是会触发 OnResize 吗?

发布于 2024-07-30 03:23:36 字数 490 浏览 2 评论 0原文

如果我创建一个新的 Delphi 表单,挂钩其 OnResize 事件并运行该应用程序,则在显示窗口之前会触发 OnResize。 我不知道对于任何窗口来说,这种情况是否总是会发生。

(对于熟悉 Windows API 的人来说,我已将其追溯到 TCustomForm.ShowingChanged 中的 ShowWindow 调用(Delphi 2007 中的 Forms.pas 第 5503 行),这显然会触发 WM_SIZE... 至少,对于没有设置其他属性的新窗口,我还没有看到 ShowWindow 总是触发 WM_SIZE 的记录,所以我不知道我是否可以依靠这一点。)

所以: < strong>我可以依赖 TForm 在首次显示时总是触发 OnResize 吗?或者是否存在某些情况(也许如果窗口不可调整大小,也许如果 Position 属性具有某些值,等)在窗口首次显示之前,OnResize 可能不会触发?

If I create a new Delphi form, hook its OnResize event, and run the app, OnResize is fired before the window is shown. What I don't know is whether this will always happen, for any window.

(For anyone familiar with the Windows API, I've traced it to the ShowWindow call in TCustomForm.ShowingChanged (Forms.pas line 5503 in Delphi 2007), which apparently triggers a WM_SIZE... at least, for a new window with no other properties set. I haven't seen it documented that ShowWindow always fires WM_SIZE, so I don't know whether I can count on this or not.)

So: Can I rely on a TForm always firing OnResize when it's first shown? Or are there circumstances (maybe if the window is non-resizable, maybe if the Position property has certain values, etc.) where OnResize might not fire before the window is first shown?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉溺在你眼里的海 2024-08-06 03:23:37

不,该事件并不总是在表单显示时触发,具体取决于 BorderStyle 等内容。 例如,它在 bsSingle 启动时触发,但 bsDialog 则不会。

很容易测试。 只需向主窗体的 OnResize 事件添加一些日志记录代码,更改 BorderStyle 并运行您的应用程序即可。

No, this event doesn't always fire when the form shows, depending on things like BorderStyle. For example, it fires on startup for bsSingle, but not for bsDialog.

It's easy to test. Just add some logging code to the main form's OnResize event, change the BorderStyle and run your app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文