EM_GETHANDLE message

Gets a handle of the memory currently allocated for a multiline edit control's text.

Parameters

wParam

Not used; must be zero.

lParam

Not used; must be zero.

Return value

The return value is a memory handle identifying the buffer that holds the content of the edit control. If an error occurs, such as sending the message to a single-line edit control, the return value is zero.

Remarks

If the function succeeds, the application can access the contents of the edit control by casting the return value to HLOCAL and passing it to LocalLock. LocalLock returns a pointer to a buffer that is a null-terminated array of CHARs or WCHARs, depending on whether an ANSI or Unicode function created the control. For example, if CreateWindowExA was used the buffer is an array of CHARs, but if CreateWindowExW was used the buffer is an array of WCHARs. The application may not change the contents of the buffer. To unlock the buffer, the application calls LocalUnlock before allowing the edit control to receive new messages.

Note

For Comctl32.dll version 6, the buffer always contains an array of WCHARs, regardless of whether an ANSI or Unicode function created the edit control. For more information on DLL versions, see Common Control Versions.

If your application cannot abide by the restrictions imposed by EM_GETHANDLE, use the GetWindowTextLength and GetWindowText functions to copy the contents of the edit control into an application-provided buffer.

Rich Edit: The EM_GETHANDLE message is not supported. Rich edit controls do not store text as a simple array of characters.

Requirements

Requirement Value
Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
Header
Winuser.h (include Windows.h)

See also

Reference

EM_SETHANDLE

Other Resources

GetWindowText

GetWindowTextLength

LocalLock

LocalUnlock