title: Change CDialog controls focus from another dialog
body: <p>I am trying to change the focus of a CDialog controls from a CFormView by using PostMessage:</p>
  
  <p>[CHelpView is inherited from CFormView. 
  And m_wndDlg is a CSampleDlg(inherited from CDialog) object]</p>
  
  <pre><code>void CHelpView::OnEnterbutton() 
  {
      pSplitterFrame-&gt;m_dlgPane-&gt;m_wndDlg-&gt;PostMessage(WM_KEYDOWN, 'r', 2); 
  }
  
  BOOL CSampleDlg::PreTranslateMessage(MSG* pMsg) 
  {
      if (pMsg-&gt;message &gt;= WM_KEYFIRST &amp;&amp; // for performance
          pMsg-&gt;message &lt;= WM_KEYLAST)
      { 
           if (pMsg-&gt;wParam=='r' &amp;&amp; pMsg-&gt;lParam==2){
              NextDlgCtrl();
              return TRUE; 
           }
      }
  }
  </code></pre>
  
  <p>The dialog receives the message but the NextDlgCtrl method doesn't change the focus. I realized that if I change the PreTranslateMessage method so that if the Return key is pressed, within the dialog, this NextDlgCtrl method properly changes the focus each time the user hit the return key(from the dialog). Yet this I couldn't achieve through another dialog.</p>
  
  <p>Does anyone possibly know the reason behind it or any hints or workaround ?</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here's (part of)the log file for the dialog from SPY++. </p>
  
  <p>&lt;01128> 0016013E R WM_GETDLGCODE fuDlgCode:0000</p>
  
  <p>&lt;01129> 0016013E P WM_KEYDOWN nVirtKey:00726574 cRepeat:2 ScanCode:00 fExtended:0 fAltDown:0 fRepeat:0 fUp:0</p>
  
  <p>&lt;01130> 0016013E S WM_NEXTDLGCTL wCtlFocus:(null) (next control receives focus) fHandle:False</p>
  
  <p>&lt;01131> 0016013E R WM_NEXTDLGCTL</p>
  
  <p>&lt;01132> 0016013E S WM_GETDLGCODE </p>