Hello José,
Me again... Sorry.
In the cw_edit_autoselect.bas there is no autoselect, maybe the code is faulty :
CASE EN_SETFOCUS
SELECT CASE CBCTL(wParam, lParam)
' Note: To deselect, use EM_SETSEL, -1, 0
CASE IDC_EDIT1
Edit_SetSel(GetDlgItem(hWnd, IDC_EDIT1), 0, -1)
CASE IDC_EDIT2
Edit_SetSel(GetDlgItem(hWnd, IDC_EDIT2), 0, -1)
END SELECT
I change the code with :
case idc_edit2
if cbctlmsg(wparam,lparam)=en_setfocus then
Edit_SetSel(GetDlgItem(hWnd, IDC_EDIT2), 0, -1)
end if
case idc_edit1
if cbctlmsg(wparam,lparam)=en_setfocus then
'sendmessage(GetDlgItem(hWnd, IDC_EDIT1),em_setsel,0,-1)
Edit_SetSel(GetDlgItem(hWnd, IDC_EDIT1), 0, -1)
end if
Seems to work with edit2, but not with edit1.
Maybe its not possible with single line edit...
Maybe iam wrong.
Yes, the code must be:
' // Sent when the user selects a command item from a menu, when a control sends a
' // notification message to its parent window, or when an accelerator keystroke is translated.
CASE WM_COMMAND
SELECT CASE CBCTL(wParam, lParam)
CASE IDCANCEL
' // If ESC key pressed, close the application by sending an WM_CLOSE message
IF CBCTLMSG(wParam, lParam) = BN_CLICKED THEN SendMessageW(hwnd, WM_CLOSE, 0, 0)
CASE IDC_EDIT1
IF CBCTLMSG(wParam, lParam) = EN_SETFOCUS THEN
' Note: To deselect, use EM_SETSEL, -1, 0
Edit_SetSel(GetDlgItem(hWnd, IDC_EDIT1), 0, -1)
END IF
CASE IDC_EDIT2
IF CBCTLMSG(wParam, lParam) = EN_SETFOCUS THEN
Edit_SetSel(GetDlgItem(hWnd, IDC_EDIT2), 0, -1)
END IF
END SELECT
RETURN 0
New template: https://github.com/JoseRoca/AfxNova/blob/main/SDK%20Templates/CW_Edit_Autoselect.bas
Thanks for reporting it and sorry for the inconvenience.