I have a class derived from CAknDialog. The dialog opens and works perfect,
but there is a situation when it's behaviour is weird: when this dialog is
shown and I switch to another application (by using the menu key) and after
going back to my application, the CAknDialog is gone (not shown on the
screen). What is wrong?

After some debugging, I see that after application got the focus again (the
dialog is not shown), but application is still in OkToExitL() method, so one
can see menu from main application (not menu from the dialog) and can't do
anything except exiting the app.
I've tried also with DrawNow() method added to FocusChanged(TDrawNow
/*aDrawNow*/) method of dialog implementation, but the dialog still isn't
shown after re-activation.

Any ideas?