Solved

Combo Box in Modeless dialog: Run-time error

Posted on 2004-09-07
4
237 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 135
maven archtype selection in eclipse 1 57
has77  challenge 9 82
tripleUp challenge 7 78
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

9 Experts available now in Live!

Get 1:1 Help Now