'EM_FINDTEXTEX always returns 0
i have this small code. the problem is, result is always 0, no matter what searchword i use.
static void findtext(HWND hwnd, const char *SearchWord)
{
FINDTEXTEX ft;
char text[256];
ft.chrg.cpMin = 0;
ft.chrg.cpMax = GetWindowTextLength(hwnd);
ft.lpstrText = (LPCSTR)SearchWord;
int result = SendMessage(hwnd, EM_FINDTEXTEX, (WPARAM)FR_DOWN, (LPARAM)&ft);
GetWindowText(hwnd, text, 256);
log_message("result [%d]", result);
log_message("ft.chrg.cpMin [%d]", ft.chrg.cpMin);
log_message("ft.chrg.cpMax [%d]", ft.chrg.cpMax);
log_message("ft.lpstrText [%s]", ft.lpstrText);
log_message("text [%s]\n", text);
}
as you see i did some logging, and all seems to be fine. log output:
result[0]
ft.chrg.cpMin [0]
ft.chrg.cpMax [26]
ft.lpstrText [basic]
text [hello this is a basic test]
why is result 0? i would expect either a proper value or -1? ft.lpstrText can be complete nonsense still i get result 0.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
