title: How to make the Tab key input the Tab character to focused edit control instead of navigating among dialog controls?
body: <p>The present posting is continuation of post <a href="https://stackoverflow.com/questions/18443702/how-to-disallow-tab-key-to-switch-focus-between-edit-control-and-button-within-d">How to disallow tab key to switch focus between edit control and button within dialog box?</a> because I Just thought I needed a separate posting for this.</p>
  
  <p>I followed the comments on that post to make the Tab key input the Tab character inside its edit control:</p>
  
  <p>I created <code>EditCode</code> class derived from <code>CEdit</code> and I overrode method:</p>
  
  <pre><code> afx_msg UINT OnGetDlgCode()
   {
       UINT uiCode = CEdit::OnGetDlgCode();
       uiCode |= DLGC_WANTTAB;
       return uiCode;
   }
  </code></pre>
  
  <p>And I added the respective handler entry in the class' message map:</p>
  
  <pre><code>BEGIN_MESSAGE_MAP(EditCode, CEdit)
      ON_WM_GETDLGCODE()
  END_MESSAGE_MAP()
  </code></pre>
  
  <p>I also added a variable of type <code>EditCode</code> to the dialog class, but I could not still manage to fix it.</p>
  
  <p>I tried to override <code>WindowProc</code> as follows</p>
  
  <pre><code>LRESULT CEditCode:: WindowProc(
     UINT message,
     WPARAM wParam,
     LPARAM lParam 
  )
  {
      // TODO: Add your specialized code here and/or call the base class
      LRESULT lres;
      switch (message) {
      case WM_GETDLGCODE:
          lres = CEdit::WindowProc(message, wParam, lParam);
          lres |= DLGC_WANTTAB;
          return lres;
      }
      return CEdit::WindowProc(message, wParam, lParam);
  }
  </code></pre>
  
  <p>But until now, I had no success.</p>
  
  <p><strong>EDIT:</strong>
  I am now able to make the Tab key input the Tab character by returning </p>
  
  <pre><code>  (DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_WANTTAB | DLGC_WANTALLKEYS). 
  </code></pre>
  
  <p>I wanted the Shift+Tab key combination to still work for navigation, hence I wrote:</p>
  
  <pre><code>if(GetKeyState(VK_SHIFT) &lt; 0 )
  {
     return CEdit::WindowProc(message, wParam, lParam);
  }
  </code></pre>
  
  <p>It is working fine, but whenever  press Shift+Tab for navigation and come back to edit box, then the Tab key is not working as input; instead it as navigates among controls. I am confused.</p>