共用方式為


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 the standard Windows Find dialog box. Set it to FALSE to display the Windows Find/Replace dialog box.

  • lpszFindWhat
    Specifies the string for which to search.

  • lpszReplaceWith
    Specifies the default string with which to replace found strings.

  • 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 application's main window 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 and create the code for the find/replace operations.

Example

See the example for CFindReplaceDialog::CFindReplaceDialog.

Requirements

Header: afxdlgs.h

See Also

Concepts

CFindReplaceDialog Class

CFindReplaceDialog Members

Hierarchy Chart

CFindReplaceDialog::CFindReplaceDialog