The FINDMSGSTRING Registered Message
Before creating a Find or Replace dialog box, you must call the RegisterWindowMessage function to get a message identifier for the FINDMSGSTRING registered message. You can then use the identifier to detect and process messages sent from the dialog box. When the user clicks the Find Next, Replace, or Replace All button in a dialog box, the dialog box procedure sends a FINDMSGSTRING message to the window procedure of the owner window. When you create the dialog box, the hwndOwner member of the FINDREPLACE structure identifies the owner window.
The lParam parameter of a FINDMSGSTRING message is a pointer to the FINDREPLACE structure that you specified when you created the dialog box. Before sending the message, the dialog box sets the members of this structure with the latest user input, including the string to search for, the replacement string (if any), and options for the find-and-replace operation.
In a FINDMSGSTRING message, the Flags member of the FINDREPLACE structure includes one of the following flags to indicate the event that caused the message.
Flag | Meaning |
FR_DIALOGTERM | The dialog box is closing. After the owner window processes this message, the handle of the dialog box is no longer valid. |
FR_FINDNEXT | The user clicked the Find Next button in a Find or Replace dialog box. The lpstrFindWhat member specifies the string to search for. |
FR_REPLACE | The user clicked the Replace button in a Replace dialog box. The lpstrFindWhat member specifies the string to replace and the lpstrReplaceWith member specifies the replacement string. |
FR_REPLACEALL | The user clicked the Replace All button in a Replace dialog box. The lpstrFindWhat member specifies the string to replace and the lpstrReplaceWith member specifies the replacement string. |
For a Find Next or Replace All message, the Flags member can include any combination of the following flags to indicate the search options.
Flag | Meaning |
FR_DOWN | If set, the Down button of the direction radio buttons is selected, indicating that user wants to search from the current location to the end of the document. If FR_DOWN is not set, the Up button is selected so the user wants to search to the beginning of the document. |
FR_MATCHCASE | If set, the Match Case check box is checked, indicating that the user wants the search to be case sensitive. If FR_MATCHCASE is not set, the check box is unchecked so the search should be case insensitive. |
FR_WHOLEWORD | If set, the Match Whole Word Only check box is checked, indicating that the user wants to search only for whole words that match the search string. If FR_WHOLEWORD is not set, the check box is unchecked so you should also search for word fragments that match the search string. |