Things you already know: How do I wait until my dialog box is displayed before doing something?

Raymond Chen

One customer wanted to wait until the dialog box was displayed before displaying its own dialog box. (Personally, I think immediately displaying a doubly-nested dialog box counts as starting off on the wrong foot from a usability standpoint, but let’s set that issue aside for now.) The customer discovered that displaying the nested dialog box in response to the WM_INITDIALOG message was premature, because as we all know, the WM_INITDIALOG is sent before the dialog box is displayed. The question therefore is, “How do I want until my dialog box is displayed before doing something?”

One proposed solution was the following code fragment:

case WM_INITDIALOG:
    PostMessage(hDlg, WM_APP, 0, 0);
    return TRUE;
case WM_APP:
    ... display the second dialog ...
    break;
  1. Why is this wrong? Hint: You definitely know the answer to this already.

  2. What is the correct solution? You probably know this already.

0 comments

Discussion is closed.

Feedback usabilla icon