FINDREPLACE

3.1

#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 FINDREPLACE structure contains information that the system uses to initialize a system-defined Find dialog box or Replace dialog box. After the user chooses the OK button to close the dialog box, the system returns information about the user's selections in this structure.

Members

lStructSize

Specifies the length of the structure, in bytes. This member is filled on input.

hwndOwner

Identifies the window that owns the dialog box. This member can be any valid window handle, but it must not be NULL.

If the FR_SHOWHELP flag is set, hwndOwner must identify the window that owns the dialog box. The window procedure for this owner window receives a notification message when the user chooses the Help button. (The identifier for the notification message is the value returned by the RegisterWindowMessage function when HELPMSGSTRING is passed as its argument.)

This member is filled on input.

hInstance

Identifies a data block that contains a dialog box template specified by the lpTemplateName member. This member is only used if the Flags member specifies the FR_ENABLETEMPLATE or the FR_ENABLETEMPLATEHANDLE flag; otherwise, this member is ignored. This member is filled on input.

Flags

Specifies the dialog box initialization flags. This member can be a combination of the following values:

Value Meaning

FR_DIALOGTERM Indicates the dialog box is closing. The window handle returned by the FindText or ReplaceText function is no longer valid after this bit is set. This flag is set by the system.
FR_DOWN Sets the direction of searches through a document. If the flag is set, the search direction is down; if the flag is clear, the search direction is up. Initially, this flag specifies the state of the Up and Down buttons; after the user chooses the OK button to close the dialog box, this flag specifies the user's selection.
FR_ENABLEHOOK Enables the hook function specified in the lpfnHook member of this structure. This flag can be set on input.
FR_ENABLETEMPLATE Causes the system to use the dialog box template identified by the hInstance and lpTemplateName members to display the dialog box. This flag is used only to initialize the dialog box.
FR_ENABLETEMPLATEHANDLE Indicates that the hInstance member identifies a data block that contains a pre-loaded dialog box template. The system ignores the lpTemplateName member if this flag is specified. This flag can be set on input.
FR_FINDNEXT Indicates that the application should search for the next occurrence of the string specified by the lpstrFindWhat member. This flag is set by the system.
FR_HIDEMATCHCASE Hides and disables the Match Case check box. This flag can be set on input.
FR_HIDEWHOLEWORD Hides and disables the Match Only Whole Word check box. This flag can be set on input.
FR_HIDEUPDOWN Hides the Up and Down radio buttons that control the direction of searches through a document. This flag can be set on input.
FR_MATCHCASE Specifies that the search is to be case sensitive. This flag is set when the dialog box is created and may be changed by the system in response to user input.
FR_NOMATCHCASE Disables the Match Case check box. This flag is used only to initialize the dialog box.
FR_NOUPDOWN Disables the Up and Down buttons. This flag is used only to initialize the dialog box.
FR_NOWHOLEWORD Disables the Match Whole Word Only check box. This flag is used only to initialize the dialog box.
FR_REPLACE Indicates that the application should replace the current occurrence of the string specified in the lpstrFindWhat member with the string specified in the lpstrReplaceWith member. This flag is set by the system.
FR_REPLACEALL Indicates that the application should replace all occurrences of the string specified in the lpstrFindWhat member with the string specified in the lpstrReplaceWith member. This flag is set by the system.
FR_SHOWHELP Causes the dialog box to show the Help button. If this flag is specified, the hwndOwner must not be NULL. This flag can be set on input.
FR_WHOLEWORD Checks the Match Whole Word Only check box. Only whole words that match the search string will be considered. This flag is set when the dialog box is created and may be changed by the system in response to user input.

lpstrFindWhat

Specifies the string to search for. If a string is specified when the dialog box is created, the dialog box will initialize the Find What edit control with this string. If the FR_FINDNEXT flag is set when the dialog box is created, the application should search for an occurrence of this string (using the FR_DOWN, FR_WHOLEWORD, and FR_MATCHCASE flags to further define the direction and type of search). The application must allocate a buffer for the string. This buffer should be at least 80 bytes long. This flag is set when the dialog box is created and may be changed by the system in response to user input.

lpstrReplaceWith

Specifies the replacement string for replace operations. The FindText function ignores this member. The ReplaceText function uses this string to initialize the Replace With edit control. This flag is set when the dialog box is created and may be changed by the system in response to user input.

wFindWhatLen

Specifies the length, in bytes, of the buffer to which the lpstrFindWhat member points. This member is filled on input.

wReplaceWithLen

Specifies the length, in bytes, of the buffer to which the lpstrReplaceWith member points. This member is filled on input.

lCustData

Specifies application-defined data that the system passes to the hook function identified by the lpfnHook member. The system passes a pointer to the CHOOSECOLOR structure in the lParam parameter of the WM_INITDIALOG message; this pointer can be used to retrieve the lCustData member.

lpfnHook

Points to a hook function that processes messages intended for the dialog box. To enable the hook function, an application must specify the FR_ENABLEHOOK flag in the Flags member; otherwise, the system ignores this structure member. The hook function must return zero to pass a message that it didn't process back to the dialog box procedure in COMMDLG.DLL. The hook function must return a nonzero value to prevent the dialog box procedure in COMMDLG.DLL from processing a message it has already processed.

This member is filled on input.

lpTemplateName

Points to a null-terminated string that specifies the name of the resource file for the dialog box template that is to be substituted for the dialog box template in COMMDLG.DLL. An application can use the MAKEINTRESOURCE macro for numbered dialog box resources. This member is used only if the Flags member specifies the FR_ENABLETEMPLATE flag; otherwise, this member is ignored.

This member is filled on input.

Comments

Some members of this structure are filled only when the dialog box is created, some are filled only when the user closes the dialog box, and some have an initialization value that changes when the user closes the dialog box. Whenever a description in the Members section does not specify how the value of a member is assigned, the value is assigned only when the dialog box is created.

See Also

FindText, ReplaceText