次の方法で共有


EnumDisplayMonitors (Windows Embedded CE 6.0)

1/6/2010

This function enumerates screens that intersect a region formed by the intersection of a specified clipping rectangle and the visible region of a specified device context.

Syntax

BOOL EnumDisplayMonitors(
  HDC hdc,
  LPCRECT lprcClip,
  MONITORENUMPROC lpfnEnum,
  LPARAM dwData
);

Parameters

  • hdc
    [in] Handle to a display device context that specifies the visible region of interest. When this parameter is NULL, the hdcMonitor parameter that this function passes to the MonitorEnumProc callback function is NULL, and the visible region of interest is the virtual screen that encompasses all of the screens connected to the Windows Embedded CE–based device.
  • lprcClip
    [in] Pointer to a RECT structure that specifies a clipping rectangle. The region of interest is the intersection of the clipping rectangle with the visible region specified by hdc. If hdc is not NULL, specify the coordinates of the clipping rectangle relative to the origin of the hdc. If hdc is NULL, specify virtual screen coordinates. Set lprcClip equal to NULL if you do not want to clip the region specified by hdc.
  • lpfnEnum
    [in] Pointer to an application-defined MonitorEnumProc callback function that you want EnumDisplayMonitors to call for each screen it enumerates. This parameter cannot be NULL.
  • dwData
    [in] DWORD that specifies application-defined data that you want this function to pass directly to MonitorEnumProc.

Return Value

TRUE indicates success. FALSE indicates failure or that lpfnEnum is NULL. To get extended error information, call GetLastError. When lpfnEnum is NULL, GetLastError returns ERROR_INVALID_PARAMETER.

Remarks

The following list shows tasks that you can perform by calling this function:

  • Draw optimally into a device context that spans several screens.
  • Obtain a handle and position rectangle for one or more screens.

This function calls an application-defined MonitorEnumProc callback function once for each screen that this function enumerates.

By setting the hdc parameter to NULL, you can use this function to obtain a handle and position rectangle for one or more screens. The following table shows how the four combinations of NULL and non-NULL hdc and lprcClip values affect the behavior of this function.

Value of hdc Value of lprcRect Behavior of EnumDisplayMonitors

NULL

NULL

Enumerates all screens and passes a NULL hdc to the callback function.

NULL

non-NULL

Enumerates all screens that intersect the clipping rectangle and passes a NULL hdc to the callback function. Use virtual screen coordinates for the clipping rectangle.

non-NULL

NULL

Enumerates all screens that intersect the visible region of the device context and passes an hdc for each specific screen to the callback function.

non-NULL

non-NULL

Enumerates all screens that intersect the visible region of the device context and the clipping rectangle and passes an hdc for each specific screen to the callback function. Use device context coordinates for the clipping rectangle.

The following code example shows how to paint in response to a WM_PAINT message using the capabilities of each screen.

case WM_PAINT:
  hdc = BeginPaint(hwnd, &ps);
  EnumDisplayMonitors(hdc, NULL, MyPaintEnumProc, 0);
  EndPaint(hwnd, &ps);

The following code example shows how to paint the top half of a window using the capabilities of each screen.

GetClientRect(hwnd, &rc);
rc.bottom = (rc.bottom - rc.top) / 2;
hdc = GetDC(hwnd);
EnumDisplayMonitors(hdc, &rc, MyPaintEnumProc, 0);
ReleaseDC(hwnd, hdc);

The following code example shows how to paint the entire virtual screen optimally for each screen.

hdc = GetDC(NULL);
EnumDisplayMonitors(hdc, NULL, MyPaintScreenEnumProc, 0);
ReleaseDC(NULL, hdc);

The following code example shows how to get information about all of the screens.

EnumDisplayMonitors(NULL, NULL, MyInfoEnumProc, 0);

Requirements

Header windows.h
Library coredll.lib
Windows Embedded CE Windows CE .NET 4.0 and later

See Also

Reference

Multiple Screens Functions
MonitorEnumProc

Other Resources

GetSystemMetrics
RECT