I did need to do it, this what I found.
Derive a MyDialog from class CAknDialog
Call ConstructL( menueresourceId) for instance in MyDialog::PostLayoutDynInitL().
In MyDialog::OkToExitL() you call DisplayMenuL() for your EAknSoftkeyOptions command.
You can do whatever you want in MyDialog::DynInitMenuPaneL() to dynamically hide lines depending on what happened in the dialog.