When initializing a main window win32, when is the best time to show a modal dialog?
I'm t开发者_StackOverflowrying 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) HandleWM_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?
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.
加载中,请稍侯......
精彩评论