Solved

Combo Box in Modeless dialog: Run-time error

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 96
repeatSeparator  java  challenge 13 58
has22 challenge 11 105
wordappend challenge 8 200
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

838 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