> My program always creates a modal dialog A when it startup.
Thats one common easy way to make apps... once that consist of a dialog box.
> If user clicks a button of A, it will create the second modal dialog B.
Cool.. hope you have a good reason for not extending A with B functionality.
> In common situation, user can't select any button on title bar of dialog A
> ,such as Minimize button, when dialog B hasn't been closed.
Yes, that's the way modal dialogs work -- they disable their parent window
which in your case is A.
> In fact, when dialog B is suspended, such as executing Sleep function,
> user
Dialogs are never suspended. They can be disabled or out of focus.
But the Thread can Sleep but shouldn't because it should return ASAP so the
dialog boxes message loop can continue.
> can select buttons on title bar of dialog A ,just waiting 3~4 seconds.
> In this way, my program can't catch any WM_SYSCOMMAND messages from dialog
> A.
> Is it normal ?
Definately
> How to do to prevent user from selecting buttons on title bar when dialog
> B
> is suspended ?
Don't get you now. It doesn't respond if you sleep unnecessarily in the
dlgproc.
If you need to sleep (or preferably wait for something to happen with
WaitForSingleObject etc) then you should do that either in a separate
(worker) thread or you should use a timer (SetTimer, WM_TIMER).
- Sten
Best Regards,
Felix
Presumably, you specify DialogA's hwnd as the parent window for dialog B when creating it?
> In common situation, user can't select any button on title bar of dialog A
> ,such as Minimize button, when dialog B hasn't been closed.
> In fact, when dialog B is suspended, such as executing Sleep function, user
> can select buttons on title bar of dialog A ,just waiting 3~4 seconds.
This implies that Dialog A was not disabled when dialog B was created. Or that something is enabling it again. Normally, creating a modal dialog disables its parent.