# Window - [Overview](#section75228680165625) - [Summary](#section1987360514165625) - [Files](#files) - [Data Structures](#nested-classes) - [Enumerations](#enum-members) - [Functions](#func-members) - [Details](#section1328341200165625) - [Enumeration Type](#section1779893936165625) - [WindowPixelFormat](#gade9f6a70c1e8547785d266aab3ca5725) - [Function](#section536210334165625) - [BindRootView\(\)](#ga10d20114dbd02b0ea8306fd508108af9) - [CreateWindow\(\)](#ga13f51542db51b560e4bd8c52fe37a7d0) - [DestoryWindow\(\)](#gaae86fd5bd45c654159939ac4ba877cc1) - [GetRect\(\)](#ga2c14344eed608ec8cd345a6c1c835a53) - [GetRootView\(\)](#ga0f81825ac2f7acd742d114627d007dc0) - [GetWindowId\(\)](#ga7efafa2bc07e9a0b5fc5c4c8b1b17b89) - [Hide\(\)](#ga37272c50d164a77bf004c18174d94736) - [LowerToBottom\(\)](#ga61c01a10b37843abf8cf348bd7d1d659) - [MoveTo\(\)](#ga7454cb1c3c28e68f4e962fef108a0d2f) - [RaiseToTop\(\)](#ga395aa07d4a622059c627d18ecd2ff115) - [Resize\(\)](#gac2c1bf9dc681741eb9c0490785bd73c2) - [Show\(\)](#ga920aaa7deb0054c1436b2aaba3a81e4f) - [UnbindRootView\(\)](#ga7ad1bbc5a9a758e48a0fcecc10512bf2) - [Variable](#section1566951119165625) - [opacity](#ga848d59949e340c4c2572c49212eb6f5a) - [option](#gae5bf33ab2eecd5dcafe2eb3da43d6f27) - [pixelFormat](#ga213fd5a52a7232dd4fbaef7108e2a36a) - [rect](#gabb7c9c7f86fb9f1d29728ca0afa10668) ## **Overview** **Description:** Provides window management capabilities, including creating, destroying, showing, hiding, moving, resizing a window, raising a window to the top, and lowering a window to the bottom. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Files

File Name

Description

window.h

Declares the Window class that provides a drawing canvas for the RootView, which represents the root node of a view tree.

## Data Structures

Data Structure Name

Description

OHOS::WindowConfig

Sets the attributes for this window.

OHOS::Window

Provides a drawing canvas for the RootView, which represents the root node of a view tree.

## Enumerations

Enumeration Name

Description

OHOS::WindowPixelFormat { OHOS::WINDOW_PIXEL_FORMAT_RGB565 = 101, OHOS::WINDOW_PIXEL_FORMAT_ARGB1555, OHOS::WINDOW_PIXEL_FORMAT_RGB888, OHOS::WINDOW_PIXEL_FORMAT_ARGB8888 }

Enumerates the pixel formats of this window.

## Functions

Function

Description

OHOS::Window::CreateWindow (const WindowConfig &config)

static Window *

Creates a Window instance.

OHOS::Window::DestoryWindow (Window *window)

static void

Destroys a specified window.

OHOS::Window::BindRootView (RootView *rootView)=0

virtual void

Binds the RootView to this window.

OHOS::Window::UnbindRootView ()=0

virtual void

Unbinds the RootView from this window.

OHOS::Window::GetRootView ()=0

virtual RootView *

Obtains the RootView bound to this window.

OHOS::Window::GetRect ()=0

virtual Rect

Obtains the rectangle information (position, width, and height) of this window.

OHOS::Window::Show ()=0

virtual void

Shows this window.

OHOS::Window::Hide ()=0

virtual void

Hides this window.

OHOS::Window::MoveTo (int16_t x, int16_t y)=0

virtual void

Moves this window to a specified position.

OHOS::Window::Resize (int16_t width, int16_t height)=0

virtual void

Resizes this window.

OHOS::Window::RaiseToTop ()=0

virtual void

Raises this window to the top.

OHOS::Window::LowerToBottom ()=0

virtual void

Lowers this window to the bottom.

OHOS::Window::GetWindowId ()=0

virtual int32_t

Obtains the unique ID of this window.

## **Details** ## **Enumeration Type ** ## WindowPixelFormat ``` enum [OHOS::WindowPixelFormat](Window.md#gade9f6a70c1e8547785d266aab3ca5725) ``` **Description:** Enumerates the pixel formats of this window.

Enumerator

Description

WINDOW_PIXEL_FORMAT_RGB565

RGB565 format

WINDOW_PIXEL_FORMAT_ARGB1555

ARGB1555 format

WINDOW_PIXEL_FORMAT_RGB888

RGB888 format

WINDOW_PIXEL_FORMAT_ARGB8888

ARGB8888 format

## **Function ** ## BindRootView\(\) ``` virtual void OHOS::Window::BindRootView ([RootView](OHOS-RootView.md) * rootView) ``` **Description:** Binds the **[RootView](OHOS-RootView.md)** to this window. **Parameters:**

Name

Description

rootView Indicates the RootView to bind.
## CreateWindow\(\) ``` static [Window](OHOS-Window.md)* OHOS::Window::CreateWindow (const [WindowConfig](OHOS-WindowConfig.md) & config) ``` **Description:** Creates a **[Window](OHOS-Window.md)** instance. **Parameters:**

Name

Description

config Indicates the window configuration. For details, see WindowConfig.
**Returns:** Returns the **[Window](OHOS-Window.md)** instance if the operation is successful; returns **nullptr** otherwise. ## DestoryWindow\(\) ``` static void OHOS::Window::DestoryWindow ([Window](OHOS-Window.md) * window) ``` **Description:** Destroys a specified window. **Parameters:**

Name

Description

window Indicates the Window instance to destroy.
## GetRect\(\) ``` virtual [Rect](OHOS-Rect.md) OHOS::Window::GetRect () ``` **Description:** Obtains the rectangle information \(position, width, and height\) of this window. **Returns:** Returns the rectangle information of this window. ## GetRootView\(\) ``` virtual [RootView](OHOS-RootView.md)* OHOS::Window::GetRootView () ``` **Description:** Obtains the **[RootView](OHOS-RootView.md)** bound to this window. **Returns:** Returns the **[RootView](OHOS-RootView.md)** if available; returns **nullptr** otherwise. ## GetWindowId\(\) ``` virtual int32_t OHOS::Window::GetWindowId () ``` **Description:** Obtains the unique ID of this window. The window ID is within \[0, 31\]. An ID will be reused after the current window is destroyed. A maximum of 32 windows can be displayed at the same time. **Returns:** Returns the unique ID of this window if the operation is successful; returns **-1** otherwise. ## Hide\(\) ``` virtual void OHOS::Window::Hide () ``` **Description:** Hides this window. ## LowerToBottom\(\) ``` virtual void OHOS::Window::LowerToBottom () ``` **Description:** Lowers this window to the bottom. ## MoveTo\(\) ``` virtual void OHOS::Window::MoveTo (int16_t x, int16_t y ) ``` **Description:** Moves this window to a specified position. **Parameters:**

Name

Description

x Indicates the x-coordinate of the target position.
y Indicates the y-coordinate of the target position.
## RaiseToTop\(\) ``` virtual void OHOS::Window::RaiseToTop () ``` **Description:** Raises this window to the top. ## Resize\(\) ``` virtual void OHOS::Window::Resize (int16_t width, int16_t height ) ``` **Description:** Resizes this window. **Parameters:**

Name

Description

width Indicates the new window width.
height Indicates the new window height.
## Show\(\) ``` virtual void OHOS::Window::Show () ``` **Description:** Shows this window. ## UnbindRootView\(\) ``` virtual void OHOS::Window::UnbindRootView () ``` **Description:** Unbinds the **[RootView](OHOS-RootView.md)** from this window. ## **Variable ** ## opacity ``` uint8_t OHOS::WindowConfig::opacity ``` **Description:** Opacity, within \[0, 255\] ## option ``` uint32_t OHOS::WindowConfig::option ``` **Description:** Other options ## pixelFormat ``` [WindowPixelFormat](Window.md#gade9f6a70c1e8547785d266aab3ca5725) OHOS::WindowConfig::pixelFormat ``` **Description:** Pixel format ## rect ``` [Rect](OHOS-Rect.md) OHOS::WindowConfig::rect ``` **Description:** [Rectangle](Rectangle.md)