EditBox & Enter
-
Hello, could it be possible to get a notification message when user presses Enter with the Editbox selected. If user hits Enter, it should get the editbox's text and write it into a Textbox.. All suggestions are welcome, Thank You..
CWnd* pWnd = GetFocus(); if(pWnd->GetDlgCtrlID() != IDOK) { if (pWnd->GetDlgCtrlID() == IDC_MYEDITBOX) //do something; } CDialog::OnOK();
-
CWnd* pWnd = GetFocus(); if(pWnd->GetDlgCtrlID() != IDOK) { if (pWnd->GetDlgCtrlID() == IDC_MYEDITBOX) //do something; } CDialog::OnOK();
-
Thank You.. Seems that i posted it into a wrong discussion board.. :( Win32 API without MFC would be a bit more helpful for me as i'm using DevC++ and i don't know what equals to CDialog::OnOK(); All suggestions are welcome, Thank You..
here is Shay Harel code converted. case IDOK: HWND hWndChild = GetFocus(); if( hWndChild != GetDlgItem(hWnd, IDOK) ) { if( hWndChild == GetDlgItem(hWnd, IDC_MYEDITBOX) ) // do something; }
-
here is Shay Harel code converted. case IDOK: HWND hWndChild = GetFocus(); if( hWndChild != GetDlgItem(hWnd, IDOK) ) { if( hWndChild == GetDlgItem(hWnd, IDC_MYEDITBOX) ) // do something; }
and with message WM_COMMAND and switch (LOWORD(wParam)) ? Why could if( hWndChild != GetDlgItem(hWnd, IDOK) ) be needed if the second one checks for a window in focus? With this switch i get a notification even if user clicks on the editbox. Is it possible to check HIWORD(wParam) for a mouseclick when the control is an editbox? Do i have to use ES_MULTILINE | ES_WANTRETURN flags when creating the editbox in order to make the control even receive a notification about Enter? Unfortunately i see no changes after adding these flags..
WinInf.EditBox = CreateWindow ("edit", "", WS_CHILD | WS_VISIBLE | ES_LEFT | ES_NOHIDESEL | ES_MULTILINE | ES_WANTRETURN, WinInf.ClientRect.left + 2, WinInf.ClientRect.bottom - 20, WinInf.ClientRect.right - 4, 20, hwnd, (HMENU) 1, WinInf.hInst, NULL);
All suggestions are welcome, Thank You.. -
and with message WM_COMMAND and switch (LOWORD(wParam)) ? Why could if( hWndChild != GetDlgItem(hWnd, IDOK) ) be needed if the second one checks for a window in focus? With this switch i get a notification even if user clicks on the editbox. Is it possible to check HIWORD(wParam) for a mouseclick when the control is an editbox? Do i have to use ES_MULTILINE | ES_WANTRETURN flags when creating the editbox in order to make the control even receive a notification about Enter? Unfortunately i see no changes after adding these flags..
WinInf.EditBox = CreateWindow ("edit", "", WS_CHILD | WS_VISIBLE | ES_LEFT | ES_NOHIDESEL | ES_MULTILINE | ES_WANTRETURN, WinInf.ClientRect.left + 2, WinInf.ClientRect.bottom - 20, WinInf.ClientRect.right - 4, 20, hwnd, (HMENU) 1, WinInf.hInst, NULL);
All suggestions are welcome, Thank You..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;