HWND FindText(lpfr) | |||||
LPFINDREPLACE lpfr; | /* pointer to structure with initialization data | */ |
The FindText function creates a system-defined modeless dialog box that makes it possible for the user to find text within a document. The application must perform the search operation.
lpfr
Points to a FINDREPLACE structure that contains information used to initialize the dialog box. When the user makes a selection in the dialog box, the system fills this structure with information about the user's selection and then sends a message to the application. This message contains a pointer to the FINDREPLACE structure.
The FINDREPLACE structure has the following form:
#include <commdlg.h>
typedef struct tagFINDREPLACE { /* fr */
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
DWORD Flags;
LPSTR lpstrFindWhat;
LPSTR lpstrReplaceWith;
UINT wFindWhatLen;
UINT wReplaceWithLen;
LPARAM lCustData;
UINT (CALLBACK* lpfnHook)(HWND, UINT, WPARAM, LPARAM);
LPCSTR lpTemplateName;
} FINDREPLACE;
The return value is the window handle of the dialog box if the function is successful. Otherwise, it is NULL. An application can use this window handle to communicate with or to close the dialog box.
Use the CommDlgExtendedError function to retrieve the error value, which may be one of the following values:
CDERR_FINDRESFAILURE
CDERR_INITIALIZATION
CDERR_LOCKRESFAILURE
CDERR_LOADRESFAILURE
CDERR_LOADSTRFAILURE
CDERR_MEMALLOCFAILURE
CDERR_MEMLOCKFAILURE
CDERR_NOHINSTANCE
CDERR_NOHOOK
CDERR_NOTEMPLATE
CDERR_STRUCTSIZE
FRERR_BUFFERLENGTHZERO
The dialog box procedure for the Find dialog box passes user requests to the application through special messages. The lParam parameter of each of these messages contains a pointer to a FINDREPLACE structure. The procedure sends the messages to the window identified by the hwndOwner member of the FINDREPLACE structure. An application can register the identifier for these messages by specifying the “commdlg_FindReplace” string in a call to the RegisterWindowMessage function.
For the TAB key to function correctly, any application that calls the FindText function must also call the IsDialogMessage function in its main message loop. (The IsDialogMessage function returns a value that indicates whether messages are intended for the Find dialog box.)
If the hook function (to which the lpfnHook member of the FINDREPLACE structure points) processes the WM_CTLCOLOR message, this function must return a handle of the brush that should be used to paint the control background.