按RETURN键执行TAB [英] TAB implementation upon RETURN key

查看:98
本文介绍了按RETURN键执行TAB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想在多个文本框上实现TAB效果
即在文本框中输入值,然后按Enter键,焦点应
自动进入下一个文本框(与输入数据一样,然后点击
我不想做的TAB键)...所以请有人可以提出一种解决方法
当前,我正在尝试在PreTranslateMessage()中使用这段代码..

Hello there I would like to implement the TAB effect on multiple textboxes
i.e upon entering the value in a textbox and then hitting the enter key the focus should
automatically get onto the next textbox (as good as entering the data and then hitting the
TAB key which I dont want to do)...So please can some one suggest a way for this
currently I am trying to use this piece of code in PreTranslateMessage()..

if ( (pMsg->wParam == VK_RETURN) )
if( m_CeditCtrlLlaLatDegrees.GetFocus() )
{
  keybd_event( VK_TAB,0x09,0,0);
  // keybd_event( VK_TAB,0x09,KEYEVENTF_KEYUP,0);
}


但是上面的代码只是将焦点推到了我需要的文本框之后.即
它向前移动了2个选项卡...我总共有20个文本框全部取自CEdit和所有
仅接受数值.
我也想知道为每个文本框检索ID的方法
我尝试分配Cedit-控制变量并访问每个
的ID 文本框..然后通过一个简单的if-else代码的switch-case语句,我会
然后检查哪个文本框处于活动状态,然后将SetFocus()移至下一个直接文本框
---所有这些都在PreTranslateMessage();中.
但是,即使这样也无法正常工作.所以请有人提出一种使该功能正常工作的方法.
由于我是新手,请让我详细了解流程/代码..


but the above code just pushes the focus onto the textbox following the one i need for.that is
it moves 2 tabs ahead... i have a total of 20 textboxes all taken from CEdit and all
accept only numeric values.
Also I would like to know the way to retrieve the ID for each of these textboxes
I tried assigning Cedit - control variable and accessing the ID for each of the
textbox ..then through a switch-case statement of a simple if-else code i would
then check which textbox is active and then SetFocus() to the next immediate one
--- all of this in PreTranslateMessage();.
But even this wont work ..So please can someone suggest a way to get this thing to work.
Please let me know the flow/code in detail since I am a newbie ..
Thanks for the help in advance.

推荐答案

第一件事,请阅读 CDialog :: NextDlgCtrl [ ^ ]方法帮你.不要像您正在做的那样呼叫keybd_event,这太可怕了.
 
First thing, read this[^]. In MFC the CDialog class contains the CDialog::NextDlgCtrl[^] method which might help you. Don''t call keybd_event like you''re doing, it''s horrible.
 


您好,首先感谢您提供的所有帮助.您的上述想法也没有起作用.甚至PostMessage(WM_NEXTDLGCTL,0,0);将焦点移到下一个之后的文本框上,因此也失败了..虽然TAB效果已完成,但更糟糕的是验证,我必须使用鼠标单击消息框,而通常不使用Enter键,否则单击消息框用于验证(例如纬度的范围为0-53),因为焦点再次位于下一个控件上,所以请继续弹出!!

谢谢,问候
hello first of all thanks for all the help..the above idea of yours didnt work either..even PostMessage( WM_NEXTDLGCTL ,0,0 ); shifts the focus to the textbox one after the next so this fails too ..though the TAB effect is done but whats worse is the validation for which i have to click on the message box with mouse and not normally the enter key else the message box for validation (like the range 0-53 for latitude )keep popping up since the focus is on the next control again here the next messagebox!!.

Thanks and regards


您好,这是一小段代码,可确保将选项卡设置为下一个文本框,并且可以循环方式进行操作
如果(pMsg->消息== WM_KEYDOWN&&(pMsg-> wParam == VK_RETURN))
{
pMsg-> wParam = VK_TAB;
}


希望这有助于所有对VC6编码有类似想法的人.再次感谢大家
Hello there heres the small piece of code which ensures that the tab is set to the very next textbox and this works about in round robin fashion
if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_RETURN))
{
pMsg->wParam = VK_TAB;
}


hope this helps to all having similar thought about coding in VC6..thanks to all again


这篇关于按RETURN键执行TAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆