CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 1999
    Posts
    74

    I need to tab to next CEdit using the <ENTER> key instead of the <TAB> key . . .

    appreciate any s****. Thanks. JD


  2. #2
    Guest

    Re: I need to tab to next CEdit using the <ENTER> key instead of the <TAB> key . . .

    Try trapping the OnChar call. if the enter key is set handle as you need.
    Else just pass on to the parent class. THis does require a derived class.

    void CMabEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
    {
    if(nChar==13)
    {
    OnKillfocus();
    return;
    }
    CEdit::OnChar(nChar, nRepCnt, nFlags);
    }



  3. #3
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: I need to tab to next CEdit using the <ENTER> key instead of the <TAB> key . . .

    See Example 5 on my web site at http://home.earthlink.net/~railro/mfc_link.html

    Rail

    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    [email protected]
    http://home.earthlink.net/~railro/

  4. #4
    Join Date
    May 1999
    Location
    Piacenza, ITALIA
    Posts
    30

    Re: I need to tab to next CEdit using the <ENTER> key instead of the <TAB> key . . .

    OK, try this (its a little bit "dirty" but fast, easy and works anytime)

    - Put a button on your dialog.
    - make it the default button (now it catches the enter key)
    - hide this button
    - create the OnButton...() method via class wizard
    - enter a code like this (i think "OnKillFocus()" as mentioned in another post should not be called directly):

    --------

    void CKostenEditDlg::OnButtonReturn()
    {
    CWnd* pCurrentItem = GetFocus();
    // if (pCurrentItem == &m_ctrlUmlage)
    // OnDblclkUmlage();
    // else {
    CWnd* pNextItem = GetNextDlgTabItem( pCurrentItem );
    pNextItem-&gt;SetFocus();
    if ( pNextItem-&gt;IsKindOf( RUNTIME_CLASS( CEdit )) )
    ((CEdit*)pNextItem)-&gt;SetSel(0, -1);
    // }
    }

    --------

    you don't need the code I have commented, that part I used to catch the enter key on a CListCtrl (m_ctrlUmlage) and call the onDoubleClck()-method for that control ....





  5. #5
    Join Date
    Apr 1999
    Posts
    74

    Great, Marco . . thanks!

    eom


  6. #6
    Join Date
    Apr 1999
    Posts
    74

    Rail, your page is terrific! Now how do I capture the ENTER key for a CComboBox . . .

    I derived MyComboBox & thought I captured the WM_CHAR, . . . but apparently not since the function is never called. Should I just use a list box with my own CEdit . . would that be the easiest way? Sure appreciate your help! JD


  7. #7
    Join Date
    Apr 1999
    Posts
    74

    Thanks, anon!

    eom


  8. #8
    Join Date
    Apr 1999
    Posts
    74

    To Rail only . .

    Tried to email you . . undeliverable (?), anyway,

    Rail, could you please point me to what I need to read or tools available to
    learn to create a web page & others would be able to download programs from
    the site. (like yours) Thanks very much for any suggestions you might be
    able to provide. My email is [email protected]
    Thanks, John




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured