You are making this much harder than it needs to be. This is a very easy thing to code. The following code does exactly what you need. All you have to do is copy it into your code and it will work. You don't need to mess around with the create options. The reason it works is because the IDOK button will be a default button, and will be called when the return is pressed. case WM_COMMAND: { switch(LOWORD(wParam)) { case IDOK: { HWND hWndChild = GetFocus(); if( hWndChild != GetDlgItem(hDlg, IDOK) ) { if( hWndChild == GetDlgItem(hDlg, IDC_EDIT1) ) { char szText[128]; GetWindowText(hWndChild, szText, sizeof(szText)); SetWindowText(GetDlgItem(hDlg, IDCS_TEXT), szText); return TRUE; } } EndDialog(hDlg, LOWORD(wParam)); } return TRUE;