如果控件不是动态创建的,在资源模板里ctrl+d就能解决,如果是动态创建的方法有2。
1:SetwindowPos,比如有2个CEdit,m_editAcc和m_editPass
::SetWindowPos(m_editAcc.GetSafeHwnd(),HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE );
::SetWindowPos(m_editPass.GetSafeHwnd(),m_editAcc.GetSafeHwnd(),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE );
2:SetFocus,具体点代码如下
BOOL CLogDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg-> message == WM_KEYDOWN)
{
if( pMsg-> wParam == VK_TAB)
{
CWnd* pWndNext = GetNextDlgTabItem(GetFocus());
if (pWndNext)
{
pWndNext-> SetFocus();
}
return TRUE;
}
else
{
return CDialog::PreTranslateMessage(pMsg);
}
}
else
{
return CDialog::PreTranslateMessage(pMsg);
}
}
else
{
return CDialog::PreTranslateMessage(pMsg);
}
}