ClientToScreen
TOC
Collapse the table of content
Expand the table of content

ClientToScreen (Compact 2013)

3/28/2014

This function converts the client coordinates of a specified point to screen coordinates.


BOOL ClientToScreen( 
  HWND hWnd, 
  LPPOINT lpPoint
);

hWnd

Handle to the window whose client area is used for the conversion.

lpPoint

Long pointer to a POINT structure that contains the client coordinates to be converted.

The new screen coordinates are copied into this structure if the function succeeds.

Nonzero indicates success.

Zero indicates failure.

To get extended error information, call GetLastError.

The following code example converts the coordinates of a mouse click or stylus tap to screen coordinates and uses the new coordinates in a calculation.

Ee505933.note(en-us,WinEmbedded.80).gifImportant:
For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

    switch (message)
    {
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
            pt.x = LOWORD(lParam);
            pt.y = HIWORD(lParam);
            ClientToScreen( hStatusWnd, &pt );
            SetCapture(hStatusWnd);
            GetWindowRect(hStatusWnd,&drc);
            ptdif.x = pt.x - drc.left;
            ptdif.y = pt.y - drc.top;
            break;
    }

The ClientToScreen function replaces the client coordinates in the POINT structure with the screen coordinates. The origin of the new coordinates depends on the window layout. For windows with a left-to-right layout, the new screen coordinates are relative to the upper-left corner of the screen; for windows with a right-to-left layout,they are relative to the upper-right corner of the screen.

All coordinates are in device units.

Header

winuser.h

Library

coredll.lib,
Winmgr.lib

Show:
© 2016 Microsoft