Поделиться через


CFindReplaceDialog::Create

Creates and displays either a Find or Find/Replace dialog box object, depending on the value of bFindDialogOnly.

virtual BOOL Create(
   BOOL bFindDialogOnly,
   LPCTSTR lpszFindWhat,
   LPCTSTR lpszReplaceWith = NULL,
   DWORD dwFlags = FR_DOWN,
   CWnd* pParentWnd = NULL 
);

Parameters

  • bFindDialogOnly
    Set this parameter to TRUE to display a Find dialog box. Set it to FALSE to display a Find/Replace dialog box.

  • lpszFindWhat
    Pointer to the default search string when the dialog box appears. If NULL, the dialog box does not contain a default search string.

  • lpszReplaceWith
    Pointer to the default replacement string when the dialog box appears. If NULL, the dialog box does not contain a default replacement string.

  • dwFlags
    One or more flags you can use to customize the settings of the dialog box, combined using the bitwise OR operator. The default value is FR_DOWN, which specifies that the search is to proceed in a downward direction. See the FINDREPLACE structure in the Windows SDK for more information on these flags.

  • pParentWnd
    A pointer to the dialog box's parent or owner window. This is the window that will receive the special message indicating that a find/replace action is requested. If NULL, the main window of the application is used.

Return Value

Nonzero if the dialog box object was successfully created; otherwise 0.

Remarks

In order for the parent window to be notified of find/replace requests, you must use the Windows RegisterWindowMessage function whose return value is a message number unique to the application's instance. Your frame window should have a message map entry that declares the callback function (OnFindReplace in the example that follows) that handles this registered message. The following code fragment is an example of how to do this for a frame window class named CMyRichEditView:

// Message handler declared in CMyRichEditView class declaration
protected:
   afx_msg LONG OnFindReplace(WPARAM wParam, LPARAM lParam);
// Register FindReplace window message.
static UINT WM_FINDREPLACE = ::RegisterWindowMessage(FINDMSGSTRING);
// Message map entry to map from message to handler function.
ON_REGISTERED_MESSAGE(WM_FINDREPLACE, &CMyRichEditView::OnFindReplace)

Within your OnFindReplace function, you interpret the intentions of the user by using the CFindReplaceDialog::FindNext and CFindReplaceDialog::IsTerminating methods and you create the code for the find/replace operations.

Example

See the example for CFindReplaceDialog::CFindReplaceDialog.

Requirements

Header: afxdlgs.h

See Also

Reference

CFindReplaceDialog Class

Hierarchy Chart

CFindReplaceDialog::CFindReplaceDialog

Other Resources

CFindReplaceDialog Members