Window State Queries
IsWindowFocused
Checks if the current window is focused.Parameters
Flags to modify the focus check behavior. Common flags:
ImGuiFocusedFlags_ChildWindows- Check child windows tooImGuiFocusedFlags_RootWindow- Check root window insteadImGuiFocusedFlags_AnyWindow- Return true if any window is focused
Returns
True if the current window (or specified scope) is focused.
Example
IsWindowHovered
Checks if the current window is hovered and hoverable.Parameters
Flags to modify hover check behavior. Common flags:
ImGuiHoveredFlags_ChildWindows- Check child windows tooImGuiHoveredFlags_RootWindow- Check root window insteadImGuiHoveredFlags_AllowWhenBlockedByPopup- Return true even if blocked by popupImGuiHoveredFlags_AllowWhenBlockedByActiveItem- Return true even if blocked by active item
Returns
True if the current window is hovered and hoverable (not blocked by popup/modal).
Example
Window Position & Size Queries
GetWindowPos
Gets the current window position in screen space.Returns
Current window position in screen coordinates (pixels).
Example
It is unlikely you ever need to use this. Consider using
GetCursorScreenPos() and GetContentRegionAvail() instead for layout purposes.GetWindowSize
Gets the current window size.Returns
Current window size including decorations (title bar, borders, etc.).
Example
GetWindowWidth / GetWindowHeight
Gets the current window width or height.Returns
Current window width or height in pixels.
Example
Window Manipulation
Prefer using
SetNextXXX functions (before Begin()) rather than SetXXX functions (after Begin()). The SetNext functions are cleaner and avoid potential side effects.SetNextWindowPos
Sets the next window position (call beforeBegin()).
Parameters
Position in screen coordinates.
Condition for applying position:
0orImGuiCond_Always- Always applyImGuiCond_Once- Apply once per runtime sessionImGuiCond_FirstUseEver- Apply only on first useImGuiCond_Appearing- Apply when window appears
Pivot point: (0,0) = top-left, (0.5,0.5) = center, (1,1) = bottom-right.
Example
SetNextWindowSize
Sets the next window size (call beforeBegin()).
Parameters
Window size. Set axis to 0.0f to force auto-fit on that axis.
Condition for applying size.
Example
SetNextWindowSizeConstraints
Sets the next window size constraints.Parameters
Minimum size. Use 0.0f or
FLT_MAX for no limit.Maximum size. Use
FLT_MAX for no limit. Use -1 for both min and max of same axis to preserve current size.Optional callback for custom programmatic constraints.
User data passed to the callback.
Example
Window Scrolling
GetScrollX / GetScrollY
Gets the current scroll position.Returns
Current scroll amount from 0 to
GetScrollMaxX() or GetScrollMaxY().Example
SetScrollX / SetScrollY
Sets the scroll position.Parameters
Scroll amount from 0 to
GetScrollMaxX().Scroll amount from 0 to
GetScrollMaxY().Example
Changes to scroll will be applied at the beginning of the next frame in the first call to
Begin(). You can use SetNextWindowScroll() before Begin() to avoid this one-frame delay.SetScrollHereY
Adjusts scrolling to make the current cursor position visible.Parameters
Position ratio: 0.0 = top, 0.5 = center, 1.0 = bottom.
Example
GetScrollMaxX / GetScrollMaxY
Gets the maximum scroll amount.Returns
Maximum scroll amount ≈ ContentSize - WindowSize - DecorationsSize.