Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. tabing through cedit controls

tabing through cedit controls

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jafrazee
    wrote on last edited by
    #1

    is there a way to set the enter key to work like a tab key when moving through different cedit controls? or would i have to create a keypress event for each control?

    R 1 Reply Last reply
    0
    • J jafrazee

      is there a way to set the enter key to work like a tab key when moving through different cedit controls? or would i have to create a keypress event for each control?

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      Yes there is. Override your PreTranslateMessage function as follows:

      BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
      {
      if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
      {
      CWnd *pWnd = GetFocus() ;

      	if (pWnd != NULL)
      		{
      		CEdit \*pEdit = static\_cast(pWnd) ; // returns NULL if its not a CEdit\* control
      		if (pEdit)
      			{
      			// convert the VK\_RETURN to a VK\_TAB for edit controls
      			pMsg->wParam = VK\_TAB ;
      			}
      		}
      	}
      return CDialog::PreTranslateMessage(pMsg); // or correct base class
      

      }

      This converts all return presses to tabs so that it should tab from control ro control instead. Roger Allen Sonork 100.10016 If I'm not breathing, I'm either dead or holding my breath. A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?

      R 1 Reply Last reply
      0
      • R Roger Allen

        Yes there is. Override your PreTranslateMessage function as follows:

        BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
        {
        if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
        {
        CWnd *pWnd = GetFocus() ;

        	if (pWnd != NULL)
        		{
        		CEdit \*pEdit = static\_cast(pWnd) ; // returns NULL if its not a CEdit\* control
        		if (pEdit)
        			{
        			// convert the VK\_RETURN to a VK\_TAB for edit controls
        			pMsg->wParam = VK\_TAB ;
        			}
        		}
        	}
        return CDialog::PreTranslateMessage(pMsg); // or correct base class
        

        }

        This converts all return presses to tabs so that it should tab from control ro control instead. Roger Allen Sonork 100.10016 If I'm not breathing, I'm either dead or holding my breath. A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?

        R Offline
        R Offline
        Roger Allen
        wrote on last edited by
        #3

        That should have read CEdit *pEdit = static_cast(pWnd) ; // returns NULL if its not a CEdit* control but the HTML parser stripped it out Roger Allen Sonork 100.10016 If I'm not breathing, I'm either dead or holding my breath. A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?

        J 1 Reply Last reply
        0
        • R Roger Allen

          That should have read CEdit *pEdit = static_cast(pWnd) ; // returns NULL if its not a CEdit* control but the HTML parser stripped it out Roger Allen Sonork 100.10016 If I'm not breathing, I'm either dead or holding my breath. A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?

          J Offline
          J Offline
          jafrazee
          wrote on last edited by
          #4

          thank you.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups