Win32 API Reference

FINDTEXTW Structure

The FINDTEXTW structure contains information used by the FindText function to search for text within a dialog box.

Structure Definition:


typedef struct tagFINDTEXTW {
  RECT    *lprc;
  LPWSTR  lpstrText;
  LPWSTR  lpstrSel;
  int     chars;
  DWORD   flags;
} FINDTEXTW, *LPFINDTEXTW;
            

Members

Syntax Example


// Example of how to initialize a FINDTEXTW structure
FINDTEXTW findInfo;
RECT searchRect = {10, 10, 200, 100}; // Define search area
WCHAR searchString[] = L"example text";
WCHAR selectionBuffer[100];

findInfo.lprc = &searchRect;
findInfo.lpstrText = searchString;
findInfo.lpstrSel = selectionBuffer;
findInfo.chars = 100;
findInfo.flags = FR_DOWN | FR_WHOLEWORD;

// Assuming hDialog is a handle to your dialog box
HWND hDialog = GetActiveWindow(); // Or obtain your dialog handle

LRESULT result = SendMessage(hDialog, WM_FINDTEXT, 0, (LPARAM)&findInfo);

if (result != -1) {
    // Text found or selection updated
    if (findInfo.lpstrSel[0] != L'\0') {
        // Selected text is in findInfo.lpstrSel
    }
} else {
    // Error or text not found
}
            

See Also

Remarks

The FindText function sends the WM_FINDTEXT message to a dialog box. The dialog box procedure should process this message by searching for the text specified in the lpstrText member of the FINDTEXTW structure. If the text is found, the dialog box procedure should select the text and return the starting character index of the found text. If the text is not found, it should return -1.

The FR_DOWN flag is crucial for implementing search functionality that can iterate through multiple occurrences of the search term.