Windows API Reference

Documentation for Windows Programming Interfaces

POINT Structure

The POINT structure specifies a coordinate in two-dimensional space. This structure is used by many Windows functions, such as those that deal with screen coordinates, cursor positions, and window dimensions.

Syntax

typedef struct _POINT {
  LONG x;
  LONG y;
} POINT;

Members

Member Type Description
x LONG The x-coordinate of the point. This member can be a signed integer.
y LONG The y-coordinate of the point. This member can be a signed integer.

Requirements

| |
SDK Windows.h
Header wingdi.h (for GDI functions), winuser.h (for user interface functions)

Remarks

The POINT structure is the basis for other structures like POINTEX. The coordinates are typically relative to the device context's origin.

Example

The following C++ code snippet demonstrates how to declare and initialize a POINT structure:

#include <windows.h>
#include <iostream>

int main() {
    POINT pt1;
    pt1.x = 100;
    pt1.y = 200;

    POINT pt2 = {50, 75}; // Using aggregate initialization

    std::cout << "Point 1: (" << pt1.x << ", " << pt1.y << ")" << std::endl;
    std::cout << "Point 2: (" << pt2.x << ", " << pt2.y << ")" << std::endl;

    return 0;
}

See Also