Question : How to sendmessage to parent pretranslatemessage?

I created a edit box with the follow code:

HWND hEdit = CreateWindowEx(
                        0,
                        L"EDIT",
                        L"",
                        WS_VISIBLE | WS_CHILD | WS_TABSTOP,
                        GLOBAL_bgX+535,
                        GLOBAL_bgY+702,
                        35,
                        17,
                        AfxGetApp()->GetMainWnd()->m_hWnd,
                        (HMENU)ID_EDITT,
                        (HINSTANCE)GetWindowLong(AfxGetApp()->GetMainWnd()->m_hWnd,GWL_HINSTANCE),
                        NULL);
      
                  OldEdit = (WNDPROC) SetWindowLong(hEdit,GWL_WNDPROC,(LPARAM)EditProc);

And below are the proc code:

LRESULT CALLBACK EditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
            
      if(message == WM_KEYDOWN && wParam == VK_RETURN){            
                MessageBox(L"aaa",L"sdfdsf",MB_OK);
            SendMessage(hWnd,WM_COMMAND,MAKELONG(ID_EDITT,VK_RETURN),(LPARAM)hWnd);                  
      }

      return CallWindowProc(OldEdit,hWnd,message,wParam,lParam);
}

And i have :

BOOL CMFCBookReaderDlg::PreTranslateMessage(MSG* pMsg)
{

case WM_COMMAND:
            {                  
                  TCHAR textBoxValue[50];
                  char textBoxInt[50];
                  GetDlgItemText(ID_EDITT, textBoxValue,50);

                  MessageBox(L" bbb",L"sdfdsf",MB_OK);
                  
                  if (LOWORD(pMsg->wParam)==ID_EDITT && HIWORD(pMsg->wParam) == VK_RETURN)
                  {
                                      MessageBox(L"ccc",L"sdfdsf",MB_OK);
                  }
                  return 0;
            }
}

===================

I got the message show aaa, but not for bbb and ccc, meaning the msg does not send to the pretranslatemessage. Can anyone tell me what is wrong in this code? I know some people would said why not using CEdit. Because i was translate the application from win32api code to MFC.

Thanks in advance

Answer : How to sendmessage to parent pretranslatemessage?

try to use SetFocus(NULL) to cancel current focus
Random Solutions  
 
programming4us programming4us