Jump to content

MLM_SEARCH

From EDM2
Revision as of 03:16, 28 April 2025 by Martini (talk | contribs) (Remarks)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This message searches for a specified text string.

Syntax

param1
ULONG ulStyle; /* Style flags. */

param2
PMLE_SEARCHDATA pse; /* Search specification structure. */

Parameters

ulStyle (ULONG) - input
Style flags.
MLFSEARCH_CASESENSITIVE: If set, only exact matches are considered a
successful match. If not set, any case-combination of the correct characters in the
correct sequence is considered a successful match.
MLFSEARCH_SELECTMATCH: If set, the MLE selects the text and scrolls it into
view when found, just as if the application had sent an MLM_SETSEL message. This
is not done if MLFSEARCH_CHANGEALL is also indicated.
MLFSEARCH_CHANGEALL: Using the MLE_SEARCHDATA structure specified in pse, all
occurrences of pchFind are found, searching from iptStart to iptStop, and replacing them
with pchReplace. If this style is selected, the cchFound field has no meaning,
and the iptStart value points to the place where the search stopped, or is the same
as iptStop because the search has not been stopped at any of the found strings.
The current cursor location is not moved. However, any existing selection
is deselected.
pse (PMLE_SEARCHDATA) - input
Search specification structure.

Returns

rc (BOOL) - return
Success indicator.
TRUE: The search was successful.
FALSE: The search was unsuccessful.

Remarks

This message searches the MLE text for a specified string, starting at a specified insertion point and continuing until the second specified insertion point has been reached, or the requested string has been matched.

When an MLM_SEARCH message is sent, the text is scanned starting with the character that follows the insertion point indicated in the iptStart field of the MLE_SEARCHDATA structure. The search proceeds until the point indicated in the iptStop field, until a match is found, or until TRUE is returned from MLN_SEARCHPAUSE notification (see WM_CONTROL (in Multiline Entry Fields)). If a negative value is specified for the iptStart, the current cursor point is used. If a negative value is specified for iptStop, the end of the text is used. If iptStop is less than or equal to iptStart, after performing the two indicated substitutions, the search wraps from the end of the text to the beginning of the text.

If the MLFSEARCH_CASESENSITIVE option is specified, the bytes of the search string must exactly match those in the text. If MLFSEARCH_CASESENSITIVE is not specified, the WinUpperChar of the search string must match the WinUpperChar of the text.

When a match is found, the iptStart field of the search specification structure is set to indicate the insertion point immediately preceding the first character of the match, and the cchFind field is set to indicate the number of characters in the match. The cursor selection is not altered unless MLFSEARCH_SELECTMATCH is specified. If it is, an MLM_SETSEL is done with the anchor point at iptStart and the cursor at iptStart + cchFind.

While searching, the MLE occasionally sends an MLN_SEARCHPAUSE notification message. If the owner responds to this message with the value TRUE, the MLE stops the search. When a search is stopped from MLN_SEARCHPAUSE, iptStart is set to the point where the search terminated. If the response is FALSE, the search continues (see also the definition of MLN_SEARCHPAUSE). The interval at which MLN_ SEARCHPAUSE notifications are sent is implementation-dependent, but must not exceed reasonable user-response thresholds, nor should it be so often as to introduce undue messaging overhead. Sending this notification every half second is a reasonable compromise.

When no match is found, the iptStart value is unchanged.

If the application needs to continue the search, the proper way is to change the iptStart value to be the point following the string found, adjusting for any text changes done after the search that may have moved the relative location of the point.

Applications using this message are advised to change the system pointer to the wait icon (clock face) if it is expected that the search will take some time.

Default Processing

The default window procedure takes no action on this message, other than to set rc to FALSE.

Examples

This example searches for all occurrences of the word "Bonnie" and replaces them with the word "Jeannette".

MLE_SEARCHDATA search;
search.cb = sizeof(search);
search.pchFind = "bonnie";
search.pchReplace = "jeannette";
search.cchFind = 6;
search.cchReplace = 9;
search.iptStart = 0;   /* from the beginning of the text */
search.iptStop = -1;   /* to the end of the text          */
WinSendMsg(hwndMle, MLM_SEARCH, MLFSEARCH_CHANGEALL, (MPARAM) &search);