Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windows Controls
Control Library
Rich Edit
Messages
 EM_SETTARGETDEVICE Message
EM_SETTARGETDEVICE Message

The EM_SETTARGETDEVICE message sets the target device and line width used for "what you see is what you get" (WYSIWYG) formatting in a rich edit control.

Syntax

To send this message, call the SendMessage function as follows.
lResult = SendMessage(    // returns LRESULT in lResult
   hWndControl,           // (HWND) handle to destination control
   EM_SETTARGETDEVICE,    // (UINT) message ID
   wParam,                // = () wParam; 
   lParam                 // = () lParam;
);

Parameters

wParam
handle to a device context (HDC) for the target device.
lParam
Line width to use for formatting.

Return Value

The return value is zero if the operation fails, or nonzero if it succeeds.

Remarks

The HDC for the default printer can be obtained as follows.

PRINTDLG pd = { sizeof(pd) };
pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT;
if (PrintDlg(&pd))
{
    HDC hdc = pd.hDC;
    ...
}

If lParam is zero, no line breaks are created.

Message Information

HeaderDeclared in Richedit.h
Minimum operating systems Windows 95, Windows NT 4.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Wrapping text to a window      ericbrown93   |   Edit   |   Show History
Calling ::SendMessage(hwnd, EM_SETTARGETDEVICE, NULL, 0) will wrap text to the window, and ::SendMessage(hwnd, EM_SETTARGETDEVICE, NULL, 1) will disable word-wrap entirely. I'm not sure this is documented anywhere else.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker