Click to See Complete Forum and Search --> : CCombbox Control IDs


April 3rd, 1999, 02:11 AM
I am writing an app where i want to process the enter key diffently depending on which controls in my CFormView have the focus. What I have so far is an override of PretranslateMessage for the view that catches the enter key, which has a "switch" statement with control ids listed as "case" statements. For example,

CMyView::PretranslateMessage()
{
int nCtrlID = 0;
.
.
case VK_RETURN:
nCtrlID = GetFocus()->GetDlgCtrlID();
switch(nCtrlID)
{
case IDC_COMBO_CARRIER:
case IDC_EDIT_AGENT:
case IDC_EDIT_LINE:
OnProcessCtr();
break;
case IDC_COMBO_LENGTH:
case IDC_EDIT_CTR:
case IDC_EDIT_LINE:
OnProcessCar();
.
.
}
The problem is that the comboboxes do not return there respective control IDs.
I have tried all kinds of #@#$ to figure out what is going to no avail. Any
ideas on how to get control ids for comboboxes or another way to do what I
am trying to do.

Thanx.
JP

April 3rd, 1999, 01:51 PM
Can you at least get the correct window pointer to the combo box?

What if you did something like this:

CMyView::PretranslateMessage()
{
int nCtrlID = 0;
CWnd* pWnd;
.
.
case VK_RETURN:

pWnd = GetFocus();

if (pWnd == GetDlgItem(IDC_COMBO_CARRIER))
{
OnProcessCtr();
}
else
{
nCtrlID = GetFocus()->GetDlgCtrlID();
switch(nCtrlID)
{
case IDC_EDIT_AGENT:
case IDC_EDIT_LINE:
OnProcessCtr();
break;
case IDC_COMBO_LENGTH:
case IDC_EDIT_CTR:
case IDC_EDIT_LINE:
OnProcessCar();
.
.
}
}