/* 光标移到开头 */ SetFocus(hwndEdit); Edit_SetSel(hwndEdit, 0, 0);
/* 取消选中, 光标将出现在选中文字末尾 */ SetFocus(hwndEdit); Edit_SetSel(hwndEdit, -1, 0);
/* 全部选中 */ SetFocus(hwndEdit); Edit_SetSel(hwndEdit, 0, -1);
/* 光标移到末尾 */ SetFocus(hwndEdit); Edit_SetSel(hwndEdit, 0, -1); // 先全部选中 Edit_SetSel(hwndEdit, -1, 0); // 再取消选中, 光标自动移到最后
/* 显示当前选中区域 */ SendMessage(hwndEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd); _stprintf_s(szText, TEXT("Selection: (%u, %u)"), dwStart, dwEnd); MessageBox(hwndEdit, szText, TEXT("Current Selection"), MB_ICONINFORMATION); SetFocus(hwndEdit);
|