WindowGetX

Syntax

X = WindowGetX(Window, Flags=0)

Description

Retrieves the current horizontal (X) screen coordinate of the specified window in physical pixels. Flags can be used to specify whether to return the coordinate of the outer frame or the inner client area.

Parameters

Window
The handle of the ProGUI window whose X coordinate is to be retrieved.

Flags (optional)
A flag to specify which coordinate to return. Default is 0 (outer frame's top-left X coordinate).

#PG_Window_InnerCoordinate : Returns the X coordinate of the window's client area (top-left corner).

Note: #PG_Window_OuterCoordinate is the default behavior (outer frame) and doesn't need to be specified.

Return Value

Returns the requested X screen coordinate as an Integer (physical pixels). Returns 0 or #False if the window handle is invalid.

Remarks

This function returns coordinates in physical screen pixels, not device-independent pixels (DIPs). This is useful for positioning the window using OS functions or relative to other screen elements.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyWindow = CreateWindow(0, 0, 400, 300, "Window Position Info")

If MyWindow
  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

  OuterX = WindowGetX(MyWindow)
  InnerX = WindowGetX(MyWindow, #PG_Window_InnerCoordinate)

  Debug "Outer Frame X (Pixels): " + Str(OuterX)
  Debug "Client Area X (Pixels): " + Str(InnerX)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

StopProGUI()

See Also

WindowGetY, WindowGetWidth, WindowGetHeight, WindowResize

Supported OS

Windows, Linux