MSDN

MSDN Documentation

FINDTEXT Structure

The FINDTEXT structure contains the parameters that enable an application to search for a string of text within a Rich Edit control.

Syntax

typedef struct _findtext {
    CHARRANGE cp;        // Range to search
    LPSTR    lpstrText; // Pointer to the search string (ANSI)
} FINDTEXT, *LPFINDTEXT;

Members

MemberTypeDescription
cp CHARRANGE The character range to be searched. The start and end positions are specified in character indices.
lpstrText LPSTR Pointer to a null‑terminated ANSI string that contains the text to locate.

Remarks

Example

#include <windows.h>
#include <richedit.h>

void FindString(HWND hEdit, LPCSTR szFind) {
    FINDTEXT ft;
    ft.lpstrText = (LPSTR)szFind;
    ft.cp.cpMin = 0;
    ft.cp.cpMax = -1; // Search whole text

    LONG index = SendMessage(hEdit, EM_FINDTEXT, 0, (LPARAM)&ft);
    if (index != -1) {
        // Highlight the found text
        CHARRANGE cr = { index, index + lstrlen(szFind) };
        SendMessage(hEdit, EM_EXSETSEL, 0, (LPARAM)&cr);
    }
}

See Also