?
Solved

MFC combobox and listbox Control, Program shuts off when ENTER KEY is pressed

Posted on 2003-03-26
6
Medium Priority
?
1,374 Views
Last Modified: 2013-11-20
hello again,
1. how can I remove an item into a list box and combo box, assigning an index and getting the value of the selected item?

m_list1a.AddString("item1");
m_list1a.AddString("item2");
m_list1a.AddString("item3");

item1
item2
item3

supposedly if I selected item2 i want to display the index in editbox1, the value text in editbox2 and remove it Simultaneously?

2. In MFC why is that when I pressed the ENTER KEY
  (when the focused on the dialog box)
  the Entire Program Always SHUTS OFF how can I deal with that?
0
Comment
Question by:perci
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:perci
ID: 8216048
help guys
0
 

Accepted Solution

by:
FrenchFries earned 80 total points
ID: 8217493
1-  you need to get the index of item with LBN_SELCHANGE message for example (or double-click on the list box ):

int nIndex=m_listbox.GetCurSel();
int nCount = m_listbox.GetCount();
if ((nIndex != LB_ERR) && (nCount > 0))
{
if((MessageBox("Delete ?","Message",MB_YESNO)==MB_YES)
{
m_listbox.DeleteString(nIndex);
m_listboxResetContent();
....// init a again the listbox
}
}
The GetCurSel() method gives you the actual index.

2 Pressing on <ENTER KEY> is a basic mechanism provided with MFC that causes the dialog window closing.

Override OnOK ( ClassWizard if VC6 ) and you can let an empty method:

CMyDlg::OnOK()
{
// nutshell
}

It also worth for OnCancel()
0
 
LVL 1

Expert Comment

by:Mazen
ID: 8219076
Hi,
   To solve the enter key problem, you can also uncheck the "default button" check box in the OK and Cancel buttons' properties.
   Mazen
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 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