Solved

Combo Box in Modeless dialog: Run-time error

Posted on 2004-09-07
4
236 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
ID: 12003808
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
ID: 12003933
This line will not work also:

DlgSearch.m_VCDsearchChoose.AddString("Area");

This should be done in OnInitDialog.
0
 
LVL 4

Author Comment

by:smpoojary
ID: 12013033
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
ID: 12187456
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

22 Experts available now in Live!

Get 1:1 Help Now