BOOL Create( BOOL bFindDialogOnly, LPCTSTR lpszFindWhat, LPCTSTR lpszReplaceWith = NULL, DWORD dwFlags = FR_DOWN, CWnd* pParentWnd = NULL );
Return Value
Nonzero if the dialog box object was successfully created; otherwise 0.
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 Win32 SDK documentation 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.
Remarks
Creates and displays either a Find or Find/Replace dialog box object, depending on the value of bFindDialogOnly.
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 CMyFrameWnd
:
class CMyFrameWnd : public CFrameWnd
{
protected:
afx_msg LONG OnFindReplace(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
};
static UINT WM_FINDREPLACE = ::RegisterWindowMessage(FINDMSGSTRING);
BEGIN_MESSAGE_MAP( CMyFrameWnd, CFrameWnd )
//Normal message map entries here.
ON_REGISTERED_MESSAGE( WM_FINDREPLACE, OnFindReplace )
END_MESSAGE_MAP
Within your OnFindReplace function, you interpret the intentions of the user and create the code for the find/replace operations.
CFindReplaceDialog Overview | Class Members | Hierarchy Chart