Syntax
Width.d = WindowGetWidth(Window, Flags=0)
Description
Retrieves the current width of the specified window. By default, it returns the width of the client area (the area inside the borders and title bar) in device-independent pixels (DIPs). Flags can be used to retrieve the outer frame width or the width in physical pixels.
Parameters
Window
The handle of the ProGUI window whose width is to be retrieved.
Flags (optional)
A combination of flags to specify which width to retrieve and in what units. Default is 0 (client area width in DIPs).
#PG_Window_OuterCoordinate : Returns the width of the entire window frame, including borders.
#PG_Window_ReturnPixels : Returns the width in physical device pixels instead of DIPs.
Note: #PG_Window_InnerCoordinate is the default behavior for width (client area) and doesn't need to be specified unless combined with #PG_Window_ReturnPixels.
Return Value
Returns the requested window width as a floating-point number (Double). The unit (DIPs or pixels) depends on the specified flags. Returns 0.0 or #False if the window handle is invalid.
Remarks
The client area width in DIPs is most commonly used for layout calculations within ProGUI. Use #PG_Window_ReturnPixels when interacting with OS functions that require physical pixel dimensions.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyWindow = CreateWindow(0, 0, 400, 300, "Window Size Info")
If MyWindow
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
ClientWidthDIPs.d = WindowGetWidth(MyWindow)
ClientWidthPixels.d = WindowGetWidth(MyWindow, #PG_Window_ReturnPixels)
FrameWidthPixels.d = WindowGetWidth(MyWindow, #PG_Window_OuterCoordinate | #PG_Window_ReturnPixels)
Debug "Client Width (DIPs): " + StrD(ClientWidthDIPs)
Debug "Client Width (Pixels): " + StrD(ClientWidthPixels)
Debug "Frame Width (Pixels): " + StrD(FrameWidthPixels)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
WindowGetHeight, WindowGetX, WindowGetY, WindowResize
Supported OS
Windows, Linux