Solved

Combo Box in Modeless dialog: Run-time error

Posted on 2004-09-07
4
235 Views
Last Modified: 2013-11-20
hi all,

    I used Combo Box(m_VCDsearchChoose) in Modeless dialog (class DlgVCDSearch)

    While running DlgSearch.m_VCDsearchChoose.AddString("Area"); and int sel = DlgSearch.m_VCDsearchChoose.GetCurSel(); gives Run-time error.


void CMovieCollectorView::OnSearchVcd()
{
      // TODO: Add your command handler code here
                . . .
      DlgVCDSearch DlgSearch;
      DlgSearch.m_VCDsearchChoose.AddString("Area");
      if(DlgSearch.DoModal() == IDOK)
      {
            int sel = DlgSearch.m_VCDsearchChoose.GetCurSel();
                                . . .            
      }
}

   Please let me know how to overcome this problem

   with warm regards
   -Mahesh
0
Comment
Question by:smpoojary
  • 2
4 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 125 total points
Comment Utility
This is a MODAL dialog, not a modeless.

At the time you use
int sel = DlgSearch.m_VCDsearchChoose.GetCurSel();
the dialog window (and its children) is destroyed hence you get the error.

You need to use the OnOK of the dialog to set a public member var of the dialog to that value and access that var.

eg.
In DlgVCDSearch::OnOK
m_iSel = m_VCDsearchChoose.GetCurSel();

and in your other code
void CMovieCollectorView::OnSearchVcd()
{
     // TODO: Add your command handler code here
                . . .
     DlgVCDSearch DlgSearch;
     DlgSearch.m_VCDsearchChoose.AddString("Area");
     if(DlgSearch.DoModal() == IDOK)
     {
          int sel = DlgSearch.m_iSel;
                                . . .          
     }
}
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
This line will not work also:

DlgSearch.m_VCDsearchChoose.AddString("Area");

This should be done in OnInitDialog.
0
 
LVL 4

Author Comment

by:smpoojary
Comment Utility
hi,

    Thanks for AndyAinscow and AlexFM.

    I don't know to whom I have to give points. Both are telling correct. Now I will select AndyAinscow for quick response. Again thanks for AndyAinscow and AlexFM.

    With warm regards.
   -Mahesh
0
 
LVL 4

Author Comment

by:smpoojary
Comment Utility
hi Andy Ainscow,
 
     I can't put following my question on experts-exchange. Becuase, I have only 5 points. It asks 20 points per question as "Question difficulty must be at least 20 points.".
 
     my question is:
sub: How to display only one form at a time among multiple forms in SDI CFormView
desc:
     I have created SDI with CFormView. I have also created 3 different forms (form classes). I want to display at a time only one form among 3 different forms in this SDI view. Means, that diaplaying form should be override SDI current form.
    Otherwise please guide me other way about to do this.
     Please help me in this regards.
     With warm regards
     -Mahesh
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now