DOCERR: EM_POSFROMCHAR & EM_CHARFROMPOS Documented Incorrectly

Last reviewed: March 3, 1998
Article ID: Q137805

The information in this article applies to:
  • Microsoft Win32 Software Development Kit (SDK) versions 3.51, 4.0
  • Microsoft Win32s version 1.3

SUMMARY

The Win32 SDK documentation for EM_POSFROMCHAR and EM_CHARFROMPOS is not correct when you use it with the RichEdit control version 1.x (Riched32.dll) and version 2.x (Riched20.dll). The two versions of the RichEdit control handle these messages differently than the standard edit control, and even from each other. The following information explains the differences between the control's messages in each version.

MORE INFORMATION

The definitions for EM_POSFROMCHAR and EM_CHARFROMPOS should be documented as follows:

EM_POSFROMCHAR

   //For standard edit control.
   wParam = (WPARAM) wCharIndex; // Zero-based index of character.
   lParam = 0; // not used
   
   //For RichEdit control version 1.x.
   wParam = (WPARAM)pPoint;       // Address of POINT structure.
   lParam = (LPARAM)wCharIndex;   // Zero-based index of character.
   
   //For RichEdit control version 2.
   wParam = (WPARAM) wCharIndex; // Zero-based index of character.
   lParam = 0; // Not used.

An application sends the EM_POSFROMCHAR message to retrieve the coordinates of the specified character in an edit control.

Parameters:

pPoint - Value of wParam. Specifies a pointer to a POINT structure that will receive the coordinates.

wCharIndex - Value of lParam. Specifies the zero-based index of the character.

Return Value - For the standard edit control, the return value is the position of the character. The horizontal coordinate is contained in the LOWORD and the vertical coordinate is contained in the HIWORD. For a single- line edit control, the y-coordinate is always zero.

For the RichEdit control version 1.x, the return value is not used.

For the RichEdit control version 2, the return value is the position of the character. The horizontal coordinate is contained in the LOWORD and the vertical coordinate is contained in the HIWORD.

Remarks:

For a single-line edit control, the y-coordinate is always zero. A returned coordinate can be negative if the character has been scrolled outside the control's client area. The coordinates are truncated to integer values and are in screen units relative to the upper-left corner of the client area of the control.

EM_CHARFROMPOS

   //For standard edit control.
   wParam = 0; // Not used.
   lParam = (LPARAM)&pPoints; // Pointer to a POINTS structure.
   
   //For RichEdit control version 1.x and 2.
   wParam = 0;                 // Not used.
   lParam = (LPARAM)&pPoint;   // Address of a POINT structure.

An application sends an EM_CHARFROMPOS message to retrieve the zero-based character index and zero-based line index of the character nearest the specified point in an edit control.

Parameters:

pPoints - Value of lParam. Specifies a pointer to a POINTS structure that contains the coordinates for the character position wanted. The coordinates are in screen units relative to the upper-left corner of the client area of the control.

pPoint - Value of lParam. Specifies a pointer to a POINT structure that contains the coordinates for the character position wanted. The coordinates are in screen units relative to the upper-left corner of the client area of the control.

Return Value - The return value specifies the character index. Keywords : UsrMisc kbdocerr


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.