1 out of 2 rated this helpful - Rate this topic

SetLayout function

Applies to: desktop apps only

The SetLayout function changes the layout of a device context (DC).

Syntax

DWORD SetLayout(
  __in  HDC hdc,
  __in  DWORD dwLayout
);

Parameters

hdc [in]

A handle to the DC.

dwLayout [in]

The DC layout. This parameter can be one or more of the following values.

ValueMeaning
LAYOUT_BITMAPORIENTATIONPRESERVED

Disables any reflection during BitBlt and StretchBlt operations.

LAYOUT_RTL

Sets the default horizontal layout to be right to left.

 

Return value

If the function succeeds, it returns the previous layout of the DC.

If the function fails, it returns GDI_ERROR.

Remarks

The layout specifies the order in which text and graphics are revealed in a window or a device context. The default is left to right. The SetLayout function changes this to be right to left, which is the standard in Arabic and Hebrew cultures.

Once the LAYOUT_RTL flag is selected, flags normally specifying right or left are reversed. To avoid confusion, consider defining alternate words for standard flags, such as those in the following table.

Standard flagSuggested alternate name
WS_EX_RIGHTWS_EX_TRAILING
WS_EX_RTLREADINGWS_EX_REVERSEREADING
WS_EX_LEFTSCROLLBARWS_EX_LEADSCROLLBAR
ES_LEFTES_LEAD
ES_RIGHTES_TRAIL
EC_LEFTMARGINEC_LEADMARGIN
EC_RIGHTMARGINEC_TRAILMARGIN

 

SetLayout cannot modify drawing directly into the bits of a DIB.

For more information, see "Window Layout and Mirroring" in Window Features.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Wingdi.h (include Windows.h)

Library

Gdi32.lib

DLL

Gdi32.dll

See also

Device Contexts Overview
Device Context Functions
GetLayout

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
BitBlt raster operation NOMIRRORBITMAP preferable for single calls
If you are calling this to avoid bitmap reflection, then t avoid saving, modifying, and restoring the DC, it's easier to just pass NOMIRRORBITMAP to BitBlt or StretchBlt. This is essential if you are drawing text into an offscreen DIB and then blitting it to the screen, which would otherwise be pixel mirrored on RTL builds. For multiple calls that all need to preserve orientation, you can just call SetLayout, but note that DC's obtained from windows (and not a class DC) are reset each GetDC call depending on the WS_EX_LAYOUTRTL flag (so you would need to call SetLayout again).