CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2006
    Posts
    169

    Question modeless child and main dialog communication

    Dear All;

    I have a slight problem which i am sure it will be straight forward for you to solve.

    I have a modeless child box in which the user inputs information. My question is so how do i stop the program from completing the execution until the data which has been entered is returned to the main application.

    Method A{

    invoke modelless box;
    method B;

    }

    How do i stop the program from continuing the execution until the modeless box has been dismissed, only then method B can be executed.

    Many thanx

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: modeless child and main dialog communication

    Usually the communication between two windows is made by using (user-defined) messages.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Feb 2006
    Posts
    169

    Re: modeless child and main dialog communication

    Quote Originally Posted by ovidiucucu
    Usually the communication between two windows is made by using (user-defined) messages.
    I know that and i have done it. My question is how do i stop the execution of the program until the user has entered the data and dismissed the modeless dialog box.

    again:

    Method A{

    invoke modelless box;
    method B;

    }

    how do i stop the execution of method B until the modeless box has been dismissed?

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: modeless child and main dialog communication

    For that purpose were invented the modal dialogs.

    // it's seems you have to review a little your application "design".
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  5. #5
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: modeless child and main dialog communication

    Either use a modal box or add loop where you wait on termination (messy compared to a modal box)

  6. #6
    Join Date
    Feb 2006
    Posts
    169

    Re: modeless child and main dialog communication

    thanx,
    i have tried a modal box

    CModalBox* modalBox;
    modalBox = new ModalBox(this);
    modalBox->DoModal();


    This creates the a modal dialog and freezez the main application which is what i want. But once i dismiss the modal box i get an assertion!!!

    any ideas how to fix this problem?

  7. #7
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: modeless child and main dialog communication

    Are you calling DestroyWindow() in CModalBox code?
    Last edited by S_M_A; June 25th, 2007 at 12:35 AM.

  8. #8
    Join Date
    May 2006
    Location
    India
    Posts
    22

    Re: modeless child and main dialog communication

    Quote Originally Posted by llp00na
    thanx,
    i have tried a modal box
    CModalBox* modalBox;
    modalBox = new ModalBox(this);
    modalBox->DoModal();
    any ideas how to fix this problem?
    Hi friend,
    I would suggest you to do like below:-

    Code:
    CModalBox modalBox;
    modalBox->m_pParent = this; 
    //m_pParent is your own pointer for your parent dialog in your child dialog.
    //add your info to the pointer, simply. I expect you could understand
    modalBox.DoModal();

    Why dont you go for this code. why do you go for new in your code.
    If you want to pass info from your main dialog to child dialog then just take a pointer in your child dialog. like this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured