2

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?

l33t
  • 18,692
  • 16
  • 103
  • 180

1 Answers1

0

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.

Mario S
  • 11,715
  • 24
  • 39
  • 47
MinYun
  • 1
  • 1