写了两个函数都没能成功 按下enter键后没什么反应 好像没能截获到enter键被按下的消息 两个函数的代码如下 大家看看是哪错了?
void xscj::OnOK()
{
CWnd* pwndCtrl = GetFocus();
// get the control ID which is
// presently having the focus
int ctrl_ID = pwndCtrl->GetDlgCtrlID();
CString str;
switch (ctrl_ID)
{ //if the control is the EditBox
CWnd* pwndCtrl = GetFocus();
// get the control ID which is
// presently having the focus
int ctrl_ID = pwndCtrl->GetDlgCtrlID();
CString str;
switch (ctrl_ID)
{ //if the control is the EditBox
case IDC_EDIT6:
//get the text from the EditBox
GetDlgItemText(IDC_EDIT6,str);
//set the value in the listContorl with the
//specified Item & SubItem values
m_list.SetItemText (nItem,nSubItem,str);
::SendDlgItemMessage(m_hWnd,IDC_EDIT6,
WM_KILLFOCUS,0,0);
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT6),SW_HIDE);
break;
default:
break;
}
}
}
另一个函数
BOOL xscj::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
/*if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
{
if(pMsg-> wParam==VK_RETURN)
{
CString str;
GetDlgItemText(IDC_EDIT6,str);
m_list.SetItemText (nItem,nSubItem,str);
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT6),SW_HIDE);
}
}*/
if ( pMsg -> message == WM_KEYDOWN )
{
if ( ( pMsg -> wParam & 0xff ) == VK_RETURN )
{
if ( GetFocus() -> GetDlgCtrlID() == m_Edit.GetDlgCtrlID () )
{
CString str;
GetDlgItemText(IDC_EDIT6,str);
m_list.SetItemText (nItem,nSubItem,str);
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT6),SW_HIDE);
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void xscj::OnOK()
{
CWnd* pwndCtrl = GetFocus();
// get the control ID which is
// presently having the focus
int ctrl_ID = pwndCtrl->GetDlgCtrlID();
CString str;
switch (ctrl_ID)
{ //if the control is the EditBox
CWnd* pwndCtrl = GetFocus();
// get the control ID which is
// presently having the focus
int ctrl_ID = pwndCtrl->GetDlgCtrlID();
CString str;
switch (ctrl_ID)
{ //if the control is the EditBox
case IDC_EDIT6:
//get the text from the EditBox
GetDlgItemText(IDC_EDIT6,str);
//set the value in the listContorl with the
//specified Item & SubItem values
m_list.SetItemText (nItem,nSubItem,str);
::SendDlgItemMessage(m_hWnd,IDC_EDIT6,
WM_KILLFOCUS,0,0);
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT6),SW_HIDE);
break;
default:
break;
}
}
}
另一个函数
BOOL xscj::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
/*if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
{
if(pMsg-> wParam==VK_RETURN)
{
CString str;
GetDlgItemText(IDC_EDIT6,str);
m_list.SetItemText (nItem,nSubItem,str);
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT6),SW_HIDE);
}
}*/
if ( pMsg -> message == WM_KEYDOWN )
{
if ( ( pMsg -> wParam & 0xff ) == VK_RETURN )
{
if ( GetFocus() -> GetDlgCtrlID() == m_Edit.GetDlgCtrlID () )
{
CString str;
GetDlgItemText(IDC_EDIT6,str);
m_list.SetItemText (nItem,nSubItem,str);
::ShowWindow(::GetDlgItem(m_hWnd,IDC_EDIT6),SW_HIDE);
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
解决方案 »
- OpenCV为什么只保存视频的前景帧后得到的是无效的文件?附代码
- ????求助:vc++2010 使用CMSComm出现“该组件上的 GetValue 操作失败,生成错误代码 0x80020003。”
- 为什么请求一个网址返回了压缩内容?
- 有一段代码用来获取计算器的进程句柄,看看哪儿出错了?
- 求教socket编程类的资料
- 如何 让windows知道 *.abc 文件 由 ABC.exe 打开?
- 郁闷,工作这么难找啊,散分!!
- 怎么样实现调用帮助系统阿?
- 这是不是CArray的BUG??????????????
- 我想CEDITVIEW每落下一个汉字都能取到这个汉字的内容;每落下一行汉字都能取到这行汉字的内容;每落下一段汉字都能取到这段汉字的内容;每落下一页........
- 想删除编辑框中光标所在行的内容
- unused = CXX0030: 错误: 无法计算表达式的值
按下enter建,可以通过响应失去焦点消息