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?