在向文本框输入的时候,如何在打回车的时候就让焦点转到下一个文本框上???

xrxrxr 2002-01-10 08:24:49
最好有代码,谢谢
...全文
78 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
liaolf 2002-01-11
  • 打赏
  • 举报
回复
在PreTranslateMessage(..)里,截获回车键,看看下面的参考(不过好像有点问题,修改一下,我的方法是截获回车键后,直接把它换成TAB键,后面的都省了,呵呵)
virtual BOOL PreTranslateMessage(MSG *);

BOOL CMyDialog::PreTranslateMessage(MSG *pMsg)
{
if (pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
{
DWORD def_id=GetDefID();
if (def_id!=0)
{
CWnd *wnd=FromHandle(pMsg->hwnd);
// you may implement other ways of testing, e.g.
// comparing to array of CWnd*, comparing to array of IDs etc.
char class_name[16];
if (GetClassName(wnd->GetSafeHwnd(),
class_name,sizeof(class_name))!=0)
{
if (strnicmp(class_name,"Edit",5)==0)
{
GetDlgItem(LOWORD(def_id))->SetFocus();
return TRUE;
// discard the message!
}
}
}
}
// be a good citizen - call the base class
return CDialog::PreTranslateMessage(pMsg);
}
starcbh 2002-01-11
  • 打赏
  • 举报
回复
sendmessage...
Jneu 2002-01-11
  • 打赏
  • 举报
回复
if (e.KeyValue ==13)
this.button1.Focus();
Jneu 2002-01-10
  • 打赏
  • 举报
回复
13
xrxrxr 2002-01-10
  • 打赏
  • 举报
回复
vbKeyReturn不可被识别,用的是C#啊
wenzm 2002-01-10
  • 打赏
  • 举报
回复
在keydown事件中
If (KeyCode = vbKeyReturn)
{ textbox.select();
或则 textbox.focus();
}

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧