Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A problem about modal dialog

3 views
Skip to first unread message

Felix

unread,
Oct 7, 2008, 4:12:01 AM10/7/08
to
Hi
I met a weird question about modal dialog.
My program always creates a modal dialog A when it startup.
If user clicks a button of A, it will create the second modal dialog B.
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.
In this way, my program can't catch any WM_SYSCOMMAND messages from dialog A.
Is it normal ?
How to do to prevent user from selecting buttons on title bar when dialog B
is suspended ?
Thanks a lot.

Sten Westerback (MVP SDK 2005-6 :)

unread,
Oct 10, 2008, 2:37:17 PM10/10/08
to

"Felix" <Fe...@discussions.microsoft.com> wrote in message
news:B0F9C2A4-29E9-4930...@microsoft.com...

> Hi
> I met a weird question about modal dialog.
Really.. what did the question look like, which language did it speak and
what did it drink. Did it dance too? ;)

> 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


Felix

unread,
Oct 13, 2008, 7:21:01 AM10/13/08
to
Thanks for your reply, Sten.
I still have confusion about this instance.
My application needs to send commands to a device and waits its response,
and it usually spends 30~60 seconds to process these commands.
At this moment, user can select buttons on title bar of parent window
without closing its child window.
And in this way, I can't catch any WM_SYSCOMMAND messages from system.
After application got device's response, buttons on title bar of parent
window were disabled again.
Could you explain this issue in clarity?
Thanks a lot.

Best Regards,
Felix

Chris Becke

unread,
Oct 13, 2008, 8:16:04 AM10/13/08
to
"Felix" <Fe...@discussions.microsoft.com> wrote in message news:B0F9C2A4-29E9-4930...@microsoft.com...
> Hi
> I met a weird question about modal dialog.
> My program always creates a modal dialog A when it startup.
> If user clicks a button of A, it will create the second modal dialog B.

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.

0 new messages