• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

About ComboBox

Hello, I'm newbie at VC++ and have a litttle problem.
I need to read a file (text file) in order to initialize some dialog boxes. I have no problem with Edit boxes, but Combo Boxes are another thing.
This is part of my code:

FichProyecto.ReadString(linea);
campo=linea.SpanExcluding(":");
tam=linea.GetLength()-campo.GetLength()-2;

if (campo=="paridad")
{
      CComboBox* combo;
      combo=(CComboBox*)m_pCanalSerieDlg->GetDlgItem(IDC_COMBO_PARIDAD);
       combo->SelectString(-1, linea.Right(tam));
}

m_pCanalSerieDlg is a pointer to the dialog box that contains the combo box.

There is no compilation problems, but execution problems.
What am I doing wrong??
Thx.
0
amkhara
Asked:
amkhara
  • 4
  • 3
1 Solution
 
wildyCommented:
What type of problems do you have?
0
 
amkharaAuthor Commented:
"A debug assertion failed."

It seems to be at

CWnd* CWnd::GetDlgItem(int nID) const
{
      ASSERT(::IsWindow(m_hWnd));

      if (m_pCtrlCont == NULL)
                               // here is the problem
            return CWnd::FromHandle(::GetDlgItem(m_hWnd, nID));
      else
            return m_pCtrlCont->GetDlgItem(nID);
}

And the program crashes.

0
 
Shay050799Commented:
where is this function take place ?
OnInitDialog ?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
amkharaAuthor Commented:
No... in OnOpenFile I call a function "LeerFich" to read the file. The code I posted belongs to this function "LeerFich".
0
 
wildyCommented:
If the dialog is not created when you call GetDlgItem, it crashes...
0
 
amkharaAuthor Commented:
OK. Then I'll have to keep the value and then, when I create the dialog, use it, isn't it??

Thx
0
 
wildyCommented:
You are right.
0
 
amkharaAuthor Commented:
OK... Thx a lot
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now