locked
MFC: How to change focus to different dialog boxes? RRS feed

  • Question

  • Hi All,

    I am a novice to MFC, My problem is something like this.

    I have a dialog box. On certain action to this dialog box,i am opening 3 different modal dialog boxes of same class. Now, if try to access my parent dialog, i cant since first i have to close the modal dialog. But as soon as i am closing any one of the child dialogs, my parent window is accessible.

    I want to retain the modal behavior until i close all three child dialogs. i.e. even if i close one of them, my parent window should still not response until other two are closed.

    Friday, December 3, 2010 4:28 PM

Answers

  • Not that I am aware of, the window is either modal or not, if there are multiple of them it is, by definition, not modal.  I understand it may be a 'requirement' but if the person giving you such requirements doesn't understand reality then they are going to be disappointed.  You MAY be able to disable your parent window explicitly and then re-enable it when the last dialog closes, but such a route is fraught with peril and if you don't do it correctly you will hose the parent window.

    Are you doing this inside VS?  I would STRONGLY suggest against manually disabling the parent window (presumably the VS mainw window).

    Ryan

    • Marked as answer by Victor_Chen Friday, December 10, 2010 9:17 AM
    Friday, December 3, 2010 6:13 PM

All replies

  • Are you showing three modal dialog boxes at one time?  That doesn't make a lot of sense, the idea of a modal dialog is that it is the ONLY window enabled in the entire app, having three such windows means they aren't technically modal.

    Ryan

    Friday, December 3, 2010 5:38 PM
  • You are absolutely correct, but this is the requirement and i cant change it. :(

    is there any way, i can block access to the parent window untill all child window are closed?

    Friday, December 3, 2010 5:58 PM
  • Not that I am aware of, the window is either modal or not, if there are multiple of them it is, by definition, not modal.  I understand it may be a 'requirement' but if the person giving you such requirements doesn't understand reality then they are going to be disappointed.  You MAY be able to disable your parent window explicitly and then re-enable it when the last dialog closes, but such a route is fraught with peril and if you don't do it correctly you will hose the parent window.

    Are you doing this inside VS?  I would STRONGLY suggest against manually disabling the parent window (presumably the VS mainw window).

    Ryan

    • Marked as answer by Victor_Chen Friday, December 10, 2010 9:17 AM
    Friday, December 3, 2010 6:13 PM