tabing through cedit controls
-
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?
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?
-
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?
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?
-
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?