初始化主窗口 win32 时,什么时候是显示模式对话框的最佳时间?

发布于 2024-09-05 22:55:14 字数 680 浏览 1 评论 0原文

我试图在 Win32 中实现这一点,但我确信同样的规则也适用于 WinForms 的世界。

问:我创建了主窗口,然后,当它显示时,我想显示一个模式对话框。问题是;我如何知道主窗口何时完全初始化并可见?也就是说,到底什么时候是显示对话框的最佳时间?

想法:
1) 处理WM_CREATE并作为最后一步PostMessage(WM_USER_MESSAGE)。处理 WM_USER_MESSAGE 并显示模式对话框!
2) 处理WM_CREATE并将计时器设置为~300 ms。处理WM_TIMER,终止计时器并显示模式对话框!
3) 如果第一次激活PostMessage(WM_USER_MESSAGE),则处理WM_ACTIVATE。处理 WM_USER_MESSAGE 并显示模式对话框!
4) 处理WM_SHOWWINDOW,如果是第一次显示则显示模态对话框!

上述方法虽然有效,但结果并不总是那么好。有更好的方法吗?也许以某种方式处理 WM_ENTERIDLEWM_KICKIDLE 消息?

I'm trying to accomplish this in Win32, but I'm sure the same rules apply in the world of WinForms.

Q: I create my main window, and then, when it is being shown, I want to show a modal dialog. The problem is; how can I know when the main window is completely initialized and visible? That is, exactly when is the best time to show the dialog?

Ideas:
1) Handle WM_CREATE and as a final step PostMessage(WM_USER_MESSAGE). Handle WM_USER_MESSAGE and show modal dialog!

2) Handle WM_CREATE and set a timer at ~300 ms. Handle WM_TIMER, kill timer and show modal dialog!

3) Handle WM_ACTIVATE, if first activation PostMessage(WM_USER_MESSAGE). Handle WM_USER_MESSAGE and show modal dialog!

4) Handle WM_SHOWWINDOW, if first-time show show modal dialog!

The above approaches work, but the result is not always that good. Is there a better method? Perhaps handling WM_ENTERIDLE or WM_KICKIDLE messages in some way?

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

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

发布评论

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

评论(1

ぃ双果 2024-09-12 22:55:14

是的。显示对话框的最佳时间是:

您可以处理 WM_CREATE 并使用函数检查窗口句柄是否有效:

:: GetSafeHwnd( m_hwnd)

此时我们可以显示模式对话框。

Yes. exactly the best time to show the dialog is:

You can handle WM_CREATE and check for window handle is valid by using function:

:: GetSafeHwnd( m_hwnd)

And we can show modal dialog at that time.

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