troubleshooting Question

How to sendmessage to parent pretranslatemessage?

Avatar of iphone
iphone asked on
System Programming
5 Comments1 Solution1912 ViewsLast Modified:
I created a edit box with the follow code:

HWND hEdit = CreateWindowEx(
                        WS_VISIBLE | WS_CHILD | WS_TABSTOP,
                  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){            

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

And i have :

BOOL CMFCBookReaderDlg::PreTranslateMessage(MSG* pMsg)

                  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)
                  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
Jaime Olivares
Software Architect
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros