MLM_QUERYSEL
This message returns the location of the selection.
Syntax
param1 USHORT usQueryMode; /* Query Mode. */ param2 ULONG ulReserved; /* Reserved value, should be 0. */
Parameters
- usQueryMode (USHORT) - input
- Query Mode.
- MLFQS_MINMAXSEL: Return both minimum and maximum points of selection in a
- format compatible with the EM_QUERYSEL message.
- MLFQS_MINSEL: Return minimum insertion point of selection.
- MLFQS_MAXSEL: Return maximum insertion point of selection.
- MLFQS_ANCHORSEL: Return anchor point of selection.
- MLFQS_CURSORSEL: Return cursor point of selection.
- MLFQS_MINMAXSEL: Return both minimum and maximum points of selection in a
- ulReserved (ULONG) - input
- Reserved value, should be 0.
Returns
- sMinSel (SHORT) - return
- Minimum insertion point of selection.
- This value is rounded down to 65 535, if necessary.
- ReturnCode contains sMinSel and sMaxSel for a usQueryMode of MLFQS_MINMAXSEL.
- This value is rounded down to 65 535, if necessary.
- sMaxSel (SHORT) - return
- Maximum insertion point of selection.
- This value is rounded down to 65 535 if necessary.
- ReturnCode contains sMinSel and sMaxSel for a usQueryMode of MLFQS_MINMAXSEL.
- This value is rounded down to 65 535 if necessary.
- ipt (IPT) - return
- Requested insertion point.
- ReturnCode contains ipt for a usQueryMode of MLFQS_MINSEL, MLFQS_MAXSEL,
- MLFQS_ANCHORSEL, or MLFQS_CURSORSEL.
- ReturnCode contains ipt for a usQueryMode of MLFQS_MINSEL, MLFQS_MAXSEL,
Remarks
This message returns the location of the selection in several different forms. The insertion points lie between characters, and start at a zero origin before the first character in the MLE. Subtracting the minimum from the maximum gives the number of characters in the selection. This is not necessarily the number of bytes of ASCII. The line-break character is a CR LF (2 bytes) and all DBCS characters are 2 bytes. To determine the number of bytes, use MLM_QUERYFORMATTEXTLENGTH, being sure that the format choice set by MLM_FORMAT is set to what is used when the data is exported from the MLE (for example, MLE_CFTEXT for MLM_QUERYSELTEXT).
Note the following:
- If anchor point > cursor point, minimum point = cursor point and maximum
point = anchor point.
- If anchor point < cursor point, minimum point = anchor point and maximum
point = cursor point.
Default Processing
The default window procedure takes no action on this message, other than to set ReturnCode to 0.
Examples
This example sends two MLM_QUERYSEL messages to obtain the beginning and ending points of the current selection, sends an MLM_SETIMPORTEXPORT message to set up the export buffer, and then sends an MLM_EXPORT message to export the selection into the buffer.
LONG lStart, cch; CHAR szBuf[500]; lStart = (LONG) WinSendMsg(hwndMle, MLM_QUERYSEL, (MPARAM) MLFQS_MINSEL, (MPARAM) 0L); cch = lStart - (LONG) WinSendMsg(hwndMle, MLM_QUERYSEL, (MPARAM) MLFQS_MAXSEL, (MPARAM) 0L); WinSendMsg(hwndMle, MLM_SETIMPORTEXPORT, (MPARAM) szBuf, (MPARAM) sizeof(szBuf)); WinSendMsg(hwndMle, MLM_EXPORT, (MPARAM) &lStart, (MPARAM) &cch);