1e41f4b71Sopenharmony_ci# @ohos.window (窗口)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci窗口提供管理窗口的一些基础能力,包括对当前窗口的创建、销毁、各属性设置,以及对各窗口间的管理调度。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci该模块提供以下窗口相关的常用功能:
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci- [Window](#window):当前窗口实例,窗口管理器管理的基本单元。
8e41f4b71Sopenharmony_ci- [WindowStage](#windowstage9):窗口管理器。管理各个基本窗口单元。
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci> **说明:**
11e41f4b71Sopenharmony_ci>
12e41f4b71Sopenharmony_ci> - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
13e41f4b71Sopenharmony_ci>
14e41f4b71Sopenharmony_ci> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.window (窗口)](js-apis-window.md)。
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci## 导入模块
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci```ts
19e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
20e41f4b71Sopenharmony_ci```
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci## WindowType<sup>7+</sup>
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci窗口类型枚举。
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci| 名称                                  | 值 | 说明                                                                                     |
29e41f4b71Sopenharmony_ci|-------------------------------------| ------ |----------------------------------------------------------------------------------------|
30e41f4b71Sopenharmony_ci| TYPE_INPUT_METHOD<sup>(deprecated)</sup>      | 2      | 表示输入法窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**说明:** 从API version 9开始支持,从API version 13开始废弃,无替代窗口类型,输入法相关控制都请调用[输入法框架侧接口](../../inputmethod/inputmethod-application-guide.md)执行。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
31e41f4b71Sopenharmony_ci| TYPE_STATUS_BAR<sup>9+</sup>        | 3      | 表示状态栏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
32e41f4b71Sopenharmony_ci| TYPE_PANEL<sup>9+</sup>             | 4      | 表示通知栏。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
33e41f4b71Sopenharmony_ci| TYPE_KEYGUARD<sup>9+</sup>          | 5      | 表示锁屏。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
34e41f4b71Sopenharmony_ci| TYPE_VOLUME_OVERLAY<sup>9+</sup>    | 6      | 表示音量条。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
35e41f4b71Sopenharmony_ci| TYPE_NAVIGATION_BAR<sup>9+</sup>    | 7      | 表示导航栏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
36e41f4b71Sopenharmony_ci| TYPE_WALLPAPER<sup>9+</sup>         | 9      | 表示壁纸。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
37e41f4b71Sopenharmony_ci| TYPE_DESKTOP<sup>9+</sup>           | 10      | 表示桌面。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
38e41f4b71Sopenharmony_ci| TYPE_LAUNCHER_RECENT<sup>9+</sup>   | 11      | 表示多任务中心。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
39e41f4b71Sopenharmony_ci| TYPE_LAUNCHER_DOCK<sup>9+</sup>     | 12      | 表示桌面Dock栏。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
40e41f4b71Sopenharmony_ci| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13      | 表示智慧语音。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
41e41f4b71Sopenharmony_ci| TYPE_POINTER<sup>9+</sup>           | 14      | 表示鼠标。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
42e41f4b71Sopenharmony_ci| TYPE_FLOAT_CAMERA<sup>9+</sup>      | 15      | 表示相机类型悬浮窗。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
43e41f4b71Sopenharmony_ci| TYPE_SCREENSHOT<sup>9+</sup>        | 17      | 表示截屏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
44e41f4b71Sopenharmony_ci| TYPE_SYSTEM_TOAST<sup>11+</sup>     | 18      | 表示顶层提示窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
45e41f4b71Sopenharmony_ci| TYPE_DIVIDER<sup>11+</sup>          | 19      | 表示分屏条。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
46e41f4b71Sopenharmony_ci| TYPE_GLOBAL_SEARCH<sup>11+</sup>    | 20      | 表示全局搜索窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.WindowManager.WindowManager.Core |
47e41f4b71Sopenharmony_ci| TYPE_HANDWRITE<sup>12+</sup>        | 21      | 表示手写笔窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。<br>**系统能力:** SystemCapability.Window.SessionManager |
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci## WindowMode<sup>7+</sup>
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci窗口模式枚举。
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci| 名称       | 值   | 说明                          |
58e41f4b71Sopenharmony_ci| ---------- | ---- | ----------------------------- |
59e41f4b71Sopenharmony_ci| UNDEFINED  | 1    | 表示APP未定义窗口模式。       |
60e41f4b71Sopenharmony_ci| FULLSCREEN | 2    | 表示APP全屏模式。             |
61e41f4b71Sopenharmony_ci| PRIMARY    | 3    | 表示APP分屏多窗口主要模式。   |
62e41f4b71Sopenharmony_ci| SECONDARY  | 4    | 表示APP分屏多窗口次要模式。   |
63e41f4b71Sopenharmony_ci| FLOATING   | 5    | 表示APP自由悬浮形式窗口模式。 |
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci## WindowLayoutMode<sup>9+</sup>
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci窗口布局模式枚举。
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci| 名称       | 值   | 说明                          |
74e41f4b71Sopenharmony_ci| ---------- | ---- | ----------------------------- |
75e41f4b71Sopenharmony_ci| WINDOW_LAYOUT_MODE_CASCADE  | 0    | 表示使用层叠布局模式。       |
76e41f4b71Sopenharmony_ci| WINDOW_LAYOUT_MODE_TILE | 1    | 表示使用平铺布局模式。             |
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci## BlurStyle<sup>9+</sup>
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci窗口模糊类型枚举。
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci| 名称    | 值   | 说明                 |
88e41f4b71Sopenharmony_ci| ------- | ---- | -------------------- |
89e41f4b71Sopenharmony_ci| OFF     | 0    | 表示关闭模糊。       |
90e41f4b71Sopenharmony_ci| THIN    | 1    | 表示较薄的模糊类型。 |
91e41f4b71Sopenharmony_ci| REGULAR | 2    | 表示适中的模糊类型。 |
92e41f4b71Sopenharmony_ci| THICK   | 3    | 表示较厚的模糊类型。 |
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci## SystemBarRegionTint<sup>8+</sup>
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci单个导航栏或状态栏回调信息。
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci| 名称            | 类型                  | 可读 | 可写 | 说明                                                         |
103e41f4b71Sopenharmony_ci| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
104e41f4b71Sopenharmony_ci| type            | [WindowType](#windowtype7) | 是   | 否   | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 |
105e41f4b71Sopenharmony_ci| isEnable        | boolean                   | 是   | 否   | 当前系统栏是否显示。true表示显示;false表示不显示。 |
106e41f4b71Sopenharmony_ci| region          | [Rect](js-apis-window.md#rect7)             | 是   | 否   | 当前系统栏的位置及大小。                                     |
107e41f4b71Sopenharmony_ci| backgroundColor | string                    | 是   | 否   | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
108e41f4b71Sopenharmony_ci| contentColor    | string                    | 是   | 否   | 系统栏文字颜色。                                             |
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci## SystemBarTintState<sup>8+</sup>
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci当前系统栏回调信息集合。
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci| 名称       | 类型                                            | 可读 | 可写 | 说明                         |
119e41f4b71Sopenharmony_ci| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- |
120e41f4b71Sopenharmony_ci| displayId  | number                                              | 是   | 否   | 当前物理屏幕id,该参数应为整数。             |
121e41f4b71Sopenharmony_ci| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | 是   | 否   | 当前已改变的所有系统栏信息。 |
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci## ScaleOptions<sup>9+</sup>
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci缩放参数。
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.WindowManager.WindowManager.Core
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci| 名称   | 类型 | 只读 | 必填 | 说明                                         |
132e41f4b71Sopenharmony_ci| ------ | -------- | ---- | ---- | --------------------------------------------|
133e41f4b71Sopenharmony_ci| x      | number   | 否   | 否   | X轴的缩放参数。该参数为浮点数,默认值为1.0。                   |
134e41f4b71Sopenharmony_ci| y      | number   | 否   | 否   | Y轴的缩放参数。该参数为浮点数,默认值为1.0。                   |
135e41f4b71Sopenharmony_ci| pivotX | number   | 否   | 否   | 缩放中心点X轴坐标。该参数为浮点数,默认值为0.5, 取值范围[0.0, 1.0]。 |
136e41f4b71Sopenharmony_ci| pivotY | number   | 否   | 否   | 缩放中心点Y轴坐标。该参数为浮点数,默认值为0.5, 取值范围[0.0, 1.0]。 |
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci## RotateOptions<sup>9+</sup>
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci旋转参数。
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.WindowManager.WindowManager.Core
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci| 名称   | 类型 | 只读 | 必填 | 说明                                          |
147e41f4b71Sopenharmony_ci| ------ | -------- | ---- |---- |---------------------------------------------|
148e41f4b71Sopenharmony_ci| x      | number   | 否   | 否  | 绕X轴的旋转角度。该参数为浮点数,默认值为0.0。                   |
149e41f4b71Sopenharmony_ci| y      | number   | 否   | 否  | 绕Y轴的旋转角度。该参数为浮点数,默认值为0.0。                   |
150e41f4b71Sopenharmony_ci| z      | number   | 否   | 否  | 绕Z轴的旋转角度。该参数为浮点数,默认值为0.0。                   |
151e41f4b71Sopenharmony_ci| pivotX | number   | 否   | 否  | 旋转中心点X轴坐标。该参数为浮点数,默认值为0.5, 取值范围为[0.0, 1.0]。 |
152e41f4b71Sopenharmony_ci| pivotY | number   | 否   | 否  | 旋转中心点Y轴坐标。该参数为浮点数,默认值为0.5, 取值范围为[0.0, 1.0]。  |
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci## TranslateOptions<sup>9+</sup>
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci平移参数。
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.WindowManager.WindowManager.Core
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci| 名称 | 类型 | 只读 | 必填 | 说明                         |
163e41f4b71Sopenharmony_ci| ---- | -------- | ---- | ---- | ---------------------------- |
164e41f4b71Sopenharmony_ci| x    | number   | 否   | 否  | X轴的平移参数。该参数为浮点数,默认值为0.0,单位为px。 |
165e41f4b71Sopenharmony_ci| y    | number   | 否   | 否  | Y轴的平移参数。该参数为浮点数,默认值为0.0,单位为px。 |
166e41f4b71Sopenharmony_ci| z    | number   | 否   | 否  | Z轴的平移参数。该参数为浮点数,默认值为0.0,单位为px。 |
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci## WindowInfo<sup>12+</sup>
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci当前窗口的详细信息。
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci**系统能力:**  SystemCapability.Window.SessionManager
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci| 名称   | 类型   | 只读 | 可选 | 说明                                       |
177e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---- | ------------------------------------------ |
178e41f4b71Sopenharmony_ci| rect  | [Rect](js-apis-window.md#rect7)   | 是   | 否   | 窗口内可绘制区域尺寸,其中左边界上边界是相对窗口计算。 |
179e41f4b71Sopenharmony_ci| bundleName  | string   | 是   | 否   | 应用Bundle的名称。          |
180e41f4b71Sopenharmony_ci| abilityName | string   | 是   | 否   | Ability的名称。               |
181e41f4b71Sopenharmony_ci| windowId | number | 是   | 否   | 窗口ID。   |
182e41f4b71Sopenharmony_ci| windowStatusType | [WindowStatusType](js-apis-window.md#windowstatustype11) | 是   | 否   | 窗口模式枚举。   |
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci## window.minimizeAll<sup>9+</sup>
185e41f4b71Sopenharmony_ciminimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci最小化某显示设备下的所有窗口。
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci**参数:**
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明           |
196e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | -------------- |
197e41f4b71Sopenharmony_ci| id       | number                    | 是   | 显示设备[Display](js-apis-display.md#display)的ID号,该参数仅支持整数输入。 |
198e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci**错误码:**
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
205e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
206e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
207e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
208e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
209e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ci**示例:**
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci```ts
214e41f4b71Sopenharmony_ciimport { display } from '@kit.ArkUI';
215e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_cilet displayClass: display.Display | null = null;
218e41f4b71Sopenharmony_cidisplayClass = display.getDefaultDisplaySync();
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_citry {
221e41f4b71Sopenharmony_ci  window.minimizeAll(displayClass.id, (err: BusinessError) => {
222e41f4b71Sopenharmony_ci    const errCode: number = err.code;
223e41f4b71Sopenharmony_ci    if (errCode) {
224e41f4b71Sopenharmony_ci      console.error(`Failed to minimize all windows. Cause code: ${err.code}, message: ${err.message}`);
225e41f4b71Sopenharmony_ci      return;
226e41f4b71Sopenharmony_ci    }
227e41f4b71Sopenharmony_ci    console.info('Succeeded in minimizing all windows.');
228e41f4b71Sopenharmony_ci  });
229e41f4b71Sopenharmony_ci} catch (exception) {
230e41f4b71Sopenharmony_ci  console.error(`Failed to minimize all windows. Cause code: ${exception.code}, message: ${exception.message}`);
231e41f4b71Sopenharmony_ci}
232e41f4b71Sopenharmony_ci```
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci## window.minimizeAll<sup>9+</sup>
235e41f4b71Sopenharmony_ciminimizeAll(id: number): Promise&lt;void&gt;
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci最小化某显示设备下的所有窗口。
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci**参数:**
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明           |
246e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | -------------- |
247e41f4b71Sopenharmony_ci| id       | number                    | 是   | 显示设备[Display](js-apis-display.md#display)的ID号,该参数仅支持整数输入。 |
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci**返回值:**
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci| 类型                | 说明                      |
252e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
253e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci**错误码:**
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
260e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
261e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
262e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
263e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
264e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci**示例:**
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci```ts
269e41f4b71Sopenharmony_ciimport { display } from '@kit.ArkUI';
270e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_cilet displayClass: display.Display | null = null;
273e41f4b71Sopenharmony_cidisplayClass = display.getDefaultDisplaySync();
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_citry {
276e41f4b71Sopenharmony_ci  let promise = window.minimizeAll(displayClass.id);
277e41f4b71Sopenharmony_ci  promise.then(() => {
278e41f4b71Sopenharmony_ci    console.info('Succeeded in minimizing all windows.');
279e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
280e41f4b71Sopenharmony_ci    console.error(`Failed to minimize all windows. Cause code: ${err.code}, message: ${err.message}`);
281e41f4b71Sopenharmony_ci  });
282e41f4b71Sopenharmony_ci} catch (exception) {
283e41f4b71Sopenharmony_ci  console.error(`Failed to minimize all windows. Cause code: ${exception.code}, message: ${exception.message}`);
284e41f4b71Sopenharmony_ci}
285e41f4b71Sopenharmony_ci```
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci## window.toggleShownStateForAllAppWindows<sup>9+</sup>
288e41f4b71Sopenharmony_citoggleShownStateForAllAppWindows(callback: AsyncCallback&lt;void&gt;): void
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci多窗口快速切换时隐藏或者恢复应用窗口。
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci**参数:**
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明           |
299e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | -------------- |
300e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**错误码:**
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
307e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
308e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
309e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
310e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci**示例:**
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci```ts
315e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ciwindow.toggleShownStateForAllAppWindows((err: BusinessError) => {
318e41f4b71Sopenharmony_ci  const errCode: number = err.code;
319e41f4b71Sopenharmony_ci  if (errCode) {
320e41f4b71Sopenharmony_ci    console.error(`Failed to toggle shown state for all app windows. Cause code: ${err.code}, message: ${err.message}`);
321e41f4b71Sopenharmony_ci    return;
322e41f4b71Sopenharmony_ci  }
323e41f4b71Sopenharmony_ci  console.info('Succeeded in toggling shown state for all app windows.');
324e41f4b71Sopenharmony_ci});
325e41f4b71Sopenharmony_ci```
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci## window.toggleShownStateForAllAppWindows<sup>9+</sup>
328e41f4b71Sopenharmony_citoggleShownStateForAllAppWindows(): Promise&lt;void&gt;
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ci多窗口快速切换时隐藏或者恢复应用窗口。
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci**返回值:**
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci| 类型                | 说明                      |
339e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
340e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
341e41f4b71Sopenharmony_ci
342e41f4b71Sopenharmony_ci**错误码:**
343e41f4b71Sopenharmony_ci
344e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
345e41f4b71Sopenharmony_ci
346e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
347e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
348e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
349e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
350e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ci**示例:**
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci```ts
355e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_cilet promise = window.toggleShownStateForAllAppWindows();
358e41f4b71Sopenharmony_cipromise.then(() => {
359e41f4b71Sopenharmony_ci  console.info('Succeeded in toggling shown state for all app windows.');
360e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
361e41f4b71Sopenharmony_ci  console.error(`Failed to toggle shown state for all app windows. Cause code: ${err.code}, message: ${err.message}`);
362e41f4b71Sopenharmony_ci});
363e41f4b71Sopenharmony_ci```
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci## window.setWindowLayoutMode<sup>9+</sup>
366e41f4b71Sopenharmony_cisetWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback&lt;void&gt;): void
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci设置窗口布局模式。
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci**参数:**
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明           |
377e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | -------------- |
378e41f4b71Sopenharmony_ci| mode       | [WindowLayoutMode](#windowlayoutmode9)                  | 是   | 设置的窗口布局模式。 |
379e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_ci**错误码:**
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
386e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
387e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
388e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
389e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_ci**示例:**
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ci```ts
394e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_citry {
397e41f4b71Sopenharmony_ci  window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (err: BusinessError) => {
398e41f4b71Sopenharmony_ci    const errCode: number = err.code;
399e41f4b71Sopenharmony_ci    if (errCode) {
400e41f4b71Sopenharmony_ci      console.error(`Failed to set window layout mode. Cause code: ${err.code}, message: ${err.message}`);
401e41f4b71Sopenharmony_ci      return;
402e41f4b71Sopenharmony_ci    }
403e41f4b71Sopenharmony_ci    console.info('Succeeded in setting window layout mode.');
404e41f4b71Sopenharmony_ci  });
405e41f4b71Sopenharmony_ci} catch (exception) {
406e41f4b71Sopenharmony_ci  console.error(`Failed to set window layout mode. Cause code: ${exception.code}, message: ${exception.message}`);
407e41f4b71Sopenharmony_ci}
408e41f4b71Sopenharmony_ci```
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci## window.setWindowLayoutMode<sup>9+</sup>
411e41f4b71Sopenharmony_cisetWindowLayoutMode(mode: WindowLayoutMode): Promise&lt;void&gt;
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci设置窗口布局模式。
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
418e41f4b71Sopenharmony_ci
419e41f4b71Sopenharmony_ci**参数:**
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明           |
422e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | -------------- |
423e41f4b71Sopenharmony_ci| mode       | [WindowLayoutMode](#windowlayoutmode9)                    | 是   | 设置的窗口布局模式。 |
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci**返回值:**
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_ci| 类型                | 说明                      |
428e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
429e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ci**错误码:**
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
436e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
437e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
438e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
439e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci**示例:**
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci```ts
444e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_citry {
447e41f4b71Sopenharmony_ci  let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
448e41f4b71Sopenharmony_ci  promise.then(() => {
449e41f4b71Sopenharmony_ci    console.info('Succeeded in setting window layout mode.');
450e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
451e41f4b71Sopenharmony_ci    console.error(`Failed to set window layout mode. Cause code: ${err.code}, message: ${err.message}`);
452e41f4b71Sopenharmony_ci  });
453e41f4b71Sopenharmony_ci} catch (exception) {
454e41f4b71Sopenharmony_ci  console.error(`Failed to set window layout mode. Cause code: ${exception.code}, message: ${exception.message}`);
455e41f4b71Sopenharmony_ci}
456e41f4b71Sopenharmony_ci```
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci## window.on('systemBarTintChange')<sup>8+</sup>
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_cion(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): void
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci开启状态栏、导航栏属性变化的监听。
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci**参数:**
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci| 参数名   | 类型                                                       | 必填 | 说明                                                         |
471e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
472e41f4b71Sopenharmony_ci| type     | string                                                     | 是   | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
473e41f4b71Sopenharmony_ci| callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 是   | 回调函数。返回当前的状态栏、导航栏信息集合。                 |
474e41f4b71Sopenharmony_ci
475e41f4b71Sopenharmony_ci**错误码:**
476e41f4b71Sopenharmony_ci
477e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
478e41f4b71Sopenharmony_ci
479e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
480e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
481e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
482e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.               |
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci**示例:**
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ci```ts
487e41f4b71Sopenharmony_citry {
488e41f4b71Sopenharmony_ci  window.on('systemBarTintChange', (data) => {
489e41f4b71Sopenharmony_ci    console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
490e41f4b71Sopenharmony_ci  });
491e41f4b71Sopenharmony_ci} catch (exception) {
492e41f4b71Sopenharmony_ci  console.error(`Failed to enable the listener for systemBarTint changes. Cause code: ${exception.code}, message: ${exception.message}`);
493e41f4b71Sopenharmony_ci}
494e41f4b71Sopenharmony_ci```
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_ci## window.off('systemBarTintChange')<sup>8+</sup>
497e41f4b71Sopenharmony_ci
498e41f4b71Sopenharmony_cioff(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;): void
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_ci关闭状态栏、导航栏属性变化的监听。
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
503e41f4b71Sopenharmony_ci
504e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci**参数:**
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci| 参数名   | 类型                                                       | 必填 | 说明                                                         |
509e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
510e41f4b71Sopenharmony_ci| type     | string                                                     | 是   | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
511e41f4b71Sopenharmony_ci| callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 否   | 回调函数。返回当前的状态栏、导航栏信息集合。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有状态栏、导航栏属性变化的监听。                |
512e41f4b71Sopenharmony_ci
513e41f4b71Sopenharmony_ci**错误码:**
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
516e41f4b71Sopenharmony_ci
517e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
518e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
519e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
520e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Incorrect parameter types; 2. Parameter verification failed.              |
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci**示例:**
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ci```ts
525e41f4b71Sopenharmony_ciconst callback = (systemBarTintState: window.SystemBarTintState) => {
526e41f4b71Sopenharmony_ci  // ...
527e41f4b71Sopenharmony_ci}
528e41f4b71Sopenharmony_citry {
529e41f4b71Sopenharmony_ci  window.on('systemBarTintChange', callback);
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci  window.off('systemBarTintChange', callback);
532e41f4b71Sopenharmony_ci  // 如果通过on开启多个callback进行监听,同时关闭所有监听:
533e41f4b71Sopenharmony_ci  window.off('systemBarTintChange');
534e41f4b71Sopenharmony_ci} catch (exception) {
535e41f4b71Sopenharmony_ci  console.error(`Failed to enable or disable the listener for systemBarTint changes. Cause code: ${exception.code}, message: ${exception.message}`);
536e41f4b71Sopenharmony_ci}
537e41f4b71Sopenharmony_ci```
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci## window.on('gestureNavigationEnabledChange')<sup>10+</sup>
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_cion(type: 'gestureNavigationEnabledChange', callback: Callback&lt;boolean&gt;): void
542e41f4b71Sopenharmony_ci
543e41f4b71Sopenharmony_ci添加手势导航启用状态变化的监听。
544e41f4b71Sopenharmony_ci
545e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
546e41f4b71Sopenharmony_ci
547e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
548e41f4b71Sopenharmony_ci
549e41f4b71Sopenharmony_ci**参数:**
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci| 参数名   | 类型                     | 必填 | 说明                                                                          |
552e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
553e41f4b71Sopenharmony_ci| type     | string                  | 是   | 监听事件,固定为'gestureNavigationEnabledChange',即手势导航启用状态变化事件。    |
554e41f4b71Sopenharmony_ci| callback | Callback&lt;boolean&gt; | 是   | 回调函数。返回当前手势导航的启用状态。true表示手势导航状态变化为启用;false表示手势导航状态变化为禁用。 |
555e41f4b71Sopenharmony_ci
556e41f4b71Sopenharmony_ci**错误码:**
557e41f4b71Sopenharmony_ci
558e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
559e41f4b71Sopenharmony_ci
560e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
561e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
562e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
563e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.               |
564e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
565e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
566e41f4b71Sopenharmony_ci
567e41f4b71Sopenharmony_ci**示例:**
568e41f4b71Sopenharmony_ci
569e41f4b71Sopenharmony_ci```ts
570e41f4b71Sopenharmony_citry {
571e41f4b71Sopenharmony_ci  window.on('gestureNavigationEnabledChange', (data) => {
572e41f4b71Sopenharmony_ci    console.info('Succeeded in enabling the listener for gesture navigation status changes. Data: ' + JSON.stringify(data));
573e41f4b71Sopenharmony_ci  });
574e41f4b71Sopenharmony_ci} catch (exception) {
575e41f4b71Sopenharmony_ci  console.error(`Failed to enable the listener for gesture navigation status changes. Cause code: ${exception.code}, message: ${exception.message}`);
576e41f4b71Sopenharmony_ci}
577e41f4b71Sopenharmony_ci```
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci## window.off('gestureNavigationEnabledChange')<sup>10+</sup>
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_cioff(type: 'gestureNavigationEnabledChange', callback?: Callback&lt;boolean&gt;): void
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ci移除手势导航启用状态变化的监听。
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ci**参数:**
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci| 参数名   | 类型                     | 必填 | 说明                                                        |
592e41f4b71Sopenharmony_ci| -------- | ----------------------- | -- | ------------------------------------------------------------ |
593e41f4b71Sopenharmony_ci| type     | string                  | 是 | 监听事件,固定为'gestureNavigationEnabledChange',即手势导航启用状态变化事件。 |
594e41f4b71Sopenharmony_ci| callback | Callback&lt;boolean&gt; | 否 | 已注册的回调函数。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有手势导航启用状态变化的监听。 |
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci**错误码:**
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
601e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
602e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
603e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Incorrect parameter types; 2. Parameter verification failed.               |
604e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
605e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci**示例:**
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci```ts
610e41f4b71Sopenharmony_ciconst callback = (bool: boolean) => {
611e41f4b71Sopenharmony_ci  // ...
612e41f4b71Sopenharmony_ci}
613e41f4b71Sopenharmony_citry {
614e41f4b71Sopenharmony_ci  window.on('gestureNavigationEnabledChange', callback);
615e41f4b71Sopenharmony_ci  window.off('gestureNavigationEnabledChange', callback);
616e41f4b71Sopenharmony_ci  // 如果通过on开启多个callback进行监听,同时关闭所有监听:
617e41f4b71Sopenharmony_ci  window.off('gestureNavigationEnabledChange');
618e41f4b71Sopenharmony_ci} catch (exception) {
619e41f4b71Sopenharmony_ci  console.error(`Failed to enable or disable the listener for gesture navigation status changes. Cause code: ${exception.code}, message: ${exception.message}`);
620e41f4b71Sopenharmony_ci}
621e41f4b71Sopenharmony_ci```
622e41f4b71Sopenharmony_ci
623e41f4b71Sopenharmony_ci## window.on('waterMarkFlagChange')<sup>10+</sup>
624e41f4b71Sopenharmony_ci
625e41f4b71Sopenharmony_cion(type: 'waterMarkFlagChange', callback: Callback&lt;boolean&gt;): void
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_ci添加水印启用状态变化的监听。
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_ci**参数:**
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci| 参数名   | 类型                     | 必填 | 说明                                                                          |
636e41f4b71Sopenharmony_ci| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
637e41f4b71Sopenharmony_ci| type     | string                  | 是   | 监听事件,固定为'waterMarkFlagChange',即水印启用状态变化事件。    |
638e41f4b71Sopenharmony_ci| callback | Callback&lt;boolean&gt; | 是   | 回调函数。返回当前水印的启用状态。true表示当前已启用水印;false表示当前未启用水印。 |
639e41f4b71Sopenharmony_ci
640e41f4b71Sopenharmony_ci**错误码:**
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
643e41f4b71Sopenharmony_ci
644e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
645e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
646e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
647e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.               |
648e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
649e41f4b71Sopenharmony_ci
650e41f4b71Sopenharmony_ci**示例:**
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci```ts
653e41f4b71Sopenharmony_citry {
654e41f4b71Sopenharmony_ci  window.on('waterMarkFlagChange', (data) => {
655e41f4b71Sopenharmony_ci    console.info('Succeeded in enabling the listener for watermark flag changes. Data: ' + JSON.stringify(data));
656e41f4b71Sopenharmony_ci  });
657e41f4b71Sopenharmony_ci} catch (exception) {
658e41f4b71Sopenharmony_ci  console.error(`Failed to enable the listener for watermark flag changes. Cause code: ${exception.code}, message: ${exception.message}`);
659e41f4b71Sopenharmony_ci}
660e41f4b71Sopenharmony_ci```
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci## window.off('waterMarkFlagChange')<sup>10+</sup>
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_cioff(type: 'waterMarkFlagChange', callback?: Callback&lt;boolean&gt;): void
665e41f4b71Sopenharmony_ci
666e41f4b71Sopenharmony_ci移除水印启用状态变化的监听。
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_ci**参数:**
673e41f4b71Sopenharmony_ci
674e41f4b71Sopenharmony_ci| 参数名   | 类型                     | 必填 | 说明                                                        |
675e41f4b71Sopenharmony_ci| -------- | ----------------------- | -- | ------------------------------------------------------------ |
676e41f4b71Sopenharmony_ci| type     | string                  | 是 | 监听事件,固定为'waterMarkFlagChange',即水印启用状态变化事件。 |
677e41f4b71Sopenharmony_ci| callback | Callback&lt;boolean&gt; | 否 | 已注册的回调函数。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有水印启用状态变化的监听。 |
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci**错误码:**
680e41f4b71Sopenharmony_ci
681e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
684e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
685e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
686e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Incorrect parameter types; 2. Parameter verification failed.               |
687e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci**示例:**
690e41f4b71Sopenharmony_ci
691e41f4b71Sopenharmony_ci```ts
692e41f4b71Sopenharmony_ciconst callback = (bool: boolean) => {
693e41f4b71Sopenharmony_ci  // ...
694e41f4b71Sopenharmony_ci}
695e41f4b71Sopenharmony_citry {
696e41f4b71Sopenharmony_ci  window.on('waterMarkFlagChange', callback);
697e41f4b71Sopenharmony_ci  window.off('waterMarkFlagChange', callback);
698e41f4b71Sopenharmony_ci  // 如果通过on开启多个callback进行监听,同时关闭所有监听:
699e41f4b71Sopenharmony_ci  window.off('waterMarkFlagChange');
700e41f4b71Sopenharmony_ci} catch (exception) {
701e41f4b71Sopenharmony_ci  console.error(`Failed to enable or disable the listener for watermark flag changes. Cause code: ${exception.code}, message: ${exception.message}`);
702e41f4b71Sopenharmony_ci}
703e41f4b71Sopenharmony_ci```
704e41f4b71Sopenharmony_ci
705e41f4b71Sopenharmony_ci## window.setGestureNavigationEnabled<sup>10+</sup>
706e41f4b71Sopenharmony_cisetGestureNavigationEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
707e41f4b71Sopenharmony_ci
708e41f4b71Sopenharmony_ci设置手势导航启用状态。使用callback异步回调。系统出于安全的考虑,不会干预手势的禁用和恢复。应用调用本接口禁用手势后异常退出的情况下,如果想要恢复手势,需自行实现自动拉起机制并再次调用本接口恢复手势。
709e41f4b71Sopenharmony_ci
710e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ci**参数:**
715e41f4b71Sopenharmony_ci
716e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明           |
717e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | -------------- |
718e41f4b71Sopenharmony_ci| enable   | boolean                  | 是   | 设置手势导航启用状态。true表示启用手势导航;false表示禁用手势导航。 |
719e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。 |
720e41f4b71Sopenharmony_ci
721e41f4b71Sopenharmony_ci**错误码:**
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
726e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
727e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
728e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
729e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                |
730e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
731e41f4b71Sopenharmony_ci
732e41f4b71Sopenharmony_ci**示例:**
733e41f4b71Sopenharmony_ci
734e41f4b71Sopenharmony_ci```ts
735e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_citry {
738e41f4b71Sopenharmony_ci  window.setGestureNavigationEnabled(true, (err: BusinessError) => {
739e41f4b71Sopenharmony_ci    const errCode: number = err.code;
740e41f4b71Sopenharmony_ci    if (errCode) {
741e41f4b71Sopenharmony_ci      console.error(`Failed to set gesture navigation enabled. Cause code: ${err.code}, message: ${err.message}`);
742e41f4b71Sopenharmony_ci      return;
743e41f4b71Sopenharmony_ci    }
744e41f4b71Sopenharmony_ci    console.info('Succeeded in setting gesture navigation enabled.');
745e41f4b71Sopenharmony_ci  });
746e41f4b71Sopenharmony_ci} catch (exception) {
747e41f4b71Sopenharmony_ci  console.error(`Failed to set gesture navigation enabled. Cause code: ${exception.code}, message: ${exception.message}`);
748e41f4b71Sopenharmony_ci}
749e41f4b71Sopenharmony_ci```
750e41f4b71Sopenharmony_ci
751e41f4b71Sopenharmony_ci## window.setGestureNavigationEnabled<sup>10+</sup>
752e41f4b71Sopenharmony_cisetGestureNavigationEnabled(enable: boolean): Promise&lt;void&gt;
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ci设置手势导航启用状态。使用Promise异步回调。系统出于安全的考虑,不会干预手势的禁用和恢复。应用调用本接口禁用手势后异常退出的情况下,如果想要恢复手势,需自行实现自动拉起机制并再次调用本接口恢复手势。
755e41f4b71Sopenharmony_ci
756e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
757e41f4b71Sopenharmony_ci
758e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_ci**参数:**
761e41f4b71Sopenharmony_ci
762e41f4b71Sopenharmony_ci| 参数名 | 类型     | 必填  | 说明                 |
763e41f4b71Sopenharmony_ci| ------ | ------- | ---- | -------------------- |
764e41f4b71Sopenharmony_ci| enable | boolean | 是   | 设置手势导航启用状态。true表示启用手势导航;false表示禁用手势导航。 |
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ci**返回值:**
767e41f4b71Sopenharmony_ci
768e41f4b71Sopenharmony_ci| 类型                | 说明                      |
769e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
770e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
771e41f4b71Sopenharmony_ci
772e41f4b71Sopenharmony_ci**错误码:**
773e41f4b71Sopenharmony_ci
774e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
775e41f4b71Sopenharmony_ci
776e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
777e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
778e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
779e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
780e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                |
781e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ci**示例:**
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_ci```ts
786e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
787e41f4b71Sopenharmony_ci
788e41f4b71Sopenharmony_citry {
789e41f4b71Sopenharmony_ci  let promise = window.setGestureNavigationEnabled(true);
790e41f4b71Sopenharmony_ci  promise.then(() => {
791e41f4b71Sopenharmony_ci    console.info('Succeeded in setting gesture navigation enabled.');
792e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
793e41f4b71Sopenharmony_ci    console.error(`Failed to set gesture navigation enabled. Cause code: ${err.code}, message: ${err.message}`);
794e41f4b71Sopenharmony_ci  });
795e41f4b71Sopenharmony_ci} catch (exception) {
796e41f4b71Sopenharmony_ci  console.error(`Failed to set gesture navigation enabled. Cause code: ${exception.code}, message: ${exception.message}`);
797e41f4b71Sopenharmony_ci}
798e41f4b71Sopenharmony_ci```
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_ci## window.setWaterMarkImage<sup>10+</sup>
801e41f4b71Sopenharmony_cisetWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback&lt;void&gt;): void
802e41f4b71Sopenharmony_ci
803e41f4b71Sopenharmony_ci设置水印图片显示状态。使用callback异步回调。
804e41f4b71Sopenharmony_ci
805e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
806e41f4b71Sopenharmony_ci
807e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_ci**参数:**
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明           |
812e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | -------------- |
813e41f4b71Sopenharmony_ci| pixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | 是 | 水印图片。 |
814e41f4b71Sopenharmony_ci| enable   | boolean                  | 是   | 设置是否显示水印图片。true显示水印图片;false表示不显示水印图片。 |
815e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。 |
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ci**错误码:**
818e41f4b71Sopenharmony_ci
819e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
820e41f4b71Sopenharmony_ci
821e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
822e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
823e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
824e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
825e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
826e41f4b71Sopenharmony_ci
827e41f4b71Sopenharmony_ci**示例:**
828e41f4b71Sopenharmony_ci
829e41f4b71Sopenharmony_ci```ts
830e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
831e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
832e41f4b71Sopenharmony_ci
833e41f4b71Sopenharmony_cilet enable: boolean = true;
834e41f4b71Sopenharmony_cilet color: ArrayBuffer = new ArrayBuffer(0);
835e41f4b71Sopenharmony_cilet initializationOptions: image.InitializationOptions = {
836e41f4b71Sopenharmony_ci  size: {
837e41f4b71Sopenharmony_ci    height: 100,
838e41f4b71Sopenharmony_ci    width: 100
839e41f4b71Sopenharmony_ci  }
840e41f4b71Sopenharmony_ci};
841e41f4b71Sopenharmony_ciimage.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => {
842e41f4b71Sopenharmony_ci  console.info('Succeeded in creating pixelmap.');
843e41f4b71Sopenharmony_ci  try {
844e41f4b71Sopenharmony_ci    window.setWaterMarkImage(pixelMap, enable, (err: BusinessError) => {
845e41f4b71Sopenharmony_ci      const errCode: number = err.code;
846e41f4b71Sopenharmony_ci      if (errCode) {
847e41f4b71Sopenharmony_ci        console.error(`Failed to show watermark image. Cause code: ${err.code}, message: ${err.message}`);
848e41f4b71Sopenharmony_ci        return;
849e41f4b71Sopenharmony_ci      }
850e41f4b71Sopenharmony_ci      console.info('Succeeded in showing watermark image.');
851e41f4b71Sopenharmony_ci    });
852e41f4b71Sopenharmony_ci  } catch (exception) {
853e41f4b71Sopenharmony_ci    console.error(`Failed to show watermark image. Cause code: ${exception.code}, message: ${exception.message}`);
854e41f4b71Sopenharmony_ci  }
855e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
856e41f4b71Sopenharmony_ci  console.error(`Failed to create PixelMap. Cause code: ${err.code}, message: ${err.message}`);
857e41f4b71Sopenharmony_ci});
858e41f4b71Sopenharmony_ci```
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_ci## window.setWaterMarkImage<sup>10+</sup>
861e41f4b71Sopenharmony_cisetWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise&lt;void&gt;
862e41f4b71Sopenharmony_ci
863e41f4b71Sopenharmony_ci设置水印图片显示状态。使用Promise异步回调。
864e41f4b71Sopenharmony_ci
865e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
866e41f4b71Sopenharmony_ci
867e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
868e41f4b71Sopenharmony_ci
869e41f4b71Sopenharmony_ci**参数:**
870e41f4b71Sopenharmony_ci
871e41f4b71Sopenharmony_ci| 参数名 | 类型                        | 必填  | 说明                 |
872e41f4b71Sopenharmony_ci| ------ | --------------------------- | ---- | -------------------- |
873e41f4b71Sopenharmony_ci| pixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | 是 | 水印图片。 |
874e41f4b71Sopenharmony_ci| enable   | boolean                  | 是   | 设置是否显示水印图片。true显示水印图片;false表示不显示水印图片。 |
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci**返回值:**
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci| 类型                | 说明                      |
879e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
880e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci**错误码:**
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
887e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
888e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
889e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
890e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_ci**示例:**
893e41f4b71Sopenharmony_ci
894e41f4b71Sopenharmony_ci```ts
895e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
896e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_cilet enable: boolean = true;
899e41f4b71Sopenharmony_cilet color: ArrayBuffer = new ArrayBuffer(0);
900e41f4b71Sopenharmony_cilet initializationOptions: image.InitializationOptions = {
901e41f4b71Sopenharmony_ci  size: {
902e41f4b71Sopenharmony_ci    height: 100,
903e41f4b71Sopenharmony_ci    width: 100
904e41f4b71Sopenharmony_ci  }
905e41f4b71Sopenharmony_ci};
906e41f4b71Sopenharmony_ciimage.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => {
907e41f4b71Sopenharmony_ci  console.info('Succeeded in creating pixelmap.');
908e41f4b71Sopenharmony_ci  try {
909e41f4b71Sopenharmony_ci    let promise = window.setWaterMarkImage(pixelMap, enable);
910e41f4b71Sopenharmony_ci    promise.then(() => {
911e41f4b71Sopenharmony_ci      console.info('Succeeded in showing watermark image.');
912e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
913e41f4b71Sopenharmony_ci      console.error(`Failed to show watermark image. Cause code: ${err.code}, message: ${err.message}`);
914e41f4b71Sopenharmony_ci    });
915e41f4b71Sopenharmony_ci  } catch (exception) {
916e41f4b71Sopenharmony_ci    console.error(`Failed to show watermark image. Cause code: ${exception.code}, message: ${exception.message}`);
917e41f4b71Sopenharmony_ci  }
918e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
919e41f4b71Sopenharmony_ci  console.error(`Failed to create PixelMap. Cause code: ${err.code}, message: ${err.message}`);
920e41f4b71Sopenharmony_ci});
921e41f4b71Sopenharmony_ci```
922e41f4b71Sopenharmony_ci
923e41f4b71Sopenharmony_ci## window.getSnapshot<sup>12+</sup>
924e41f4b71Sopenharmony_ci
925e41f4b71Sopenharmony_cigetSnapshot(windowId: number): Promise<image.PixelMap>
926e41f4b71Sopenharmony_ci
927e41f4b71Sopenharmony_ci获取指定窗口截图,使用Promise异步回调
928e41f4b71Sopenharmony_ci
929e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
930e41f4b71Sopenharmony_ci
931e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
932e41f4b71Sopenharmony_ci
933e41f4b71Sopenharmony_ci**参数:**
934e41f4b71Sopenharmony_ci| 参数名   | 类型   | 必填  | 说明         |
935e41f4b71Sopenharmony_ci| -------- | ------ | ----- | ------------ |
936e41f4b71Sopenharmony_ci| windowId | number | 是    | 窗口Id。可通过[getWindowProperties](js-apis-window.md#getwindowproperties9)接口获取到相关窗口属性,其中属性id即对应为窗口ID。 |
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_ci**返回值:**
939e41f4b71Sopenharmony_ci| 类型                    | 说明                            |
940e41f4b71Sopenharmony_ci| ----------------------- | ------------------------------- |
941e41f4b71Sopenharmony_ci| Promise<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | Promise对象。返回指定窗口截图。 |
942e41f4b71Sopenharmony_ci
943e41f4b71Sopenharmony_ci**错误码:**
944e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
945e41f4b71Sopenharmony_ci
946e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                     |
947e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
948e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
949e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
950e41f4b71Sopenharmony_ci| 1300002  | This window state is abnormal.                |
951e41f4b71Sopenharmony_ci| 1300003  | This window manager service works abnormally. |
952e41f4b71Sopenharmony_ci| 1300004  | This operation is not accessible.             |
953e41f4b71Sopenharmony_ci
954e41f4b71Sopenharmony_ci**示例:**
955e41f4b71Sopenharmony_ci```ts
956e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
957e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
958e41f4b71Sopenharmony_ci
959e41f4b71Sopenharmony_citry {
960e41f4b71Sopenharmony_ci  // 此处仅示意,请使用getWindowProperties获取对应窗口ID再进行使用
961e41f4b71Sopenharmony_ci  let windowId: number = 40;
962e41f4b71Sopenharmony_ci  let promise = window.getSnapshot(windowId);
963e41f4b71Sopenharmony_ci  promise.then((pixelMap: image.PixelMap) => {
964e41f4b71Sopenharmony_ci    console.info('Succeeded in getting snapshot window. Pixel bytes number:' + pixelMap.getPixelBytesNumber());
965e41f4b71Sopenharmony_ci    pixelMap.release();
966e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) =>{
967e41f4b71Sopenharmony_ci    console.error(`Failed to get snapshot. Cause code: ${err.code}, message: ${err.message}`);
968e41f4b71Sopenharmony_ci  });
969e41f4b71Sopenharmony_ci} catch (exception) {
970e41f4b71Sopenharmony_ci  console.error(`Failed to get snapshot. Cause code: ${exception.code}, message: ${exception.message}`);
971e41f4b71Sopenharmony_ci}
972e41f4b71Sopenharmony_ci```
973e41f4b71Sopenharmony_ci
974e41f4b71Sopenharmony_ci## window.getVisibleWindowInfo<sup>12+</sup>
975e41f4b71Sopenharmony_ci
976e41f4b71Sopenharmony_cigetVisibleWindowInfo(): Promise&lt;Array&lt;WindowInfo&gt;&gt;
977e41f4b71Sopenharmony_ci
978e41f4b71Sopenharmony_ci获取当前屏幕的可见窗口(未退至后台的窗口)信息。
979e41f4b71Sopenharmony_ci
980e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
981e41f4b71Sopenharmony_ci
982e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
983e41f4b71Sopenharmony_ci
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci**返回值:**
986e41f4b71Sopenharmony_ci
987e41f4b71Sopenharmony_ci| 类型 | 说明 |
988e41f4b71Sopenharmony_ci| ------------------- | ----------------------- |
989e41f4b71Sopenharmony_ci| Promise&lt;[WindowInfo](#windowinfo12)&gt; | Promise对象,返回当前可见窗口的相关信息。 |
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ci**错误码:**
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
996e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
997e41f4b71Sopenharmony_ci| 202     | Permission verification failed, non-system application uses system API. |
998e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
999e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1000e41f4b71Sopenharmony_ci
1001e41f4b71Sopenharmony_ci**示例:**
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci```ts
1004e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
1005e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1006e41f4b71Sopenharmony_ci
1007e41f4b71Sopenharmony_cilet promise = window.getVisibleWindowInfo();
1008e41f4b71Sopenharmony_cipromise.then((data) => {
1009e41f4b71Sopenharmony_ci  data.forEach(windowInfo=>{
1010e41f4b71Sopenharmony_ci    console.info(`left:${windowInfo.rect.left}`);
1011e41f4b71Sopenharmony_ci    console.info(`top:${windowInfo.rect.top}`);
1012e41f4b71Sopenharmony_ci    console.info(`width:${windowInfo.rect.width}`);
1013e41f4b71Sopenharmony_ci    console.info(`height:${windowInfo.rect.height}`);
1014e41f4b71Sopenharmony_ci    console.info(`windowId:${windowInfo.windowId}`);
1015e41f4b71Sopenharmony_ci    console.info(`windowStatusType:${windowInfo.windowStatusType}`);
1016e41f4b71Sopenharmony_ci    console.info(`abilityName:${windowInfo.abilityName}`);
1017e41f4b71Sopenharmony_ci    console.info(`bundleName:${windowInfo.bundleName}`);
1018e41f4b71Sopenharmony_ci  })
1019e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1020e41f4b71Sopenharmony_ci  console.error('Failed to getWindowInfo. Cause: ' + JSON.stringify(err));
1021e41f4b71Sopenharmony_ci});
1022e41f4b71Sopenharmony_ci```
1023e41f4b71Sopenharmony_ci
1024e41f4b71Sopenharmony_ci## Window
1025e41f4b71Sopenharmony_ci
1026e41f4b71Sopenharmony_ci当前窗口实例,窗口管理器管理的基本单元。
1027e41f4b71Sopenharmony_ci
1028e41f4b71Sopenharmony_ci下列API示例中都需先使用[getLastWindow()](js-apis-window.md#windowgetlastwindow9)、[createWindow()](js-apis-window.md#windowcreatewindow9)、[findWindow()](js-apis-window.md#windowfindwindow9)中的任一方法获取到Window实例(windowClass),再通过此实例调用对应方法。
1029e41f4b71Sopenharmony_ci
1030e41f4b71Sopenharmony_ci### hide<sup>7+</sup>
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_cihide (callback: AsyncCallback&lt;void&gt;): void
1033e41f4b71Sopenharmony_ci
1034e41f4b71Sopenharmony_ci隐藏当前窗口,使用callback异步回调,仅支持系统窗口与应用子窗口。
1035e41f4b71Sopenharmony_ci
1036e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1037e41f4b71Sopenharmony_ci
1038e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1039e41f4b71Sopenharmony_ci
1040e41f4b71Sopenharmony_ci**参数:**
1041e41f4b71Sopenharmony_ci
1042e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
1043e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
1044e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1045e41f4b71Sopenharmony_ci
1046e41f4b71Sopenharmony_ci**错误码:**
1047e41f4b71Sopenharmony_ci
1048e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1049e41f4b71Sopenharmony_ci
1050e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1051e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
1052e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1053e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
1054e41f4b71Sopenharmony_ci
1055e41f4b71Sopenharmony_ci**示例:**
1056e41f4b71Sopenharmony_ci
1057e41f4b71Sopenharmony_ci```ts
1058e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1059e41f4b71Sopenharmony_ci
1060e41f4b71Sopenharmony_ciwindowClass.hide((err: BusinessError) => {
1061e41f4b71Sopenharmony_ci  const errCode: number = err.code;
1062e41f4b71Sopenharmony_ci  if (errCode) {
1063e41f4b71Sopenharmony_ci    console.error(`Failed to hide the window. Cause code: ${err.code}, message: ${err.message}`);
1064e41f4b71Sopenharmony_ci    return;
1065e41f4b71Sopenharmony_ci  }
1066e41f4b71Sopenharmony_ci  console.info('Succeeded in hiding the window.');
1067e41f4b71Sopenharmony_ci});
1068e41f4b71Sopenharmony_ci```
1069e41f4b71Sopenharmony_ci
1070e41f4b71Sopenharmony_ci### hide<sup>7+</sup>
1071e41f4b71Sopenharmony_ci
1072e41f4b71Sopenharmony_cihide(): Promise&lt;void&gt;
1073e41f4b71Sopenharmony_ci
1074e41f4b71Sopenharmony_ci隐藏当前窗口,使用Promise异步回调,仅支持系统窗口与应用子窗口。
1075e41f4b71Sopenharmony_ci
1076e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1077e41f4b71Sopenharmony_ci
1078e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ci**返回值:**
1081e41f4b71Sopenharmony_ci
1082e41f4b71Sopenharmony_ci| 类型                | 说明                      |
1083e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1084e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci**错误码:**
1087e41f4b71Sopenharmony_ci
1088e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1089e41f4b71Sopenharmony_ci
1090e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1091e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
1092e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1093e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
1094e41f4b71Sopenharmony_ci
1095e41f4b71Sopenharmony_ci**示例:**
1096e41f4b71Sopenharmony_ci
1097e41f4b71Sopenharmony_ci```ts
1098e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_cilet promise = windowClass.hide();
1101e41f4b71Sopenharmony_cipromise.then(() => {
1102e41f4b71Sopenharmony_ci  console.info('Succeeded in hiding the window.');
1103e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1104e41f4b71Sopenharmony_ci  console.error(`Failed to hide the window. Cause code: ${err.code}, message: ${err.message}`);
1105e41f4b71Sopenharmony_ci});
1106e41f4b71Sopenharmony_ci```
1107e41f4b71Sopenharmony_ci
1108e41f4b71Sopenharmony_ci### hideWithAnimation<sup>9+</sup>
1109e41f4b71Sopenharmony_ci
1110e41f4b71Sopenharmony_cihideWithAnimation(callback: AsyncCallback&lt;void&gt;): void
1111e41f4b71Sopenharmony_ci
1112e41f4b71Sopenharmony_ci隐藏当前窗口,过程中播放动画,使用callback异步回调,仅支持系统窗口。
1113e41f4b71Sopenharmony_ci
1114e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1115e41f4b71Sopenharmony_ci
1116e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1117e41f4b71Sopenharmony_ci
1118e41f4b71Sopenharmony_ci**参数:**
1119e41f4b71Sopenharmony_ci
1120e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
1121e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
1122e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1123e41f4b71Sopenharmony_ci
1124e41f4b71Sopenharmony_ci**错误码:**
1125e41f4b71Sopenharmony_ci
1126e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1127e41f4b71Sopenharmony_ci
1128e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1129e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1130e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1131e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1132e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1133e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.                |
1134e41f4b71Sopenharmony_ci
1135e41f4b71Sopenharmony_ci**示例:**
1136e41f4b71Sopenharmony_ci
1137e41f4b71Sopenharmony_ci```ts
1138e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1139e41f4b71Sopenharmony_ci
1140e41f4b71Sopenharmony_ciwindowClass.hideWithAnimation((err: BusinessError) => {
1141e41f4b71Sopenharmony_ci  const errCode: number = err.code;
1142e41f4b71Sopenharmony_ci  if (errCode) {
1143e41f4b71Sopenharmony_ci    console.error(`Failed to hide the window with animation. Cause code: ${err.code}, message: ${err.message}`);
1144e41f4b71Sopenharmony_ci    return;
1145e41f4b71Sopenharmony_ci  }
1146e41f4b71Sopenharmony_ci  console.info('Succeeded in hiding the window with animation.');
1147e41f4b71Sopenharmony_ci});
1148e41f4b71Sopenharmony_ci```
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_ci### hideWithAnimation<sup>9+</sup>
1151e41f4b71Sopenharmony_ci
1152e41f4b71Sopenharmony_cihideWithAnimation(): Promise&lt;void&gt;
1153e41f4b71Sopenharmony_ci
1154e41f4b71Sopenharmony_ci隐藏当前窗口,过程中播放动画,使用Promise异步回调,仅支持系统窗口。
1155e41f4b71Sopenharmony_ci
1156e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1159e41f4b71Sopenharmony_ci
1160e41f4b71Sopenharmony_ci**返回值:**
1161e41f4b71Sopenharmony_ci
1162e41f4b71Sopenharmony_ci| 类型                | 说明                      |
1163e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1164e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1165e41f4b71Sopenharmony_ci
1166e41f4b71Sopenharmony_ci**错误码:**
1167e41f4b71Sopenharmony_ci
1168e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1169e41f4b71Sopenharmony_ci
1170e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1171e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1172e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1173e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1174e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1175e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.                |
1176e41f4b71Sopenharmony_ci
1177e41f4b71Sopenharmony_ci**示例:**
1178e41f4b71Sopenharmony_ci
1179e41f4b71Sopenharmony_ci```ts
1180e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1181e41f4b71Sopenharmony_ci
1182e41f4b71Sopenharmony_cilet promise = windowClass.hideWithAnimation();
1183e41f4b71Sopenharmony_cipromise.then(() => {
1184e41f4b71Sopenharmony_ci  console.info('Succeeded in hiding the window with animation.');
1185e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1186e41f4b71Sopenharmony_ci  console.error(`Failed to hide the window with animation. Cause code: ${err.code}, message: ${err.message}`);
1187e41f4b71Sopenharmony_ci});
1188e41f4b71Sopenharmony_ci```
1189e41f4b71Sopenharmony_ci
1190e41f4b71Sopenharmony_ci### showWithAnimation<sup>9+</sup>
1191e41f4b71Sopenharmony_ci
1192e41f4b71Sopenharmony_cishowWithAnimation(callback: AsyncCallback&lt;void&gt;): void
1193e41f4b71Sopenharmony_ci
1194e41f4b71Sopenharmony_ci显示当前窗口,过程中播放动画,使用callback异步回调,仅支持系统窗口。
1195e41f4b71Sopenharmony_ci
1196e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1197e41f4b71Sopenharmony_ci
1198e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1199e41f4b71Sopenharmony_ci
1200e41f4b71Sopenharmony_ci**参数:**
1201e41f4b71Sopenharmony_ci
1202e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
1203e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
1204e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1205e41f4b71Sopenharmony_ci
1206e41f4b71Sopenharmony_ci**错误码:**
1207e41f4b71Sopenharmony_ci
1208e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1209e41f4b71Sopenharmony_ci
1210e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1211e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1212e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1213e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1214e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1215e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.                |
1216e41f4b71Sopenharmony_ci
1217e41f4b71Sopenharmony_ci**示例:**
1218e41f4b71Sopenharmony_ci
1219e41f4b71Sopenharmony_ci```ts
1220e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1221e41f4b71Sopenharmony_ci
1222e41f4b71Sopenharmony_ciwindowClass.showWithAnimation((err: BusinessError) => {
1223e41f4b71Sopenharmony_ci  const errCode: number = err.code;
1224e41f4b71Sopenharmony_ci  if (errCode) {
1225e41f4b71Sopenharmony_ci    console.error(`Failed to show the window with animation. Cause code: ${err.code}, message: ${err.message}`);
1226e41f4b71Sopenharmony_ci    return;
1227e41f4b71Sopenharmony_ci  }
1228e41f4b71Sopenharmony_ci  console.info('Succeeded in showing the window with animation.');
1229e41f4b71Sopenharmony_ci});
1230e41f4b71Sopenharmony_ci```
1231e41f4b71Sopenharmony_ci
1232e41f4b71Sopenharmony_ci### showWithAnimation<sup>9+</sup>
1233e41f4b71Sopenharmony_ci
1234e41f4b71Sopenharmony_cishowWithAnimation(): Promise&lt;void&gt;
1235e41f4b71Sopenharmony_ci
1236e41f4b71Sopenharmony_ci显示当前窗口,过程中播放动画,使用Promise异步回调,仅支持系统窗口。
1237e41f4b71Sopenharmony_ci
1238e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1239e41f4b71Sopenharmony_ci
1240e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1241e41f4b71Sopenharmony_ci
1242e41f4b71Sopenharmony_ci**返回值:**
1243e41f4b71Sopenharmony_ci
1244e41f4b71Sopenharmony_ci| 类型                | 说明                      |
1245e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1246e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1247e41f4b71Sopenharmony_ci
1248e41f4b71Sopenharmony_ci**错误码:**
1249e41f4b71Sopenharmony_ci
1250e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1251e41f4b71Sopenharmony_ci
1252e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1253e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1254e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1255e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1256e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1257e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.                |
1258e41f4b71Sopenharmony_ci
1259e41f4b71Sopenharmony_ci**示例:**
1260e41f4b71Sopenharmony_ci
1261e41f4b71Sopenharmony_ci```ts
1262e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1263e41f4b71Sopenharmony_ci
1264e41f4b71Sopenharmony_cilet promise = windowClass.showWithAnimation();
1265e41f4b71Sopenharmony_cipromise.then(() => {
1266e41f4b71Sopenharmony_ci  console.info('Succeeded in showing the window with animation.');
1267e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1268e41f4b71Sopenharmony_ci  console.error(`Failed to show the window with animation. Cause code: ${err.code}, message: ${err.message}`);
1269e41f4b71Sopenharmony_ci});
1270e41f4b71Sopenharmony_ci```
1271e41f4b71Sopenharmony_ci
1272e41f4b71Sopenharmony_ci### setWindowMode<sup>9+</sup>
1273e41f4b71Sopenharmony_ci
1274e41f4b71Sopenharmony_cisetWindowMode(mode: WindowMode, callback: AsyncCallback&lt;void&gt;): void
1275e41f4b71Sopenharmony_ci
1276e41f4b71Sopenharmony_ci设置主窗口模式,使用callback异步回调。
1277e41f4b71Sopenharmony_ci
1278e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1279e41f4b71Sopenharmony_ci
1280e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1281e41f4b71Sopenharmony_ci
1282e41f4b71Sopenharmony_ci**参数:**
1283e41f4b71Sopenharmony_ci
1284e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 |
1285e41f4b71Sopenharmony_ci| -------- | -------------------------- | -- | --------- |
1286e41f4b71Sopenharmony_ci| mode     | [WindowMode](#windowmode7) | 是 | 窗口模式。 |
1287e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;  | 是 | 回调函数。 |
1288e41f4b71Sopenharmony_ci
1289e41f4b71Sopenharmony_ci**错误码:**
1290e41f4b71Sopenharmony_ci
1291e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1292e41f4b71Sopenharmony_ci
1293e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1294e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1295e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1296e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1297e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1298e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1299e41f4b71Sopenharmony_ci
1300e41f4b71Sopenharmony_ci**示例:**
1301e41f4b71Sopenharmony_ci
1302e41f4b71Sopenharmony_ci```ts
1303e41f4b71Sopenharmony_ci// EntryAbility.ets
1304e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
1305e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1306e41f4b71Sopenharmony_ci
1307e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
1308e41f4b71Sopenharmony_ci  // ...
1309e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
1310e41f4b71Sopenharmony_ci    console.info('onWindowStageCreate');
1311e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
1312e41f4b71Sopenharmony_ci    windowStage.getMainWindow((err: BusinessError, data) => {
1313e41f4b71Sopenharmony_ci      const errCode: number = err.code;
1314e41f4b71Sopenharmony_ci      if (errCode) {
1315e41f4b71Sopenharmony_ci        console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
1316e41f4b71Sopenharmony_ci        return;
1317e41f4b71Sopenharmony_ci      }
1318e41f4b71Sopenharmony_ci      windowClass = data;
1319e41f4b71Sopenharmony_ci      let mode = window.WindowMode.FULLSCREEN;
1320e41f4b71Sopenharmony_ci      try {
1321e41f4b71Sopenharmony_ci        windowClass.setWindowMode(mode, (err: BusinessError) => {
1322e41f4b71Sopenharmony_ci          const errCode: number = err.code;
1323e41f4b71Sopenharmony_ci          if (errCode) {
1324e41f4b71Sopenharmony_ci            console.error(`Failed to set the window mode. Cause code: ${err.code}, message: ${err.message}`);
1325e41f4b71Sopenharmony_ci            return;
1326e41f4b71Sopenharmony_ci          }
1327e41f4b71Sopenharmony_ci          console.info('Succeeded in setting the window mode.');
1328e41f4b71Sopenharmony_ci        });
1329e41f4b71Sopenharmony_ci      } catch (exception) {
1330e41f4b71Sopenharmony_ci        console.error(`Failed to set the window mode. Cause code: ${exception.code}, message: ${exception.message}`);
1331e41f4b71Sopenharmony_ci      }
1332e41f4b71Sopenharmony_ci    });
1333e41f4b71Sopenharmony_ci  }
1334e41f4b71Sopenharmony_ci}
1335e41f4b71Sopenharmony_ci```
1336e41f4b71Sopenharmony_ci
1337e41f4b71Sopenharmony_ci### setWindowMode<sup>9+</sup>
1338e41f4b71Sopenharmony_ci
1339e41f4b71Sopenharmony_cisetWindowMode(mode: WindowMode): Promise&lt;void&gt;
1340e41f4b71Sopenharmony_ci
1341e41f4b71Sopenharmony_ci设置主窗口模式,使用Promise异步回调。
1342e41f4b71Sopenharmony_ci
1343e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1344e41f4b71Sopenharmony_ci
1345e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1346e41f4b71Sopenharmony_ci
1347e41f4b71Sopenharmony_ci**参数:**
1348e41f4b71Sopenharmony_ci
1349e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 |
1350e41f4b71Sopenharmony_ci| -------- | -------------------------- | -- | --------- |
1351e41f4b71Sopenharmony_ci| mode     | [WindowMode](#windowmode7) | 是 | 窗口模式。 |
1352e41f4b71Sopenharmony_ci
1353e41f4b71Sopenharmony_ci**返回值:**
1354e41f4b71Sopenharmony_ci
1355e41f4b71Sopenharmony_ci| 类型 | 说明 |
1356e41f4b71Sopenharmony_ci| ------------------- | ----------------------- |
1357e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1358e41f4b71Sopenharmony_ci
1359e41f4b71Sopenharmony_ci**错误码:**
1360e41f4b71Sopenharmony_ci
1361e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1362e41f4b71Sopenharmony_ci
1363e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1364e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1365e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1366e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1367e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1368e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1369e41f4b71Sopenharmony_ci
1370e41f4b71Sopenharmony_ci**示例:**
1371e41f4b71Sopenharmony_ci
1372e41f4b71Sopenharmony_ci```ts
1373e41f4b71Sopenharmony_ci// EntryAbility.ets
1374e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
1375e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1376e41f4b71Sopenharmony_ci
1377e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
1378e41f4b71Sopenharmony_ci  // ...
1379e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
1380e41f4b71Sopenharmony_ci    console.info('onWindowStageCreate');
1381e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
1382e41f4b71Sopenharmony_ci    windowStage.getMainWindow((err: BusinessError, data) => {
1383e41f4b71Sopenharmony_ci      const errCode: number = err.code;
1384e41f4b71Sopenharmony_ci      if (errCode) {
1385e41f4b71Sopenharmony_ci        console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
1386e41f4b71Sopenharmony_ci        return;
1387e41f4b71Sopenharmony_ci      }
1388e41f4b71Sopenharmony_ci      windowClass = data;
1389e41f4b71Sopenharmony_ci      let mode = window.WindowMode.FULLSCREEN;
1390e41f4b71Sopenharmony_ci      try {
1391e41f4b71Sopenharmony_ci        let promise = windowClass.setWindowMode(mode);
1392e41f4b71Sopenharmony_ci        promise.then(() => {
1393e41f4b71Sopenharmony_ci          console.info('Succeeded in setting the window mode.');
1394e41f4b71Sopenharmony_ci        }).catch((err: BusinessError) => {
1395e41f4b71Sopenharmony_ci          console.error(`Failed to set the window mode. Cause code: ${err.code}, message: ${err.message}`);
1396e41f4b71Sopenharmony_ci        });
1397e41f4b71Sopenharmony_ci      } catch (exception) {
1398e41f4b71Sopenharmony_ci        console.error(`Failed to set the window mode. Cause code: ${exception.code}, message: ${exception.message}`);
1399e41f4b71Sopenharmony_ci      }
1400e41f4b71Sopenharmony_ci    });
1401e41f4b71Sopenharmony_ci  }
1402e41f4b71Sopenharmony_ci}
1403e41f4b71Sopenharmony_ci```
1404e41f4b71Sopenharmony_ci
1405e41f4b71Sopenharmony_ci### bindDialogTarget<sup>9+</sup>
1406e41f4b71Sopenharmony_ci
1407e41f4b71Sopenharmony_cibindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;, callback: AsyncCallback&lt;void&gt;): void
1408e41f4b71Sopenharmony_ci
1409e41f4b71Sopenharmony_ci绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。
1410e41f4b71Sopenharmony_ci
1411e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1412e41f4b71Sopenharmony_ci
1413e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1414e41f4b71Sopenharmony_ci
1415e41f4b71Sopenharmony_ci**参数:**
1416e41f4b71Sopenharmony_ci
1417e41f4b71Sopenharmony_ci| 参数名       | 类型                      | 必填 | 说明                  |
1418e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | -------------------- |
1419e41f4b71Sopenharmony_ci| token       | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | 是   | 目标窗口token值。 |
1420e41f4b71Sopenharmony_ci| deathCallback | Callback&lt;void&gt;        | 是   | 模态窗口销毁监听。 |
1421e41f4b71Sopenharmony_ci| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1422e41f4b71Sopenharmony_ci
1423e41f4b71Sopenharmony_ci**错误码:**
1424e41f4b71Sopenharmony_ci
1425e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1426e41f4b71Sopenharmony_ci
1427e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1428e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1429e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1430e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: Incorrect parameter types. |
1431e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1432e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1433e41f4b71Sopenharmony_ci
1434e41f4b71Sopenharmony_ci**示例:**
1435e41f4b71Sopenharmony_ci
1436e41f4b71Sopenharmony_ci```ts
1437e41f4b71Sopenharmony_ciimport { rpc } from '@kit.IPCKit';
1438e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1439e41f4b71Sopenharmony_ci
1440e41f4b71Sopenharmony_ciclass MyDeathRecipient {
1441e41f4b71Sopenharmony_ci  onRemoteDied() {
1442e41f4b71Sopenharmony_ci    console.log('server died');
1443e41f4b71Sopenharmony_ci  }
1444e41f4b71Sopenharmony_ci}
1445e41f4b71Sopenharmony_ci
1446e41f4b71Sopenharmony_ciclass TestRemoteObject extends rpc.RemoteObject {
1447e41f4b71Sopenharmony_ci  constructor(descriptor: string) {
1448e41f4b71Sopenharmony_ci    super(descriptor);
1449e41f4b71Sopenharmony_ci  }
1450e41f4b71Sopenharmony_ci
1451e41f4b71Sopenharmony_ci  addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
1452e41f4b71Sopenharmony_ci    return true;
1453e41f4b71Sopenharmony_ci  }
1454e41f4b71Sopenharmony_ci
1455e41f4b71Sopenharmony_ci  removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
1456e41f4b71Sopenharmony_ci    return true;
1457e41f4b71Sopenharmony_ci  }
1458e41f4b71Sopenharmony_ci
1459e41f4b71Sopenharmony_ci  isObjectDead(): boolean {
1460e41f4b71Sopenharmony_ci    return false;
1461e41f4b71Sopenharmony_ci  }
1462e41f4b71Sopenharmony_ci}
1463e41f4b71Sopenharmony_ci
1464e41f4b71Sopenharmony_cilet token: TestRemoteObject = new TestRemoteObject('testObject');
1465e41f4b71Sopenharmony_cilet windowClass: window.Window | undefined = undefined;
1466e41f4b71Sopenharmony_cilet config: window.Configuration = { name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context };
1467e41f4b71Sopenharmony_citry {
1468e41f4b71Sopenharmony_ci  window.createWindow(config, (err: BusinessError, data) => {
1469e41f4b71Sopenharmony_ci    let errCode: number = err.code;
1470e41f4b71Sopenharmony_ci    if (errCode) {
1471e41f4b71Sopenharmony_ci      console.error(`Failed to create the window. Cause code: ${err.code}, message: ${err.message}`);
1472e41f4b71Sopenharmony_ci      return;
1473e41f4b71Sopenharmony_ci    }
1474e41f4b71Sopenharmony_ci    windowClass = data;
1475e41f4b71Sopenharmony_ci  });
1476e41f4b71Sopenharmony_ci  windowClass.bindDialogTarget(token, () => {
1477e41f4b71Sopenharmony_ci    console.info('Dialog Window Need Destroy.');
1478e41f4b71Sopenharmony_ci  }, (err: BusinessError) => {
1479e41f4b71Sopenharmony_ci    let errCode: number = err.code;
1480e41f4b71Sopenharmony_ci    if (errCode) {
1481e41f4b71Sopenharmony_ci      console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`);
1482e41f4b71Sopenharmony_ci      return;
1483e41f4b71Sopenharmony_ci    }
1484e41f4b71Sopenharmony_ci    console.info('Succeeded in binding dialog target.');
1485e41f4b71Sopenharmony_ci  });
1486e41f4b71Sopenharmony_ci} catch (exception) {
1487e41f4b71Sopenharmony_ci  console.error(`Failed to bind dialog target. Cause code: ${exception.code}, message: ${exception.message}`);
1488e41f4b71Sopenharmony_ci}
1489e41f4b71Sopenharmony_ci```
1490e41f4b71Sopenharmony_ci
1491e41f4b71Sopenharmony_ci### bindDialogTarget<sup>9+</sup>
1492e41f4b71Sopenharmony_ci
1493e41f4b71Sopenharmony_cibindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;): Promise&lt;void&gt;
1494e41f4b71Sopenharmony_ci
1495e41f4b71Sopenharmony_ci绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。
1496e41f4b71Sopenharmony_ci
1497e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1498e41f4b71Sopenharmony_ci
1499e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1500e41f4b71Sopenharmony_ci
1501e41f4b71Sopenharmony_ci**参数:**
1502e41f4b71Sopenharmony_ci
1503e41f4b71Sopenharmony_ci| 参数名       | 类型                      | 必填 | 说明                  |
1504e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | -------------------- |
1505e41f4b71Sopenharmony_ci| token       | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | 是   | 目标窗口token值。 |
1506e41f4b71Sopenharmony_ci| deathCallback | Callback&lt;void&gt;        | 是   | 模态窗口销毁监听。 |
1507e41f4b71Sopenharmony_ci
1508e41f4b71Sopenharmony_ci**返回值:**
1509e41f4b71Sopenharmony_ci
1510e41f4b71Sopenharmony_ci| 类型                | 说明                      |
1511e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1512e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1513e41f4b71Sopenharmony_ci
1514e41f4b71Sopenharmony_ci**错误码:**
1515e41f4b71Sopenharmony_ci
1516e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1517e41f4b71Sopenharmony_ci
1518e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1519e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1520e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1521e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: Incorrect parameter types. |
1522e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1523e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1524e41f4b71Sopenharmony_ci
1525e41f4b71Sopenharmony_ci**示例:**
1526e41f4b71Sopenharmony_ci
1527e41f4b71Sopenharmony_ci```ts
1528e41f4b71Sopenharmony_ciimport { rpc } from '@kit.IPCKit';
1529e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1530e41f4b71Sopenharmony_ci
1531e41f4b71Sopenharmony_ciclass MyDeathRecipient {
1532e41f4b71Sopenharmony_ci  onRemoteDied() {
1533e41f4b71Sopenharmony_ci    console.log('server died');
1534e41f4b71Sopenharmony_ci  }
1535e41f4b71Sopenharmony_ci}
1536e41f4b71Sopenharmony_ci
1537e41f4b71Sopenharmony_ciclass TestRemoteObject extends rpc.RemoteObject {
1538e41f4b71Sopenharmony_ci  constructor(descriptor: string) {
1539e41f4b71Sopenharmony_ci    super(descriptor);
1540e41f4b71Sopenharmony_ci  }
1541e41f4b71Sopenharmony_ci
1542e41f4b71Sopenharmony_ci  addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
1543e41f4b71Sopenharmony_ci    return true;
1544e41f4b71Sopenharmony_ci  }
1545e41f4b71Sopenharmony_ci
1546e41f4b71Sopenharmony_ci  removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
1547e41f4b71Sopenharmony_ci    return true;
1548e41f4b71Sopenharmony_ci  }
1549e41f4b71Sopenharmony_ci
1550e41f4b71Sopenharmony_ci  isObjectDead(): boolean {
1551e41f4b71Sopenharmony_ci    return false;
1552e41f4b71Sopenharmony_ci  }
1553e41f4b71Sopenharmony_ci}
1554e41f4b71Sopenharmony_ci
1555e41f4b71Sopenharmony_cilet token: TestRemoteObject = new TestRemoteObject('testObject');
1556e41f4b71Sopenharmony_cilet windowClass: window.Window | undefined = undefined;
1557e41f4b71Sopenharmony_cilet config: window.Configuration = {
1558e41f4b71Sopenharmony_ci  name: "test",
1559e41f4b71Sopenharmony_ci  windowType: window.WindowType.TYPE_DIALOG,
1560e41f4b71Sopenharmony_ci  ctx: this.context
1561e41f4b71Sopenharmony_ci};
1562e41f4b71Sopenharmony_citry {
1563e41f4b71Sopenharmony_ci  window.createWindow(config, (err: BusinessError, data) => {
1564e41f4b71Sopenharmony_ci    const errCode: number = err.code;
1565e41f4b71Sopenharmony_ci    if (errCode) {
1566e41f4b71Sopenharmony_ci      console.error(`Failed to create the window. Cause code: ${err.code}, message: ${err.message}`);
1567e41f4b71Sopenharmony_ci      return;
1568e41f4b71Sopenharmony_ci    }
1569e41f4b71Sopenharmony_ci    windowClass = data;
1570e41f4b71Sopenharmony_ci  });
1571e41f4b71Sopenharmony_ci  let promise = windowClass.bindDialogTarget(token, () => {
1572e41f4b71Sopenharmony_ci    console.info('Dialog Window Need Destroy.');
1573e41f4b71Sopenharmony_ci  });
1574e41f4b71Sopenharmony_ci  promise.then(() => {
1575e41f4b71Sopenharmony_ci    console.info('Succeeded in binding dialog target.');
1576e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1577e41f4b71Sopenharmony_ci    console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`);
1578e41f4b71Sopenharmony_ci  });
1579e41f4b71Sopenharmony_ci} catch (exception) {
1580e41f4b71Sopenharmony_ci  console.error(`Failed to bind dialog target. Cause code: ${exception.code}, message: ${exception.message}`);
1581e41f4b71Sopenharmony_ci}
1582e41f4b71Sopenharmony_ci```
1583e41f4b71Sopenharmony_ci
1584e41f4b71Sopenharmony_ci### bindDialogTarget<sup>9+</sup>
1585e41f4b71Sopenharmony_ci
1586e41f4b71Sopenharmony_cibindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback&lt;void&gt;, callback: AsyncCallback&lt;void&gt;): void
1587e41f4b71Sopenharmony_ci
1588e41f4b71Sopenharmony_ci绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。
1589e41f4b71Sopenharmony_ci
1590e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1591e41f4b71Sopenharmony_ci
1592e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1593e41f4b71Sopenharmony_ci
1594e41f4b71Sopenharmony_ci**参数:**
1595e41f4b71Sopenharmony_ci
1596e41f4b71Sopenharmony_ci| 参数名       | 类型                      | 必填 | 说明                  |
1597e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | -------------------- |
1598e41f4b71Sopenharmony_ci| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | 是   | 目标窗口RequestInfo值。 |
1599e41f4b71Sopenharmony_ci| deathCallback | Callback&lt;void&gt;    | 是   | 模态窗口销毁监听。 |
1600e41f4b71Sopenharmony_ci| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1601e41f4b71Sopenharmony_ci
1602e41f4b71Sopenharmony_ci**错误码:**
1603e41f4b71Sopenharmony_ci
1604e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1605e41f4b71Sopenharmony_ci
1606e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1607e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1608e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1609e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: Incorrect parameter types. |
1610e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1611e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1612e41f4b71Sopenharmony_ci
1613e41f4b71Sopenharmony_ci**示例:**
1614e41f4b71Sopenharmony_ci
1615e41f4b71Sopenharmony_ci```ts
1616e41f4b71Sopenharmony_ciimport { dialogRequest, Want, ServiceExtensionAbility } from '@kit.AbilityKit';
1617e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1618e41f4b71Sopenharmony_ci
1619e41f4b71Sopenharmony_ciexport default class ServiceExtAbility extends ServiceExtensionAbility {
1620e41f4b71Sopenharmony_ci  onRequest(want: Want, startId: number) {
1621e41f4b71Sopenharmony_ci    console.info('onRequest');
1622e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
1623e41f4b71Sopenharmony_ci    let config: window.Configuration = {
1624e41f4b71Sopenharmony_ci      name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context
1625e41f4b71Sopenharmony_ci    };
1626e41f4b71Sopenharmony_ci    try {
1627e41f4b71Sopenharmony_ci      window.createWindow(config, (err: BusinessError, data) => {
1628e41f4b71Sopenharmony_ci        let errCode: number = err.code;
1629e41f4b71Sopenharmony_ci        if (errCode) {
1630e41f4b71Sopenharmony_ci          console.error(`Failed to create the window. Cause code: ${err.code}, message: ${err.message}`);
1631e41f4b71Sopenharmony_ci          return;
1632e41f4b71Sopenharmony_ci        }
1633e41f4b71Sopenharmony_ci        windowClass = data;
1634e41f4b71Sopenharmony_ci      });
1635e41f4b71Sopenharmony_ci      let requestInfo = dialogRequest.getRequestInfo(want)
1636e41f4b71Sopenharmony_ci      windowClass.bindDialogTarget(requestInfo, () => {
1637e41f4b71Sopenharmony_ci        console.info('Dialog Window Need Destroy.');
1638e41f4b71Sopenharmony_ci      }, (err: BusinessError) => {
1639e41f4b71Sopenharmony_ci        let errCode: number = err.code;
1640e41f4b71Sopenharmony_ci        if (errCode) {
1641e41f4b71Sopenharmony_ci          console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`);
1642e41f4b71Sopenharmony_ci          return;
1643e41f4b71Sopenharmony_ci        }
1644e41f4b71Sopenharmony_ci        console.info('Succeeded in binding dialog target.');
1645e41f4b71Sopenharmony_ci      });
1646e41f4b71Sopenharmony_ci    } catch (err) {
1647e41f4b71Sopenharmony_ci      console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`)
1648e41f4b71Sopenharmony_ci    }
1649e41f4b71Sopenharmony_ci  }
1650e41f4b71Sopenharmony_ci}
1651e41f4b71Sopenharmony_ci```
1652e41f4b71Sopenharmony_ci
1653e41f4b71Sopenharmony_ci### bindDialogTarget<sup>9+</sup>
1654e41f4b71Sopenharmony_ci
1655e41f4b71Sopenharmony_cibindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback&lt;void&gt;): Promise&lt;void&gt;
1656e41f4b71Sopenharmony_ci
1657e41f4b71Sopenharmony_ci绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。
1658e41f4b71Sopenharmony_ci
1659e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1660e41f4b71Sopenharmony_ci
1661e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1662e41f4b71Sopenharmony_ci
1663e41f4b71Sopenharmony_ci**参数:**
1664e41f4b71Sopenharmony_ci
1665e41f4b71Sopenharmony_ci| 参数名       | 类型                      | 必填 | 说明                  |
1666e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | -------------------- |
1667e41f4b71Sopenharmony_ci| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | 是   | 目标窗口RequestInfo值。 |
1668e41f4b71Sopenharmony_ci| deathCallback | Callback&lt;void&gt;    | 是   | 模态窗口销毁监听。 |
1669e41f4b71Sopenharmony_ci
1670e41f4b71Sopenharmony_ci**返回值:**
1671e41f4b71Sopenharmony_ci
1672e41f4b71Sopenharmony_ci| 类型                | 说明                      |
1673e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1674e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1675e41f4b71Sopenharmony_ci
1676e41f4b71Sopenharmony_ci**错误码:**
1677e41f4b71Sopenharmony_ci
1678e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1679e41f4b71Sopenharmony_ci
1680e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1681e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1682e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1683e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: Incorrect parameter types. |
1684e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1685e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1686e41f4b71Sopenharmony_ci
1687e41f4b71Sopenharmony_ci**示例:**
1688e41f4b71Sopenharmony_ci
1689e41f4b71Sopenharmony_ci```ts
1690e41f4b71Sopenharmony_ciimport { dialogRequest, Want, ServiceExtensionAbility } from '@kit.AbilityKit';
1691e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1692e41f4b71Sopenharmony_ci
1693e41f4b71Sopenharmony_ciexport default class ServiceExtAbility extends ServiceExtensionAbility {
1694e41f4b71Sopenharmony_ci  onRequest(want: Want, startId: number) {
1695e41f4b71Sopenharmony_ci    console.info('onRequest');
1696e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
1697e41f4b71Sopenharmony_ci    let config: window.Configuration = {
1698e41f4b71Sopenharmony_ci      name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context
1699e41f4b71Sopenharmony_ci    };
1700e41f4b71Sopenharmony_ci    try {
1701e41f4b71Sopenharmony_ci      window.createWindow(config, (err: BusinessError, data) => {
1702e41f4b71Sopenharmony_ci        const errCode: number = err.code;
1703e41f4b71Sopenharmony_ci        if (errCode) {
1704e41f4b71Sopenharmony_ci          console.error(`Failed to create the window. Cause code: ${err.code}, message: ${err.message}`);
1705e41f4b71Sopenharmony_ci          return;
1706e41f4b71Sopenharmony_ci        }
1707e41f4b71Sopenharmony_ci        windowClass = data;
1708e41f4b71Sopenharmony_ci      });
1709e41f4b71Sopenharmony_ci      let requestInfo = dialogRequest.getRequestInfo(want)
1710e41f4b71Sopenharmony_ci      let promise = windowClass.bindDialogTarget(requestInfo, () => {
1711e41f4b71Sopenharmony_ci        console.info('Dialog Window Need Destroy.');
1712e41f4b71Sopenharmony_ci      });
1713e41f4b71Sopenharmony_ci      promise.then(() => {
1714e41f4b71Sopenharmony_ci        console.info('Succeeded in binding dialog target.');
1715e41f4b71Sopenharmony_ci      }).catch((err: BusinessError) => {
1716e41f4b71Sopenharmony_ci        console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`);
1717e41f4b71Sopenharmony_ci      });
1718e41f4b71Sopenharmony_ci    } catch (err) {
1719e41f4b71Sopenharmony_ci      console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`)
1720e41f4b71Sopenharmony_ci    }
1721e41f4b71Sopenharmony_ci  }
1722e41f4b71Sopenharmony_ci}
1723e41f4b71Sopenharmony_ci```
1724e41f4b71Sopenharmony_ci
1725e41f4b71Sopenharmony_ci### setWakeUpScreen<sup>9+</sup>
1726e41f4b71Sopenharmony_ci
1727e41f4b71Sopenharmony_cisetWakeUpScreen(wakeUp: boolean): void
1728e41f4b71Sopenharmony_ci
1729e41f4b71Sopenharmony_ci窗口唤醒屏幕。
1730e41f4b71Sopenharmony_ci
1731e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1732e41f4b71Sopenharmony_ci
1733e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1734e41f4b71Sopenharmony_ci
1735e41f4b71Sopenharmony_ci**参数:**
1736e41f4b71Sopenharmony_ci
1737e41f4b71Sopenharmony_ci| 参数名           | 类型    | 必填 | 说明                         |
1738e41f4b71Sopenharmony_ci| ---------------- | ------- | ---- | ---------------------------- |
1739e41f4b71Sopenharmony_ci| wakeUp           | boolean | 是   | 是否设置唤醒屏幕。true表示唤醒;false表示不唤醒。  |
1740e41f4b71Sopenharmony_ci
1741e41f4b71Sopenharmony_ci**错误码:**
1742e41f4b71Sopenharmony_ci
1743e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1744e41f4b71Sopenharmony_ci
1745e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1746e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1747e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1748e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1749e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1750e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1751e41f4b71Sopenharmony_ci
1752e41f4b71Sopenharmony_ci**示例:**
1753e41f4b71Sopenharmony_ci
1754e41f4b71Sopenharmony_ci```ts
1755e41f4b71Sopenharmony_cilet wakeUp: boolean = true;
1756e41f4b71Sopenharmony_citry {
1757e41f4b71Sopenharmony_ci  windowClass.setWakeUpScreen(wakeUp);
1758e41f4b71Sopenharmony_ci} catch (exception) {
1759e41f4b71Sopenharmony_ci  console.error(`Failed to wake up the screen. Cause code: ${exception.code}, message: ${exception.message}`);
1760e41f4b71Sopenharmony_ci}
1761e41f4b71Sopenharmony_ci```
1762e41f4b71Sopenharmony_ci
1763e41f4b71Sopenharmony_ci### setSnapshotSkip<sup>9+</sup>
1764e41f4b71Sopenharmony_cisetSnapshotSkip(isSkip: boolean): void
1765e41f4b71Sopenharmony_ci
1766e41f4b71Sopenharmony_ci截屏录屏是否忽略当前窗口。此接口一般用于禁止截屏/录屏的场景。
1767e41f4b71Sopenharmony_ci
1768e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1769e41f4b71Sopenharmony_ci
1770e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1771e41f4b71Sopenharmony_ci
1772e41f4b71Sopenharmony_ci**参数:**
1773e41f4b71Sopenharmony_ci
1774e41f4b71Sopenharmony_ci| 参数名        | 类型    | 必填 | 说明                 |
1775e41f4b71Sopenharmony_ci| ------------- | ------- | ---- | -------------------- |
1776e41f4b71Sopenharmony_ci| isSkip | boolean | 是   | 截屏录屏是否忽略当前窗口,默认为false。<br>true表示忽略当前窗口,false表示不忽略当前窗口。</br> |
1777e41f4b71Sopenharmony_ci
1778e41f4b71Sopenharmony_ci**错误码:**
1779e41f4b71Sopenharmony_ci
1780e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1781e41f4b71Sopenharmony_ci
1782e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1783e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
1784e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1785e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1786e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
1787e41f4b71Sopenharmony_ci
1788e41f4b71Sopenharmony_ci```ts
1789e41f4b71Sopenharmony_cilet isSkip: boolean = true;
1790e41f4b71Sopenharmony_citry {
1791e41f4b71Sopenharmony_ci  windowClass.setSnapshotSkip(isSkip);
1792e41f4b71Sopenharmony_ci} catch (exception) {
1793e41f4b71Sopenharmony_ci  console.error(`Failed to Skip. Cause code: ${exception.code}, message: ${exception.message}`);
1794e41f4b71Sopenharmony_ci}
1795e41f4b71Sopenharmony_ci```
1796e41f4b71Sopenharmony_ci
1797e41f4b71Sopenharmony_ci### setForbidSplitMove<sup>9+</sup>
1798e41f4b71Sopenharmony_ci
1799e41f4b71Sopenharmony_cisetForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&gt;): void
1800e41f4b71Sopenharmony_ci
1801e41f4b71Sopenharmony_ci设置主窗口在分屏模式下是否被禁止移动,使用callback异步回调。
1802e41f4b71Sopenharmony_ci
1803e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1804e41f4b71Sopenharmony_ci
1805e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1806e41f4b71Sopenharmony_ci
1807e41f4b71Sopenharmony_ci**参数:**
1808e41f4b71Sopenharmony_ci
1809e41f4b71Sopenharmony_ci| 参数名      | 类型                      | 必填 | 说明                 |
1810e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | -------------------- |
1811e41f4b71Sopenharmony_ci| isForbidSplitMove | boolean                   | 是   | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 |
1812e41f4b71Sopenharmony_ci| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
1813e41f4b71Sopenharmony_ci
1814e41f4b71Sopenharmony_ci**错误码:**
1815e41f4b71Sopenharmony_ci
1816e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1817e41f4b71Sopenharmony_ci
1818e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1819e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1820e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1821e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1822e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1823e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1824e41f4b71Sopenharmony_ci
1825e41f4b71Sopenharmony_ci**示例:**
1826e41f4b71Sopenharmony_ci
1827e41f4b71Sopenharmony_ci```ts
1828e41f4b71Sopenharmony_ci// EntryAbility.ets
1829e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
1830e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1831e41f4b71Sopenharmony_ci
1832e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
1833e41f4b71Sopenharmony_ci  // ...
1834e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
1835e41f4b71Sopenharmony_ci    console.info('onWindowStageCreate');
1836e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
1837e41f4b71Sopenharmony_ci    windowStage.getMainWindow((err: BusinessError, data) => {
1838e41f4b71Sopenharmony_ci      const errCode: number = err.code;
1839e41f4b71Sopenharmony_ci      if (errCode) {
1840e41f4b71Sopenharmony_ci        console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
1841e41f4b71Sopenharmony_ci        return;
1842e41f4b71Sopenharmony_ci      }
1843e41f4b71Sopenharmony_ci      windowClass = data;
1844e41f4b71Sopenharmony_ci      let isForbidSplitMove: boolean = true;
1845e41f4b71Sopenharmony_ci      try {
1846e41f4b71Sopenharmony_ci        windowClass.setForbidSplitMove(isForbidSplitMove, (err: BusinessError) => {
1847e41f4b71Sopenharmony_ci          const errCode: number = err.code;
1848e41f4b71Sopenharmony_ci          if (errCode) {
1849e41f4b71Sopenharmony_ci            console.error(`Failed to forbid window moving in split screen mode. Cause code: ${err.code}, message: ${err.message}`);
1850e41f4b71Sopenharmony_ci            return;
1851e41f4b71Sopenharmony_ci          }
1852e41f4b71Sopenharmony_ci          console.info('Succeeded in forbidding window moving in split screen mode.');
1853e41f4b71Sopenharmony_ci        });
1854e41f4b71Sopenharmony_ci      } catch (exception) {
1855e41f4b71Sopenharmony_ci        console.error(`Failed to forbid window moving in split screen mode. Cause code: ${exception.code}, message: ${exception.message}`);
1856e41f4b71Sopenharmony_ci      }
1857e41f4b71Sopenharmony_ci    });
1858e41f4b71Sopenharmony_ci  }
1859e41f4b71Sopenharmony_ci}
1860e41f4b71Sopenharmony_ci```
1861e41f4b71Sopenharmony_ci
1862e41f4b71Sopenharmony_ci### setForbidSplitMove<sup>9+</sup>
1863e41f4b71Sopenharmony_ci
1864e41f4b71Sopenharmony_cisetForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt;
1865e41f4b71Sopenharmony_ci
1866e41f4b71Sopenharmony_ci设置主窗口在分屏模式下是否被禁止移动,使用Promise异步回调。
1867e41f4b71Sopenharmony_ci
1868e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1869e41f4b71Sopenharmony_ci
1870e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1871e41f4b71Sopenharmony_ci
1872e41f4b71Sopenharmony_ci**参数:**
1873e41f4b71Sopenharmony_ci
1874e41f4b71Sopenharmony_ci| 参数名      | 类型    | 必填 | 说明                 |
1875e41f4b71Sopenharmony_ci| ----------- | ------- | ---- | -------------------- |
1876e41f4b71Sopenharmony_ci| isForbidSplitMove | boolean | 是   | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 |
1877e41f4b71Sopenharmony_ci
1878e41f4b71Sopenharmony_ci**返回值:**
1879e41f4b71Sopenharmony_ci
1880e41f4b71Sopenharmony_ci| 类型                | 说明                      |
1881e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1882e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1883e41f4b71Sopenharmony_ci
1884e41f4b71Sopenharmony_ci**错误码:**
1885e41f4b71Sopenharmony_ci
1886e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1887e41f4b71Sopenharmony_ci
1888e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1889e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1890e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1891e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
1892e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.               |
1893e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
1894e41f4b71Sopenharmony_ci
1895e41f4b71Sopenharmony_ci**示例:**
1896e41f4b71Sopenharmony_ci
1897e41f4b71Sopenharmony_ci```ts
1898e41f4b71Sopenharmony_ci// EntryAbility.ets
1899e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
1900e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1901e41f4b71Sopenharmony_ci
1902e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
1903e41f4b71Sopenharmony_ci  // ...
1904e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
1905e41f4b71Sopenharmony_ci    console.info('onWindowStageCreate');
1906e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
1907e41f4b71Sopenharmony_ci    windowStage.getMainWindow((err: BusinessError, data) => {
1908e41f4b71Sopenharmony_ci      const errCode: number = err.code;
1909e41f4b71Sopenharmony_ci      if (errCode) {
1910e41f4b71Sopenharmony_ci        console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
1911e41f4b71Sopenharmony_ci        return;
1912e41f4b71Sopenharmony_ci      }
1913e41f4b71Sopenharmony_ci      windowClass = data;
1914e41f4b71Sopenharmony_ci      let isForbidSplitMove: boolean = true;
1915e41f4b71Sopenharmony_ci      try {
1916e41f4b71Sopenharmony_ci        let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
1917e41f4b71Sopenharmony_ci        promise.then(() => {
1918e41f4b71Sopenharmony_ci          console.info('Succeeded in forbidding window moving in split screen mode.');
1919e41f4b71Sopenharmony_ci        }).catch((err: BusinessError) => {
1920e41f4b71Sopenharmony_ci          console.error(`Failed to forbid window moving in split screen mode. Cause code: ${err.code}, message: ${err.message}`);
1921e41f4b71Sopenharmony_ci        });
1922e41f4b71Sopenharmony_ci      } catch (exception) {
1923e41f4b71Sopenharmony_ci        console.error(`Failed to forbid window moving in split screen mode. Cause code: ${exception.code}, message: ${exception.message}`);
1924e41f4b71Sopenharmony_ci      }
1925e41f4b71Sopenharmony_ci    });
1926e41f4b71Sopenharmony_ci  }
1927e41f4b71Sopenharmony_ci}
1928e41f4b71Sopenharmony_ci```
1929e41f4b71Sopenharmony_ci
1930e41f4b71Sopenharmony_ci### opacity<sup>9+</sup>
1931e41f4b71Sopenharmony_ci
1932e41f4b71Sopenharmony_ciopacity(opacity: number): void
1933e41f4b71Sopenharmony_ci
1934e41f4b71Sopenharmony_ci设置窗口不透明度。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
1935e41f4b71Sopenharmony_ci
1936e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1937e41f4b71Sopenharmony_ci
1938e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1939e41f4b71Sopenharmony_ci
1940e41f4b71Sopenharmony_ci**参数:**
1941e41f4b71Sopenharmony_ci
1942e41f4b71Sopenharmony_ci| 参数名  | 类型   | 必填 | 说明                                                 |
1943e41f4b71Sopenharmony_ci| ------- | ------ | ---- |----------------------------------------------------|
1944e41f4b71Sopenharmony_ci| opacity | number | 是   | 不透明度。该参数为浮点数,取值范围为[0.0, 1.0]。0.0表示完全透明,1.0表示完全不透明。 |
1945e41f4b71Sopenharmony_ci
1946e41f4b71Sopenharmony_ci**错误码:**
1947e41f4b71Sopenharmony_ci
1948e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1949e41f4b71Sopenharmony_ci
1950e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1951e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
1952e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1953e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1954e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
1955e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
1956e41f4b71Sopenharmony_ci
1957e41f4b71Sopenharmony_ci**示例:**
1958e41f4b71Sopenharmony_ci
1959e41f4b71Sopenharmony_ci```ts
1960e41f4b71Sopenharmony_citry {
1961e41f4b71Sopenharmony_ci  windowClass.opacity(0.5);
1962e41f4b71Sopenharmony_ci} catch (exception) {
1963e41f4b71Sopenharmony_ci  console.error(`Failed to opacity. Cause code: ${exception.code}, message: ${exception.message}`);
1964e41f4b71Sopenharmony_ci}
1965e41f4b71Sopenharmony_ci```
1966e41f4b71Sopenharmony_ci
1967e41f4b71Sopenharmony_ci### scale<sup>9+</sup>
1968e41f4b71Sopenharmony_ci
1969e41f4b71Sopenharmony_ciscale(scaleOptions: ScaleOptions): void
1970e41f4b71Sopenharmony_ci
1971e41f4b71Sopenharmony_ci设置窗口缩放参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
1972e41f4b71Sopenharmony_ci
1973e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1974e41f4b71Sopenharmony_ci
1975e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1976e41f4b71Sopenharmony_ci
1977e41f4b71Sopenharmony_ci**参数:**
1978e41f4b71Sopenharmony_ci
1979e41f4b71Sopenharmony_ci| 参数名       | 类型                           | 必填 | 说明       |
1980e41f4b71Sopenharmony_ci| ------------ | ------------------------------ | ---- | ---------- |
1981e41f4b71Sopenharmony_ci| scaleOptions | [ScaleOptions](#scaleoptions9) | 是   | 缩放参数。 |
1982e41f4b71Sopenharmony_ci
1983e41f4b71Sopenharmony_ci**错误码:**
1984e41f4b71Sopenharmony_ci
1985e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
1986e41f4b71Sopenharmony_ci
1987e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
1988e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
1989e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
1990e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1991e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
1992e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
1993e41f4b71Sopenharmony_ci
1994e41f4b71Sopenharmony_ci**示例:**
1995e41f4b71Sopenharmony_ci
1996e41f4b71Sopenharmony_ci```ts
1997e41f4b71Sopenharmony_cilet obj: window.ScaleOptions = {
1998e41f4b71Sopenharmony_ci  x: 2.0,
1999e41f4b71Sopenharmony_ci  y: 1.0,
2000e41f4b71Sopenharmony_ci  pivotX: 0.5,
2001e41f4b71Sopenharmony_ci  pivotY: 0.5
2002e41f4b71Sopenharmony_ci};
2003e41f4b71Sopenharmony_citry {
2004e41f4b71Sopenharmony_ci  windowClass.scale(obj);
2005e41f4b71Sopenharmony_ci} catch (exception) {
2006e41f4b71Sopenharmony_ci  console.error(`Failed to scale. Cause code: ${exception.code}, message: ${exception.message}`);
2007e41f4b71Sopenharmony_ci}
2008e41f4b71Sopenharmony_ci```
2009e41f4b71Sopenharmony_ci
2010e41f4b71Sopenharmony_ci### rotate<sup>9+</sup>
2011e41f4b71Sopenharmony_ci
2012e41f4b71Sopenharmony_cirotate(rotateOptions: RotateOptions): void
2013e41f4b71Sopenharmony_ci
2014e41f4b71Sopenharmony_ci设置窗口旋转参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
2015e41f4b71Sopenharmony_ci
2016e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2017e41f4b71Sopenharmony_ci
2018e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2019e41f4b71Sopenharmony_ci
2020e41f4b71Sopenharmony_ci**参数:**
2021e41f4b71Sopenharmony_ci
2022e41f4b71Sopenharmony_ci| 参数名        | 类型                             | 必填 | 说明       |
2023e41f4b71Sopenharmony_ci| ------------- | -------------------------------- | ---- | ---------- |
2024e41f4b71Sopenharmony_ci| rotateOptions | [RotateOptions](#rotateoptions9) | 是   | 旋转参数。 |
2025e41f4b71Sopenharmony_ci
2026e41f4b71Sopenharmony_ci**错误码:**
2027e41f4b71Sopenharmony_ci
2028e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2029e41f4b71Sopenharmony_ci
2030e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2031e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2032e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2033e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2034e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2035e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
2036e41f4b71Sopenharmony_ci
2037e41f4b71Sopenharmony_ci**示例:**
2038e41f4b71Sopenharmony_ci
2039e41f4b71Sopenharmony_ci```ts
2040e41f4b71Sopenharmony_cilet obj: window.RotateOptions = {
2041e41f4b71Sopenharmony_ci  x: 1.0,
2042e41f4b71Sopenharmony_ci  y: 1.0,
2043e41f4b71Sopenharmony_ci  z: 45.0,
2044e41f4b71Sopenharmony_ci  pivotX: 0.5,
2045e41f4b71Sopenharmony_ci  pivotY: 0.5
2046e41f4b71Sopenharmony_ci};
2047e41f4b71Sopenharmony_citry {
2048e41f4b71Sopenharmony_ci  windowClass.rotate(obj);
2049e41f4b71Sopenharmony_ci} catch (exception) {
2050e41f4b71Sopenharmony_ci  console.error(`Failed to rotate. Cause code: ${exception.code}, message: ${exception.message}`);
2051e41f4b71Sopenharmony_ci}
2052e41f4b71Sopenharmony_ci```
2053e41f4b71Sopenharmony_ci
2054e41f4b71Sopenharmony_ci### translate<sup>9+</sup>
2055e41f4b71Sopenharmony_ci
2056e41f4b71Sopenharmony_citranslate(translateOptions: TranslateOptions): void
2057e41f4b71Sopenharmony_ci
2058e41f4b71Sopenharmony_ci设置窗口平移参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
2059e41f4b71Sopenharmony_ci
2060e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2061e41f4b71Sopenharmony_ci
2062e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2063e41f4b71Sopenharmony_ci
2064e41f4b71Sopenharmony_ci**参数:**
2065e41f4b71Sopenharmony_ci
2066e41f4b71Sopenharmony_ci| 参数名           | 类型                                   | 必填 | 说明                 |
2067e41f4b71Sopenharmony_ci| ---------------- | -------------------------------------- | ---- | -------------------- |
2068e41f4b71Sopenharmony_ci| translateOptions | [TranslateOptions](#translateoptions9) | 是   | 平移参数,单位为px。 |
2069e41f4b71Sopenharmony_ci
2070e41f4b71Sopenharmony_ci**错误码:**
2071e41f4b71Sopenharmony_ci
2072e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2073e41f4b71Sopenharmony_ci
2074e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2075e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2076e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2077e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2078e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2079e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
2080e41f4b71Sopenharmony_ci
2081e41f4b71Sopenharmony_ci**示例:**
2082e41f4b71Sopenharmony_ci
2083e41f4b71Sopenharmony_ci```ts
2084e41f4b71Sopenharmony_cilet obj: window.TranslateOptions = {
2085e41f4b71Sopenharmony_ci  x: 100.0,
2086e41f4b71Sopenharmony_ci  y: 0.0,
2087e41f4b71Sopenharmony_ci  z: 0.0
2088e41f4b71Sopenharmony_ci};
2089e41f4b71Sopenharmony_citry {
2090e41f4b71Sopenharmony_ci  windowClass.translate(obj);
2091e41f4b71Sopenharmony_ci} catch (exception) {
2092e41f4b71Sopenharmony_ci  console.error(`Failed to translate. Cause code: ${exception.code}, message: ${exception.message}`);
2093e41f4b71Sopenharmony_ci}
2094e41f4b71Sopenharmony_ci```
2095e41f4b71Sopenharmony_ci
2096e41f4b71Sopenharmony_ci### getTransitionController<sup>9+</sup>
2097e41f4b71Sopenharmony_ci
2098e41f4b71Sopenharmony_ci getTransitionController(): TransitionController
2099e41f4b71Sopenharmony_ci
2100e41f4b71Sopenharmony_ci获取窗口属性转换控制器。
2101e41f4b71Sopenharmony_ci
2102e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2103e41f4b71Sopenharmony_ci
2104e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2105e41f4b71Sopenharmony_ci
2106e41f4b71Sopenharmony_ci**返回值:**
2107e41f4b71Sopenharmony_ci
2108e41f4b71Sopenharmony_ci| 类型                                           | 说明             |
2109e41f4b71Sopenharmony_ci| ---------------------------------------------- | ---------------- |
2110e41f4b71Sopenharmony_ci| [TransitionController](#transitioncontroller9) | 属性转换控制器。 |
2111e41f4b71Sopenharmony_ci
2112e41f4b71Sopenharmony_ci**错误码:**
2113e41f4b71Sopenharmony_ci
2114e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2115e41f4b71Sopenharmony_ci
2116e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2117e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2118e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2119e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2120e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
2121e41f4b71Sopenharmony_ci
2122e41f4b71Sopenharmony_ci**示例:**
2123e41f4b71Sopenharmony_ci
2124e41f4b71Sopenharmony_ci```ts
2125e41f4b71Sopenharmony_cilet controller = windowClass.getTransitionController(); // 获取属性转换控制器
2126e41f4b71Sopenharmony_ci```
2127e41f4b71Sopenharmony_ci
2128e41f4b71Sopenharmony_ci### setBlur<sup>9+</sup>
2129e41f4b71Sopenharmony_ci
2130e41f4b71Sopenharmony_cisetBlur(radius: number): void
2131e41f4b71Sopenharmony_ci
2132e41f4b71Sopenharmony_ci设置窗口模糊。
2133e41f4b71Sopenharmony_ci
2134e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2135e41f4b71Sopenharmony_ci
2136e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2137e41f4b71Sopenharmony_ci
2138e41f4b71Sopenharmony_ci**参数:**
2139e41f4b71Sopenharmony_ci
2140e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                               |
2141e41f4b71Sopenharmony_ci| ------ | ------ | ---- |--------------------------------------------------|
2142e41f4b71Sopenharmony_ci| radius | number | 是   | 表示窗口模糊的半径值。该参数为浮点数,单位为px,取值范围为[0, +∞),取值为0.0时表示关闭窗口模糊。 |
2143e41f4b71Sopenharmony_ci
2144e41f4b71Sopenharmony_ci**错误码:**
2145e41f4b71Sopenharmony_ci
2146e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2147e41f4b71Sopenharmony_ci
2148e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2149e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2150e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2151e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2152e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2153e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
2154e41f4b71Sopenharmony_ci
2155e41f4b71Sopenharmony_ci**示例:**
2156e41f4b71Sopenharmony_ci
2157e41f4b71Sopenharmony_ci```ts
2158e41f4b71Sopenharmony_citry {
2159e41f4b71Sopenharmony_ci  windowClass.setBlur(4.0);
2160e41f4b71Sopenharmony_ci} catch (exception) {
2161e41f4b71Sopenharmony_ci  console.error(`Failed to set blur. Cause code: ${exception.code}, message: ${exception.message}`);
2162e41f4b71Sopenharmony_ci}
2163e41f4b71Sopenharmony_ci```
2164e41f4b71Sopenharmony_ci
2165e41f4b71Sopenharmony_ci### setBackdropBlur<sup>9+</sup>
2166e41f4b71Sopenharmony_ci
2167e41f4b71Sopenharmony_cisetBackdropBlur(radius: number): void
2168e41f4b71Sopenharmony_ci
2169e41f4b71Sopenharmony_ci设置窗口背景模糊。
2170e41f4b71Sopenharmony_ci窗口背景是指窗口覆盖的下层区域,与窗口大小相同。
2171e41f4b71Sopenharmony_ci需要通过[setWindowBackgroundColor](js-apis-window.md#setwindowbackgroundcolor9)将窗口内容背景设置成透明,否则无法看到模糊效果。
2172e41f4b71Sopenharmony_ci
2173e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2174e41f4b71Sopenharmony_ci
2175e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2176e41f4b71Sopenharmony_ci
2177e41f4b71Sopenharmony_ci**参数:**
2178e41f4b71Sopenharmony_ci
2179e41f4b71Sopenharmony_ci| 参数名 | 类型   | 必填 | 说明                                                    |
2180e41f4b71Sopenharmony_ci| ------ | ------ | ---- |-------------------------------------------------------|
2181e41f4b71Sopenharmony_ci| radius | number | 是   | 表示窗口背景模糊的半径值。该参数为浮点数,单位为px,取值范围为[0.0, +∞),取值为0.0表示关闭窗口背景模糊。 |
2182e41f4b71Sopenharmony_ci
2183e41f4b71Sopenharmony_ci**错误码:**
2184e41f4b71Sopenharmony_ci
2185e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2186e41f4b71Sopenharmony_ci
2187e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2188e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2189e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2190e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2191e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2192e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
2193e41f4b71Sopenharmony_ci
2194e41f4b71Sopenharmony_ci**示例:**
2195e41f4b71Sopenharmony_ci
2196e41f4b71Sopenharmony_ci```ts
2197e41f4b71Sopenharmony_citry {
2198e41f4b71Sopenharmony_ci  windowClass.setWindowBackgroundColor('#00FFFFFF');
2199e41f4b71Sopenharmony_ci  windowClass.setBackdropBlur(4.0);
2200e41f4b71Sopenharmony_ci} catch (exception) {
2201e41f4b71Sopenharmony_ci  console.error(`Failed to set backdrop blur. Cause code: ${exception.code}, message: ${exception.message}`);
2202e41f4b71Sopenharmony_ci}
2203e41f4b71Sopenharmony_ci```
2204e41f4b71Sopenharmony_ci
2205e41f4b71Sopenharmony_ci### setBackdropBlurStyle<sup>9+</sup>
2206e41f4b71Sopenharmony_ci
2207e41f4b71Sopenharmony_cisetBackdropBlurStyle(blurStyle: BlurStyle): void
2208e41f4b71Sopenharmony_ci
2209e41f4b71Sopenharmony_ci设置窗口背景模糊类型。
2210e41f4b71Sopenharmony_ci
2211e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2212e41f4b71Sopenharmony_ci
2213e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2214e41f4b71Sopenharmony_ci
2215e41f4b71Sopenharmony_ci**参数:**
2216e41f4b71Sopenharmony_ci
2217e41f4b71Sopenharmony_ci| 参数名    | 类型      | 必填 | 说明                   |
2218e41f4b71Sopenharmony_ci| --------- | --------- | ---- | ---------------------- |
2219e41f4b71Sopenharmony_ci| blurStyle | [BlurStyle](#blurstyle9) | 是   | 表示窗口背景模糊类型。 |
2220e41f4b71Sopenharmony_ci
2221e41f4b71Sopenharmony_ci**错误码:**
2222e41f4b71Sopenharmony_ci
2223e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2224e41f4b71Sopenharmony_ci
2225e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2226e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2227e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2228e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2229e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2230e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
2231e41f4b71Sopenharmony_ci
2232e41f4b71Sopenharmony_ci**示例:**
2233e41f4b71Sopenharmony_ci
2234e41f4b71Sopenharmony_ci```ts
2235e41f4b71Sopenharmony_citry {
2236e41f4b71Sopenharmony_ci  windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
2237e41f4b71Sopenharmony_ci} catch (exception) {
2238e41f4b71Sopenharmony_ci  console.error(`Failed to set backdrop blur style. Cause code: ${exception.code}, message: ${exception.message}`);
2239e41f4b71Sopenharmony_ci}
2240e41f4b71Sopenharmony_ci```
2241e41f4b71Sopenharmony_ci
2242e41f4b71Sopenharmony_ci### setShadow<sup>9+</sup>
2243e41f4b71Sopenharmony_ci
2244e41f4b71Sopenharmony_cisetShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void
2245e41f4b71Sopenharmony_ci
2246e41f4b71Sopenharmony_ci设置窗口边缘阴影。
2247e41f4b71Sopenharmony_ci
2248e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2249e41f4b71Sopenharmony_ci
2250e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2251e41f4b71Sopenharmony_ci
2252e41f4b71Sopenharmony_ci**参数:**
2253e41f4b71Sopenharmony_ci
2254e41f4b71Sopenharmony_ci| 参数名  | 类型   | 必填 | 说明                                                          |
2255e41f4b71Sopenharmony_ci| ------- | ------ | ---- |-------------------------------------------------------------|
2256e41f4b71Sopenharmony_ci| radius  | number | 是   | 表示窗口边缘阴影的模糊半径。该参数为浮点数,单位为px,取值范围为[0.0, +∞),取值为0.0时表示关闭窗口边缘阴影。     |
2257e41f4b71Sopenharmony_ci| color   | string | 否   | 表示窗口边缘阴影的颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
2258e41f4b71Sopenharmony_ci| offsetX | number | 否   | 表示窗口边缘阴影的X轴的偏移量。该参数为浮点数,单位为px。                              |
2259e41f4b71Sopenharmony_ci| offsetY | number | 否   | 表示窗口边缘阴影的Y轴的偏移量。该参数为浮点数,单位为px。                              |
2260e41f4b71Sopenharmony_ci
2261e41f4b71Sopenharmony_ci**错误码:**
2262e41f4b71Sopenharmony_ci
2263e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2264e41f4b71Sopenharmony_ci
2265e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2266e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2267e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2268e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2269e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2270e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
2271e41f4b71Sopenharmony_ci
2272e41f4b71Sopenharmony_ci**示例:**
2273e41f4b71Sopenharmony_ci
2274e41f4b71Sopenharmony_ci```ts
2275e41f4b71Sopenharmony_citry {
2276e41f4b71Sopenharmony_ci  windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
2277e41f4b71Sopenharmony_ci} catch (exception) {
2278e41f4b71Sopenharmony_ci  console.error(`Failed to set shadow. Cause code: ${exception.code}, message: ${exception.message}`);
2279e41f4b71Sopenharmony_ci}
2280e41f4b71Sopenharmony_ci```
2281e41f4b71Sopenharmony_ci
2282e41f4b71Sopenharmony_ci### setCornerRadius<sup>9+</sup>
2283e41f4b71Sopenharmony_ci
2284e41f4b71Sopenharmony_cisetCornerRadius(cornerRadius: number): void
2285e41f4b71Sopenharmony_ci
2286e41f4b71Sopenharmony_ci设置窗口圆角半径。
2287e41f4b71Sopenharmony_ci
2288e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2289e41f4b71Sopenharmony_ci
2290e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2291e41f4b71Sopenharmony_ci
2292e41f4b71Sopenharmony_ci**参数:**
2293e41f4b71Sopenharmony_ci
2294e41f4b71Sopenharmony_ci| 参数名      | 类型    | 必填 | 说明                                                 |
2295e41f4b71Sopenharmony_ci| ----------- | ------- | ---- |----------------------------------------------------|
2296e41f4b71Sopenharmony_ci| cornerRadius | number | 是   | 表示窗口圆角的半径值。该参数为浮点数,单位为px,取值范围为[0.0, +∞),取值为0.0时表示没有窗口圆角。 |
2297e41f4b71Sopenharmony_ci
2298e41f4b71Sopenharmony_ci**错误码:**
2299e41f4b71Sopenharmony_ci
2300e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2301e41f4b71Sopenharmony_ci
2302e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2303e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2304e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2305e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
2306e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2307e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.  |
2308e41f4b71Sopenharmony_ci
2309e41f4b71Sopenharmony_ci**示例:**
2310e41f4b71Sopenharmony_ci
2311e41f4b71Sopenharmony_ci```ts
2312e41f4b71Sopenharmony_citry {
2313e41f4b71Sopenharmony_ci  windowClass.setCornerRadius(4.0);
2314e41f4b71Sopenharmony_ci} catch (exception) {
2315e41f4b71Sopenharmony_ci  console.error(`Failed to set corner radius. Cause code: ${exception.code}, message: ${exception.message}`);
2316e41f4b71Sopenharmony_ci}
2317e41f4b71Sopenharmony_ci```
2318e41f4b71Sopenharmony_ci
2319e41f4b71Sopenharmony_ci### setTouchableAreas<sup>12+</sup>
2320e41f4b71Sopenharmony_ci
2321e41f4b71Sopenharmony_cisetTouchableAreas(rects: Array&lt;Rect&gt;): void
2322e41f4b71Sopenharmony_ci
2323e41f4b71Sopenharmony_ci实现设置窗口可触摸区域;不设置时默认整个窗口区域可触摸;设置窗口可触摸区域后,区域外触摸事件将被透传;如果窗口区域发生变化需要重新设置。
2324e41f4b71Sopenharmony_ci
2325e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2326e41f4b71Sopenharmony_ci
2327e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
2328e41f4b71Sopenharmony_ci
2329e41f4b71Sopenharmony_ci**参数:**
2330e41f4b71Sopenharmony_ci
2331e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
2332e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
2333e41f4b71Sopenharmony_ci| rects | Array<[Rect](js-apis-window.md#rect7)> | 是   | 窗口可触摸区域。可触摸区域最大个数不能超过10个,且范围不能超出窗口区域。 |
2334e41f4b71Sopenharmony_ci
2335e41f4b71Sopenharmony_ci**错误码:**
2336e41f4b71Sopenharmony_ci
2337e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2338e41f4b71Sopenharmony_ci
2339e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2340e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2341e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2342e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2343e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
2344e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                |
2345e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |                       |
2346e41f4b71Sopenharmony_ci
2347e41f4b71Sopenharmony_ci**示例:**
2348e41f4b71Sopenharmony_ci
2349e41f4b71Sopenharmony_ci```ts
2350e41f4b71Sopenharmony_citry {
2351e41f4b71Sopenharmony_ci  windowClass.setTouchableAreas([{left: 100, top: 100, width: 200, height:200},
2352e41f4b71Sopenharmony_ci    {left: 400, top: 100, width: 200, height:200}]);
2353e41f4b71Sopenharmony_ci} catch (exception) {
2354e41f4b71Sopenharmony_ci  console.error(`Failed to set touchable areas. Cause code: ${exception.code}, message: ${exception.message}`);
2355e41f4b71Sopenharmony_ci}
2356e41f4b71Sopenharmony_ci```
2357e41f4b71Sopenharmony_ci
2358e41f4b71Sopenharmony_ci### raiseToAppTop<sup>10+</sup>
2359e41f4b71Sopenharmony_ci
2360e41f4b71Sopenharmony_ciraiseToAppTop(callback: AsyncCallback&lt;void&gt;): void
2361e41f4b71Sopenharmony_ci
2362e41f4b71Sopenharmony_ci提升应用子窗口到应用顶层。使用callback异步回调。
2363e41f4b71Sopenharmony_ci
2364e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2365e41f4b71Sopenharmony_ci
2366e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2367e41f4b71Sopenharmony_ci
2368e41f4b71Sopenharmony_ci**参数:**
2369e41f4b71Sopenharmony_ci
2370e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
2371e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
2372e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2373e41f4b71Sopenharmony_ci
2374e41f4b71Sopenharmony_ci**错误码:**
2375e41f4b71Sopenharmony_ci
2376e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2377e41f4b71Sopenharmony_ci
2378e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2379e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2380e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2381e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2382e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
2383e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation. |
2384e41f4b71Sopenharmony_ci| 1300009 | The parent window is invalid. |
2385e41f4b71Sopenharmony_ci
2386e41f4b71Sopenharmony_ci**示例:**
2387e41f4b71Sopenharmony_ci
2388e41f4b71Sopenharmony_ci```ts
2389e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2390e41f4b71Sopenharmony_ci
2391e41f4b71Sopenharmony_ciwindowClass.raiseToAppTop((err: BusinessError) => {
2392e41f4b71Sopenharmony_ci  const errCode: number = err.code;
2393e41f4b71Sopenharmony_ci  if (errCode) {
2394e41f4b71Sopenharmony_ci    console.error(`Failed to raise the window to app top. Cause code: ${err.code}, message: ${err.message}`);
2395e41f4b71Sopenharmony_ci    return;
2396e41f4b71Sopenharmony_ci  }
2397e41f4b71Sopenharmony_ci  console.info('Succeeded in raising the window to app top.');
2398e41f4b71Sopenharmony_ci});
2399e41f4b71Sopenharmony_ci```
2400e41f4b71Sopenharmony_ci
2401e41f4b71Sopenharmony_ci### raiseToAppTop<sup>10+</sup>
2402e41f4b71Sopenharmony_ci
2403e41f4b71Sopenharmony_ciraiseToAppTop(): Promise&lt;void&gt;
2404e41f4b71Sopenharmony_ci
2405e41f4b71Sopenharmony_ci提升应用子窗口到应用顶层。使用Promise异步回调。
2406e41f4b71Sopenharmony_ci
2407e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2408e41f4b71Sopenharmony_ci
2409e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2410e41f4b71Sopenharmony_ci
2411e41f4b71Sopenharmony_ci**返回值:**
2412e41f4b71Sopenharmony_ci
2413e41f4b71Sopenharmony_ci| 类型                | 说明                      |
2414e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
2415e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2416e41f4b71Sopenharmony_ci
2417e41f4b71Sopenharmony_ci**错误码:**
2418e41f4b71Sopenharmony_ci
2419e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2420e41f4b71Sopenharmony_ci
2421e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2422e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2423e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2424e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2425e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
2426e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation. |
2427e41f4b71Sopenharmony_ci| 1300009 | The parent window is invalid. |
2428e41f4b71Sopenharmony_ci
2429e41f4b71Sopenharmony_ci**示例:**
2430e41f4b71Sopenharmony_ci
2431e41f4b71Sopenharmony_ci```ts
2432e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2433e41f4b71Sopenharmony_ci
2434e41f4b71Sopenharmony_cilet promise = windowClass.raiseToAppTop();
2435e41f4b71Sopenharmony_cipromise.then(() => {
2436e41f4b71Sopenharmony_ci  console.info('Succeeded in raising the window to app top.');
2437e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
2438e41f4b71Sopenharmony_ci  console.error(`Failed to raise the window to app top. Cause code: ${err.code}, message: ${err.message}`);
2439e41f4b71Sopenharmony_ci});
2440e41f4b71Sopenharmony_ci```
2441e41f4b71Sopenharmony_ci
2442e41f4b71Sopenharmony_ci### setWaterMarkFlag<sup>10+</sup>
2443e41f4b71Sopenharmony_ci
2444e41f4b71Sopenharmony_cisetWaterMarkFlag(enable: boolean): Promise&lt;void&gt;
2445e41f4b71Sopenharmony_ci
2446e41f4b71Sopenharmony_ci为当前窗口添加或删除安全水印标志,使用Promise异步回调。
2447e41f4b71Sopenharmony_ci
2448e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2449e41f4b71Sopenharmony_ci
2450e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2451e41f4b71Sopenharmony_ci
2452e41f4b71Sopenharmony_ci**参数:**
2453e41f4b71Sopenharmony_ci
2454e41f4b71Sopenharmony_ci| 参数名 | 类型     | 必填 | 说明                                            |
2455e41f4b71Sopenharmony_ci| ------ | ------- | --- | ------------------------------------------------ |
2456e41f4b71Sopenharmony_ci| enable | boolean | 是   | 是否对窗口添加标志位。true表示添加,false表示删除。 |
2457e41f4b71Sopenharmony_ci
2458e41f4b71Sopenharmony_ci**返回值:**
2459e41f4b71Sopenharmony_ci
2460e41f4b71Sopenharmony_ci| 类型                | 说明                      |
2461e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
2462e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2463e41f4b71Sopenharmony_ci
2464e41f4b71Sopenharmony_ci**错误码:**
2465e41f4b71Sopenharmony_ci
2466e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2467e41f4b71Sopenharmony_ci
2468e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2469e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------- |
2470e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2471e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2472e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                 |
2473e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally.  |
2474e41f4b71Sopenharmony_ci| 1300008 | The display device is abnormal.           |
2475e41f4b71Sopenharmony_ci
2476e41f4b71Sopenharmony_ci**示例:**
2477e41f4b71Sopenharmony_ci
2478e41f4b71Sopenharmony_ci```ts
2479e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2480e41f4b71Sopenharmony_ci
2481e41f4b71Sopenharmony_citry {
2482e41f4b71Sopenharmony_ci  let enable = true;
2483e41f4b71Sopenharmony_ci  let promise = windowClass.setWaterMarkFlag(enable);
2484e41f4b71Sopenharmony_ci  promise.then(() => {
2485e41f4b71Sopenharmony_ci    console.info('Succeeded in setting water mark flag of window.');
2486e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
2487e41f4b71Sopenharmony_ci    console.error(`Failed to set water mark flag of window. Cause code: ${err.code}, message: ${err.message}`);
2488e41f4b71Sopenharmony_ci  });
2489e41f4b71Sopenharmony_ci} catch (exception) {
2490e41f4b71Sopenharmony_ci  console.error(`Failed to set water mark flag of window. Cause code: ${exception.code}, message: ${exception.message}`);
2491e41f4b71Sopenharmony_ci}
2492e41f4b71Sopenharmony_ci```
2493e41f4b71Sopenharmony_ci
2494e41f4b71Sopenharmony_ci### setWaterMarkFlag<sup>10+</sup>
2495e41f4b71Sopenharmony_ci
2496e41f4b71Sopenharmony_cisetWaterMarkFlag(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
2497e41f4b71Sopenharmony_ci
2498e41f4b71Sopenharmony_ci为当前窗口添加或删除安全水印标志,使用callback异步回调。
2499e41f4b71Sopenharmony_ci
2500e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2501e41f4b71Sopenharmony_ci
2502e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2503e41f4b71Sopenharmony_ci
2504e41f4b71Sopenharmony_ci**参数:**
2505e41f4b71Sopenharmony_ci
2506e41f4b71Sopenharmony_ci| 参数名   | 类型                       | 必填 | 说明                                              |
2507e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---  | ----------------------------------------------- |
2508e41f4b71Sopenharmony_ci| enable   | boolean                   | 是   | 是否对窗口添加标志位。true表示添加,false表示删除。 |
2509e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
2510e41f4b71Sopenharmony_ci
2511e41f4b71Sopenharmony_ci**错误码:**
2512e41f4b71Sopenharmony_ci
2513e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2514e41f4b71Sopenharmony_ci
2515e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2516e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------- |
2517e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2518e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2519e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                 |
2520e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally.  |
2521e41f4b71Sopenharmony_ci| 1300008 | The display device is abnormal.           |
2522e41f4b71Sopenharmony_ci
2523e41f4b71Sopenharmony_ci**示例:**
2524e41f4b71Sopenharmony_ci
2525e41f4b71Sopenharmony_ci```ts
2526e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2527e41f4b71Sopenharmony_ci
2528e41f4b71Sopenharmony_citry {
2529e41f4b71Sopenharmony_ci  let enable: boolean = true;
2530e41f4b71Sopenharmony_ci  windowClass.setWaterMarkFlag(enable, (err: BusinessError) => {
2531e41f4b71Sopenharmony_ci    const errCode: number = err.code;
2532e41f4b71Sopenharmony_ci    if (errCode) {
2533e41f4b71Sopenharmony_ci      console.error(`Failed to set water mark flag of window. Cause code: ${err.code}, message: ${err.message}`);
2534e41f4b71Sopenharmony_ci      return;
2535e41f4b71Sopenharmony_ci    }
2536e41f4b71Sopenharmony_ci    console.info('Succeeded in setting water mark flag of window.');
2537e41f4b71Sopenharmony_ci  });
2538e41f4b71Sopenharmony_ci} catch (exception) {
2539e41f4b71Sopenharmony_ci  console.error(`Failed to set water mark flag of window. Cause code: ${exception.code}, message: ${exception.message}`);
2540e41f4b71Sopenharmony_ci}
2541e41f4b71Sopenharmony_ci```
2542e41f4b71Sopenharmony_ci
2543e41f4b71Sopenharmony_ci### setHandwritingFlag<sup>12+</sup>
2544e41f4b71Sopenharmony_ci
2545e41f4b71Sopenharmony_cisetHandwritingFlag(enable: boolean): Promise&lt;void&gt;
2546e41f4b71Sopenharmony_ci
2547e41f4b71Sopenharmony_ci为当前窗口添加或移除手写标志,添加该标志后窗口只响应手写笔事件,不响应触屏事件。使用Promise异步回调。
2548e41f4b71Sopenharmony_ci
2549e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2550e41f4b71Sopenharmony_ci
2551e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
2552e41f4b71Sopenharmony_ci
2553e41f4b71Sopenharmony_ci**参数:**
2554e41f4b71Sopenharmony_ci
2555e41f4b71Sopenharmony_ci| 参数名 | 类型     | 必填 | 说明                                            |
2556e41f4b71Sopenharmony_ci| ------ | ------- | --- | ------------------------------------------------ |
2557e41f4b71Sopenharmony_ci| enable | boolean | 是   | 是否对窗口添加标志位。true表示添加,false表示移除。 |
2558e41f4b71Sopenharmony_ci
2559e41f4b71Sopenharmony_ci**返回值:**
2560e41f4b71Sopenharmony_ci
2561e41f4b71Sopenharmony_ci| 类型                | 说明                      |
2562e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
2563e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2564e41f4b71Sopenharmony_ci
2565e41f4b71Sopenharmony_ci**错误码:**
2566e41f4b71Sopenharmony_ci
2567e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2568e41f4b71Sopenharmony_ci
2569e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2570e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
2571e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2572e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2573e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
2574e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                 |
2575e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally.  |
2576e41f4b71Sopenharmony_ci
2577e41f4b71Sopenharmony_ci**示例:**
2578e41f4b71Sopenharmony_ci
2579e41f4b71Sopenharmony_ci```ts
2580e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2581e41f4b71Sopenharmony_ci
2582e41f4b71Sopenharmony_citry {
2583e41f4b71Sopenharmony_ci  let enable = true;
2584e41f4b71Sopenharmony_ci  let promise = windowClass.setHandwritingFlag(enable);
2585e41f4b71Sopenharmony_ci  promise.then(() => {
2586e41f4b71Sopenharmony_ci    console.info('Succeeded in setting handwriting flag of window.');
2587e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
2588e41f4b71Sopenharmony_ci    console.error(`Failed to set handwriting flag of window. Cause code: ${err.code}, message: ${err.message}`);
2589e41f4b71Sopenharmony_ci  });
2590e41f4b71Sopenharmony_ci} catch (exception) {
2591e41f4b71Sopenharmony_ci  console.error(`Failed to set handwriting flag of window. Cause code: ${exception.code}, message: ${exception.message}`);
2592e41f4b71Sopenharmony_ci}
2593e41f4b71Sopenharmony_ci```
2594e41f4b71Sopenharmony_ci
2595e41f4b71Sopenharmony_ci### raiseAboveTarget<sup>10+</sup>
2596e41f4b71Sopenharmony_ci
2597e41f4b71Sopenharmony_ciraiseAboveTarget(windowId: number, callback: AsyncCallback&lt;void&gt;): void
2598e41f4b71Sopenharmony_ci
2599e41f4b71Sopenharmony_ci将同一个主窗口下的子窗口提升到目标子窗口之上。使用callback异步回调。
2600e41f4b71Sopenharmony_ci
2601e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2602e41f4b71Sopenharmony_ci
2603e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
2604e41f4b71Sopenharmony_ci
2605e41f4b71Sopenharmony_ci**参数:**
2606e41f4b71Sopenharmony_ci
2607e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
2608e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
2609e41f4b71Sopenharmony_ci| windowId | number                    | 是   | 目标子窗口的id,通过[getWindowProperties](js-apis-window.md#getwindowproperties9)接口获取到[properties](js-apis-window.md#windowproperties)后,再通过properties.id获取 |
2610e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2611e41f4b71Sopenharmony_ci
2612e41f4b71Sopenharmony_ci**错误码:**
2613e41f4b71Sopenharmony_ci
2614e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2615e41f4b71Sopenharmony_ci
2616e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2617e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------- |
2618e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2619e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: Mandatory parameters are left unspecified. |
2620e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
2621e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2622e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
2623e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation. |
2624e41f4b71Sopenharmony_ci| 1300009 | The parent window is invalid. |
2625e41f4b71Sopenharmony_ci
2626e41f4b71Sopenharmony_ci**示例:**
2627e41f4b71Sopenharmony_ci
2628e41f4b71Sopenharmony_ci```ts
2629e41f4b71Sopenharmony_ci// EntryAbility.ets
2630e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
2631e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2632e41f4b71Sopenharmony_ci
2633e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
2634e41f4b71Sopenharmony_ci  // ...
2635e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
2636e41f4b71Sopenharmony_ci    console.info('onWindowStageCreate');
2637e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
2638e41f4b71Sopenharmony_ci    // 创建子窗
2639e41f4b71Sopenharmony_ci    try {
2640e41f4b71Sopenharmony_ci      let subWindow = windowStage.createSubWindow("testSubWindow");
2641e41f4b71Sopenharmony_ci      subWindow.then((data) => {
2642e41f4b71Sopenharmony_ci        if (data == null) {
2643e41f4b71Sopenharmony_ci          console.error("Failed to create the subWindow. Cause: The data is empty");
2644e41f4b71Sopenharmony_ci          return;
2645e41f4b71Sopenharmony_ci        }
2646e41f4b71Sopenharmony_ci        windowClass = data;
2647e41f4b71Sopenharmony_ci        // windowClass的获取需放在targetWindow之上
2648e41f4b71Sopenharmony_ci        let targetWindow: window.Window = windowClass;
2649e41f4b71Sopenharmony_ci        let properties = targetWindow.getWindowProperties();
2650e41f4b71Sopenharmony_ci        let targetId = properties.id;
2651e41f4b71Sopenharmony_ci        windowClass.raiseAboveTarget(targetId, (err) => {
2652e41f4b71Sopenharmony_ci          if (err.code) {
2653e41f4b71Sopenharmony_ci            console.error(`Failed to raise the subWindow to target subWindow top. Cause code: ${err.code}, message: ${err.message}`);
2654e41f4b71Sopenharmony_ci            return;
2655e41f4b71Sopenharmony_ci          }
2656e41f4b71Sopenharmony_ci          console.info('Succeeded in raising the subWindow to target subWindow top.');
2657e41f4b71Sopenharmony_ci        });
2658e41f4b71Sopenharmony_ci      });
2659e41f4b71Sopenharmony_ci    } catch (exception) {
2660e41f4b71Sopenharmony_ci      console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`);
2661e41f4b71Sopenharmony_ci    }
2662e41f4b71Sopenharmony_ci  }
2663e41f4b71Sopenharmony_ci}
2664e41f4b71Sopenharmony_ci```
2665e41f4b71Sopenharmony_ci
2666e41f4b71Sopenharmony_ci### raiseAboveTarget<sup>10+</sup>
2667e41f4b71Sopenharmony_ci
2668e41f4b71Sopenharmony_ciraiseAboveTarget(windowId: number): Promise&lt;void&gt;
2669e41f4b71Sopenharmony_ci
2670e41f4b71Sopenharmony_ci将同一个主窗下的子窗口提升到目标子窗口之上。使用Promise异步回调。
2671e41f4b71Sopenharmony_ci
2672e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2673e41f4b71Sopenharmony_ci
2674e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
2675e41f4b71Sopenharmony_ci
2676e41f4b71Sopenharmony_ci**参数:**
2677e41f4b71Sopenharmony_ci
2678e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
2679e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
2680e41f4b71Sopenharmony_ci| windowId | number                    | 是   | 目标子窗口的id,通过[getWindowProperties](js-apis-window.md#getwindowproperties9)接口获取到[properties](js-apis-window.md#windowproperties)后,再通过properties.id获取 |
2681e41f4b71Sopenharmony_ci
2682e41f4b71Sopenharmony_ci**返回值:**
2683e41f4b71Sopenharmony_ci
2684e41f4b71Sopenharmony_ci| 类型                | 说明                      |
2685e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
2686e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2687e41f4b71Sopenharmony_ci
2688e41f4b71Sopenharmony_ci**错误码:**
2689e41f4b71Sopenharmony_ci
2690e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2691e41f4b71Sopenharmony_ci
2692e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2693e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2694e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2695e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: Mandatory parameters are left unspecified. |
2696e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
2697e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2698e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
2699e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation. |
2700e41f4b71Sopenharmony_ci| 1300009 | The parent window is invalid. |
2701e41f4b71Sopenharmony_ci
2702e41f4b71Sopenharmony_ci**示例:**
2703e41f4b71Sopenharmony_ci
2704e41f4b71Sopenharmony_ci```ts
2705e41f4b71Sopenharmony_ci// EntryAbility.ets
2706e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
2707e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2708e41f4b71Sopenharmony_ci
2709e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
2710e41f4b71Sopenharmony_ci  // ...
2711e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
2712e41f4b71Sopenharmony_ci    console.info('onWindowStageCreate');
2713e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
2714e41f4b71Sopenharmony_ci    // 创建子窗
2715e41f4b71Sopenharmony_ci    try {
2716e41f4b71Sopenharmony_ci      let subWindow = windowStage.createSubWindow("testSubWindow");
2717e41f4b71Sopenharmony_ci      subWindow.then((data) => {
2718e41f4b71Sopenharmony_ci        if (data == null) {
2719e41f4b71Sopenharmony_ci          console.error("Failed to create the subWindow. Cause: The data is empty");
2720e41f4b71Sopenharmony_ci          return;
2721e41f4b71Sopenharmony_ci        }
2722e41f4b71Sopenharmony_ci        windowClass = data;
2723e41f4b71Sopenharmony_ci        // windowClass的获取需放在targetWindow之上
2724e41f4b71Sopenharmony_ci        let targetWindow: window.Window = windowClass;
2725e41f4b71Sopenharmony_ci        let properties = targetWindow.getWindowProperties();
2726e41f4b71Sopenharmony_ci        let targetId = properties.id;
2727e41f4b71Sopenharmony_ci        let promise = windowClass.raiseAboveTarget(targetId);
2728e41f4b71Sopenharmony_ci        promise.then(()=> {
2729e41f4b71Sopenharmony_ci          console.info('Succeeded in raising the subWindow to target subWindow top.');
2730e41f4b71Sopenharmony_ci        }).catch((err: BusinessError)=>{
2731e41f4b71Sopenharmony_ci          console.error(`Failed to raise the subWindow to target subWindow top. Cause code: ${err.code}, message: ${err.message}`);
2732e41f4b71Sopenharmony_ci        });
2733e41f4b71Sopenharmony_ci      });
2734e41f4b71Sopenharmony_ci    } catch (exception) {
2735e41f4b71Sopenharmony_ci      console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`);
2736e41f4b71Sopenharmony_ci    }
2737e41f4b71Sopenharmony_ci  }
2738e41f4b71Sopenharmony_ci}
2739e41f4b71Sopenharmony_ci```
2740e41f4b71Sopenharmony_ci
2741e41f4b71Sopenharmony_ci### setRaiseByClickEnabled<sup>10+</sup>
2742e41f4b71Sopenharmony_ci
2743e41f4b71Sopenharmony_cisetRaiseByClickEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
2744e41f4b71Sopenharmony_ci
2745e41f4b71Sopenharmony_ci禁止/使能子窗口点击抬升功能。使用callback异步回调。
2746e41f4b71Sopenharmony_ci
2747e41f4b71Sopenharmony_ci通常来说,点击一个子窗口,会将该子窗口显示到最上方,如果设置为false,那么点击子窗口的时候,不会将该子窗口显示到最上方,而是保持不变。
2748e41f4b71Sopenharmony_ci
2749e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2750e41f4b71Sopenharmony_ci
2751e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
2752e41f4b71Sopenharmony_ci
2753e41f4b71Sopenharmony_ci**参数:**
2754e41f4b71Sopenharmony_ci
2755e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
2756e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
2757e41f4b71Sopenharmony_ci| enable   | boolean                   | 是   | 设置子窗口点击抬升功能是否使能,true表示使能,false表示禁止。 |
2758e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2759e41f4b71Sopenharmony_ci
2760e41f4b71Sopenharmony_ci**错误码:**
2761e41f4b71Sopenharmony_ci
2762e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2763e41f4b71Sopenharmony_ci
2764e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2765e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2766e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2767e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2768e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
2769e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2770e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
2771e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation. |
2772e41f4b71Sopenharmony_ci| 1300009 | The parent window is invalid. |
2773e41f4b71Sopenharmony_ci
2774e41f4b71Sopenharmony_ci**示例:**
2775e41f4b71Sopenharmony_ci
2776e41f4b71Sopenharmony_ci```ts
2777e41f4b71Sopenharmony_ci// EntryAbility.ets
2778e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
2779e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2780e41f4b71Sopenharmony_ci
2781e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
2782e41f4b71Sopenharmony_ci  // ...
2783e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
2784e41f4b71Sopenharmony_ci    console.info('onWindowStageCreate');
2785e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
2786e41f4b71Sopenharmony_ci    // 创建子窗
2787e41f4b71Sopenharmony_ci    try {
2788e41f4b71Sopenharmony_ci      let subWindow = windowStage.createSubWindow("testSubWindow");
2789e41f4b71Sopenharmony_ci      subWindow.then((data) => {
2790e41f4b71Sopenharmony_ci        if (data == null) {
2791e41f4b71Sopenharmony_ci          console.error("Failed to create the subWindow. Cause: The data is empty");
2792e41f4b71Sopenharmony_ci          return;
2793e41f4b71Sopenharmony_ci        }
2794e41f4b71Sopenharmony_ci        windowClass = data;
2795e41f4b71Sopenharmony_ci        let enabled = false;
2796e41f4b71Sopenharmony_ci        windowClass.setRaiseByClickEnabled(enabled, (err) => {
2797e41f4b71Sopenharmony_ci          if (err.code) {
2798e41f4b71Sopenharmony_ci            console.error(`Failed to disable the raise-by-click function. Cause code: ${err.code}, message: ${err.message}`);
2799e41f4b71Sopenharmony_ci            return;
2800e41f4b71Sopenharmony_ci          }
2801e41f4b71Sopenharmony_ci          console.info('Succeeded in disabling the raise-by-click function.');
2802e41f4b71Sopenharmony_ci        });
2803e41f4b71Sopenharmony_ci      });
2804e41f4b71Sopenharmony_ci    } catch (exception) {
2805e41f4b71Sopenharmony_ci      console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`);
2806e41f4b71Sopenharmony_ci    }
2807e41f4b71Sopenharmony_ci  }
2808e41f4b71Sopenharmony_ci}
2809e41f4b71Sopenharmony_ci```
2810e41f4b71Sopenharmony_ci
2811e41f4b71Sopenharmony_ci### setRaiseByClickEnabled<sup>10+</sup>
2812e41f4b71Sopenharmony_ci
2813e41f4b71Sopenharmony_cisetRaiseByClickEnabled(enable: boolean): Promise&lt;void&gt;
2814e41f4b71Sopenharmony_ci
2815e41f4b71Sopenharmony_ci禁止/使能子窗点击抬升功能。使用Promise异步回调。
2816e41f4b71Sopenharmony_ci
2817e41f4b71Sopenharmony_ci通常来说,点击一个子窗口,会将该子窗口显示到最上方,如果设置为false,那么点击子窗口的时候,不会将该子窗口显示到最上方,而是保持不变。
2818e41f4b71Sopenharmony_ci
2819e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2820e41f4b71Sopenharmony_ci
2821e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
2822e41f4b71Sopenharmony_ci
2823e41f4b71Sopenharmony_ci**参数:**
2824e41f4b71Sopenharmony_ci
2825e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
2826e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
2827e41f4b71Sopenharmony_ci| enable   | boolean                   | 是   | 设置子窗口点击抬升功能是否使能,true表示使能,false表示禁止。 |
2828e41f4b71Sopenharmony_ci
2829e41f4b71Sopenharmony_ci**返回值:**
2830e41f4b71Sopenharmony_ci
2831e41f4b71Sopenharmony_ci| 类型                | 说明                      |
2832e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
2833e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2834e41f4b71Sopenharmony_ci
2835e41f4b71Sopenharmony_ci**错误码:**
2836e41f4b71Sopenharmony_ci
2837e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2838e41f4b71Sopenharmony_ci
2839e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2840e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2841e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2842e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2843e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
2844e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2845e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
2846e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation. |
2847e41f4b71Sopenharmony_ci| 1300009 | The parent window is invalid. |
2848e41f4b71Sopenharmony_ci
2849e41f4b71Sopenharmony_ci**示例:**
2850e41f4b71Sopenharmony_ci
2851e41f4b71Sopenharmony_ci```ts
2852e41f4b71Sopenharmony_ci// EntryAbility.ets
2853e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
2854e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2855e41f4b71Sopenharmony_ci
2856e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
2857e41f4b71Sopenharmony_ci  // ...
2858e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
2859e41f4b71Sopenharmony_ci    console.info('onWindowStageCreate');
2860e41f4b71Sopenharmony_ci    let windowClass: window.Window | undefined = undefined;
2861e41f4b71Sopenharmony_ci    // 创建子窗
2862e41f4b71Sopenharmony_ci    try {
2863e41f4b71Sopenharmony_ci      let subWindow = windowStage.createSubWindow("testSubWindow");
2864e41f4b71Sopenharmony_ci      subWindow.then((data) => {
2865e41f4b71Sopenharmony_ci        if (data == null) {
2866e41f4b71Sopenharmony_ci          console.error("Failed to create the subWindow. Cause: The data is empty");
2867e41f4b71Sopenharmony_ci          return;
2868e41f4b71Sopenharmony_ci        }
2869e41f4b71Sopenharmony_ci        windowClass = data;
2870e41f4b71Sopenharmony_ci        let enabled = false;
2871e41f4b71Sopenharmony_ci        let promise = windowClass.setRaiseByClickEnabled(enabled);
2872e41f4b71Sopenharmony_ci        promise.then(()=> {
2873e41f4b71Sopenharmony_ci          console.info('Succeeded in disabling the raise-by-click function.');
2874e41f4b71Sopenharmony_ci        }).catch((err: BusinessError)=>{
2875e41f4b71Sopenharmony_ci          console.error(`Failed to disable the raise-by-click function. Cause code: ${err.code}, message: ${err.message}`);
2876e41f4b71Sopenharmony_ci        });
2877e41f4b71Sopenharmony_ci      });
2878e41f4b71Sopenharmony_ci    } catch (exception) {
2879e41f4b71Sopenharmony_ci      console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`);
2880e41f4b71Sopenharmony_ci    }
2881e41f4b71Sopenharmony_ci  }
2882e41f4b71Sopenharmony_ci}
2883e41f4b71Sopenharmony_ci```
2884e41f4b71Sopenharmony_ci
2885e41f4b71Sopenharmony_ci### setResizeByDragEnabled<sup>10+</sup>
2886e41f4b71Sopenharmony_ci
2887e41f4b71Sopenharmony_cisetResizeByDragEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
2888e41f4b71Sopenharmony_ci
2889e41f4b71Sopenharmony_ci禁止/使能通过拖拽方式缩放主窗口的功能。使用callback异步回调。
2890e41f4b71Sopenharmony_ci
2891e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2892e41f4b71Sopenharmony_ci
2893e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
2894e41f4b71Sopenharmony_ci
2895e41f4b71Sopenharmony_ci**参数:**
2896e41f4b71Sopenharmony_ci
2897e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
2898e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
2899e41f4b71Sopenharmony_ci| enable   | boolean                   | 是   | 设置窗口是否使能通过拖拽进行缩放,true表示使能,false表示禁止。 |
2900e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2901e41f4b71Sopenharmony_ci
2902e41f4b71Sopenharmony_ci**错误码:**
2903e41f4b71Sopenharmony_ci
2904e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2905e41f4b71Sopenharmony_ci
2906e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2907e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
2908e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
2909e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2910e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
2911e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
2912e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
2913e41f4b71Sopenharmony_ci
2914e41f4b71Sopenharmony_ci**示例:**
2915e41f4b71Sopenharmony_ci
2916e41f4b71Sopenharmony_ci```ts
2917e41f4b71Sopenharmony_ci// EntryAbility.ets
2918e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
2919e41f4b71Sopenharmony_ci
2920e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
2921e41f4b71Sopenharmony_ci    onWindowStageCreate(windowStage) {
2922e41f4b71Sopenharmony_ci        // 为主窗口加载对应的目标页面。
2923e41f4b71Sopenharmony_ci        windowStage.loadContent("pages/page2", (err) => {
2924e41f4b71Sopenharmony_ci            if (err.code) {
2925e41f4b71Sopenharmony_ci                console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`);
2926e41f4b71Sopenharmony_ci                return;
2927e41f4b71Sopenharmony_ci            }
2928e41f4b71Sopenharmony_ci            console.info('Succeeded in loading the content.');
2929e41f4b71Sopenharmony_ci        });
2930e41f4b71Sopenharmony_ci        // 获取应用主窗口。
2931e41f4b71Sopenharmony_ci        let mainWindow: window.Window | undefined = undefined;
2932e41f4b71Sopenharmony_ci
2933e41f4b71Sopenharmony_ci        windowStage.getMainWindow((err, data) => {
2934e41f4b71Sopenharmony_ci            if (err.code) {
2935e41f4b71Sopenharmony_ci                console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
2936e41f4b71Sopenharmony_ci                return;
2937e41f4b71Sopenharmony_ci            }
2938e41f4b71Sopenharmony_ci            mainWindow = data;
2939e41f4b71Sopenharmony_ci            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
2940e41f4b71Sopenharmony_ci
2941e41f4b71Sopenharmony_ci            let enabled = false;
2942e41f4b71Sopenharmony_ci            // 调用setResizeByDragEnabled接口。
2943e41f4b71Sopenharmony_ci            mainWindow.setResizeByDragEnabled(enabled, (err) => {
2944e41f4b71Sopenharmony_ci                if (err.code) {
2945e41f4b71Sopenharmony_ci                    console.error(`Failed to set the function of disabling the resize by dragg window. Cause code: ${err.code}, message: ${err.message}`);
2946e41f4b71Sopenharmony_ci                    return;
2947e41f4b71Sopenharmony_ci                }
2948e41f4b71Sopenharmony_ci                console.info('Succeeded in setting the function of disabling the resize by dragg window.');
2949e41f4b71Sopenharmony_ci            });
2950e41f4b71Sopenharmony_ci        });
2951e41f4b71Sopenharmony_ci    }
2952e41f4b71Sopenharmony_ci};
2953e41f4b71Sopenharmony_ci```
2954e41f4b71Sopenharmony_ci
2955e41f4b71Sopenharmony_ci### startMoving<sup>13+</sup>
2956e41f4b71Sopenharmony_ci
2957e41f4b71Sopenharmony_cistartMoving(): Promise&lt;void&gt;
2958e41f4b71Sopenharmony_ci
2959e41f4b71Sopenharmony_ci开始移动窗口,使用Promise异步回调。
2960e41f4b71Sopenharmony_ci
2961e41f4b71Sopenharmony_ci仅在[onTouch](./arkui-ts/ts-universal-events-touch.md#touchevent)事件(其中,事件类型必须为TouchType.Down)的回调方法中调用此接口才会有移动效果,成功调用此接口后,窗口将跟随鼠标移动。
2962e41f4b71Sopenharmony_ci
2963e41f4b71Sopenharmony_ci仅对2in1设备的系统窗口生效,其它设备类型调用此接口会报错。
2964e41f4b71Sopenharmony_ci
2965e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
2966e41f4b71Sopenharmony_ci
2967e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2968e41f4b71Sopenharmony_ci
2969e41f4b71Sopenharmony_ci**返回值:**
2970e41f4b71Sopenharmony_ci
2971e41f4b71Sopenharmony_ci| 类型                | 说明                      |
2972e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
2973e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2974e41f4b71Sopenharmony_ci
2975e41f4b71Sopenharmony_ci**错误码:**
2976e41f4b71Sopenharmony_ci
2977e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
2978e41f4b71Sopenharmony_ci
2979e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
2980e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
2981e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.   |
2982e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
2983e41f4b71Sopenharmony_ci| 1300001 | Repeated operation. |
2984e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                |
2985e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
2986e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.                       |
2987e41f4b71Sopenharmony_ci
2988e41f4b71Sopenharmony_ci**示例:**
2989e41f4b71Sopenharmony_ci
2990e41f4b71Sopenharmony_ci```ts
2991e41f4b71Sopenharmony_ci// ets/pages/Index.ets
2992e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2993e41f4b71Sopenharmony_ci
2994e41f4b71Sopenharmony_ci@Entry
2995e41f4b71Sopenharmony_ci@Component
2996e41f4b71Sopenharmony_cistruct Index {
2997e41f4b71Sopenharmony_ci  @State message: string = 'Hello World';
2998e41f4b71Sopenharmony_ci  build() {
2999e41f4b71Sopenharmony_ci    row() {
3000e41f4b71Sopenharmony_ci      Column() {
3001e41f4b71Sopenharmony_ci        // 设置最小宽度为160
3002e41f4b71Sopenharmony_ci        Blank('160').onTouch((event: TouchEvent) => {
3003e41f4b71Sopenharmony_ci          if (event.type === TouchType.Down) {
3004e41f4b71Sopenharmony_ci            try {
3005e41f4b71Sopenharmony_ci              windowClass.startMoving().then(() => {
3006e41f4b71Sopenharmony_ci                console.info('Succeeded in starting moving window.')
3007e41f4b71Sopenharmony_ci              }).catch((err: BusinessError) => {
3008e41f4b71Sopenharmony_ci                console.error(`Failed to start moving. Cause code: ${err.code}, message: ${err.message}`);
3009e41f4b71Sopenharmony_ci              });
3010e41f4b71Sopenharmony_ci            } catch (exception) {
3011e41f4b71Sopenharmony_ci              console.error(`Failed to start moving window. Cause code: ${exception.code}, message: ${exception.message}`);
3012e41f4b71Sopenharmony_ci            }
3013e41f4b71Sopenharmony_ci          }
3014e41f4b71Sopenharmony_ci        }
3015e41f4b71Sopenharmony_ci      }
3016e41f4b71Sopenharmony_ci    }
3017e41f4b71Sopenharmony_ci  }
3018e41f4b71Sopenharmony_ci}
3019e41f4b71Sopenharmony_ci```
3020e41f4b71Sopenharmony_ci
3021e41f4b71Sopenharmony_ci### enableDrag<sup>13+</sup>
3022e41f4b71Sopenharmony_ci
3023e41f4b71Sopenharmony_cienableDrag(enable: boolean): Promise&lt;void&gt;
3024e41f4b71Sopenharmony_ci
3025e41f4b71Sopenharmony_ci使能/禁止拖拽窗口。使用Promise异步回调。
3026e41f4b71Sopenharmony_ci
3027e41f4b71Sopenharmony_ci使能后,将允许通过鼠标对窗口进行拉伸操作。
3028e41f4b71Sopenharmony_ci
3029e41f4b71Sopenharmony_ci仅对2in1设备的系统窗口生效,其它设备类型调用此接口会报错。
3030e41f4b71Sopenharmony_ci
3031e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3032e41f4b71Sopenharmony_ci
3033e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3034e41f4b71Sopenharmony_ci
3035e41f4b71Sopenharmony_ci**参数:**
3036e41f4b71Sopenharmony_ci
3037e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 |
3038e41f4b71Sopenharmony_ci| -------- | ---------------------------- | -- | --------- |
3039e41f4b71Sopenharmony_ci| enable| boolean | 是 | 是否允许拖拽。<br>true表示允许,false表示不允许。</br> |
3040e41f4b71Sopenharmony_ci
3041e41f4b71Sopenharmony_ci**返回值:**
3042e41f4b71Sopenharmony_ci
3043e41f4b71Sopenharmony_ci| 类型                | 说明                      |
3044e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
3045e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。  |
3046e41f4b71Sopenharmony_ci
3047e41f4b71Sopenharmony_ci**错误码:**
3048e41f4b71Sopenharmony_ci
3049e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
3050e41f4b71Sopenharmony_ci
3051e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3052e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- |
3053e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.   |
3054e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3055e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
3056e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                |
3057e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
3058e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.                       |
3059e41f4b71Sopenharmony_ci
3060e41f4b71Sopenharmony_ci**示例:**
3061e41f4b71Sopenharmony_ci
3062e41f4b71Sopenharmony_ci```ts
3063e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3064e41f4b71Sopenharmony_ci
3065e41f4b71Sopenharmony_citry {
3066e41f4b71Sopenharmony_ci  windowClass.enableDrag(true).then(() => { 
3067e41f4b71Sopenharmony_ci    console.info('succeeded in setting window draggable');
3068e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
3069e41f4b71Sopenharmony_ci    console.error(`Failed to set window draggable. Cause code: ${err.code}, message: ${err.message}`);
3070e41f4b71Sopenharmony_ci  });
3071e41f4b71Sopenharmony_ci} catch (exception) {
3072e41f4b71Sopenharmony_ci  console.error(`Failed to set window draggable. Cause code: ${exception.code}, message: ${exception.message}`);
3073e41f4b71Sopenharmony_ci}
3074e41f4b71Sopenharmony_ci```
3075e41f4b71Sopenharmony_ci
3076e41f4b71Sopenharmony_ci### setResizeByDragEnabled<sup>10+</sup>
3077e41f4b71Sopenharmony_ci
3078e41f4b71Sopenharmony_cisetResizeByDragEnabled(enable: boolean): Promise&lt;void&gt;
3079e41f4b71Sopenharmony_ci
3080e41f4b71Sopenharmony_ci禁止/使能通过拖拽方式缩放主窗口的功能。使用Promise异步回调。
3081e41f4b71Sopenharmony_ci
3082e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3083e41f4b71Sopenharmony_ci
3084e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3085e41f4b71Sopenharmony_ci
3086e41f4b71Sopenharmony_ci**参数:**
3087e41f4b71Sopenharmony_ci
3088e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
3089e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
3090e41f4b71Sopenharmony_ci| enable   | boolean                   | 是   | 设置窗口是否使能通过拖拽进行缩放,true表示使能,false表示禁止。 |
3091e41f4b71Sopenharmony_ci
3092e41f4b71Sopenharmony_ci**返回值:**
3093e41f4b71Sopenharmony_ci
3094e41f4b71Sopenharmony_ci| 类型                | 说明                      |
3095e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
3096e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3097e41f4b71Sopenharmony_ci
3098e41f4b71Sopenharmony_ci**错误码:**
3099e41f4b71Sopenharmony_ci
3100e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
3101e41f4b71Sopenharmony_ci
3102e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3103e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
3104e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3105e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3106e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
3107e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
3108e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
3109e41f4b71Sopenharmony_ci
3110e41f4b71Sopenharmony_ci**示例:**
3111e41f4b71Sopenharmony_ci
3112e41f4b71Sopenharmony_ci```ts
3113e41f4b71Sopenharmony_ci// EntryAbility.ets
3114e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
3115e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3116e41f4b71Sopenharmony_ci
3117e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
3118e41f4b71Sopenharmony_ci    onWindowStageCreate(windowStage) {
3119e41f4b71Sopenharmony_ci        // 为主窗口加载对应的目标页面。
3120e41f4b71Sopenharmony_ci        windowStage.loadContent("pages/page2", (err) => {
3121e41f4b71Sopenharmony_ci            if (err.code) {
3122e41f4b71Sopenharmony_ci                console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`);
3123e41f4b71Sopenharmony_ci                return;
3124e41f4b71Sopenharmony_ci            }
3125e41f4b71Sopenharmony_ci            console.info('Succeeded in loading the content.');
3126e41f4b71Sopenharmony_ci        });
3127e41f4b71Sopenharmony_ci        // 获取应用主窗口。
3128e41f4b71Sopenharmony_ci        let mainWindow: window.Window | undefined = undefined;
3129e41f4b71Sopenharmony_ci
3130e41f4b71Sopenharmony_ci        windowStage.getMainWindow((err, data) => {
3131e41f4b71Sopenharmony_ci            if (err.code) {
3132e41f4b71Sopenharmony_ci                console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
3133e41f4b71Sopenharmony_ci                return;
3134e41f4b71Sopenharmony_ci            }
3135e41f4b71Sopenharmony_ci            mainWindow = data;
3136e41f4b71Sopenharmony_ci            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
3137e41f4b71Sopenharmony_ci
3138e41f4b71Sopenharmony_ci            let enabled = false;
3139e41f4b71Sopenharmony_ci            // 获取setResizeByDragEnabled接口的promise对象
3140e41f4b71Sopenharmony_ci            let promise = mainWindow.setResizeByDragEnabled(enabled);
3141e41f4b71Sopenharmony_ci            promise.then(()=> {
3142e41f4b71Sopenharmony_ci                console.info('Succeeded in setting the function of disabling the resize by dragg window.');
3143e41f4b71Sopenharmony_ci            }).catch((err: BusinessError)=>{
3144e41f4b71Sopenharmony_ci                console.error(`Failed to set the function of disabling the resize by dragg window. Cause code: ${err.code}, message: ${err.message}`);
3145e41f4b71Sopenharmony_ci            });
3146e41f4b71Sopenharmony_ci        });
3147e41f4b71Sopenharmony_ci    }
3148e41f4b71Sopenharmony_ci};
3149e41f4b71Sopenharmony_ci```
3150e41f4b71Sopenharmony_ci
3151e41f4b71Sopenharmony_ci### hideNonSystemFloatingWindows<sup>11+</sup>
3152e41f4b71Sopenharmony_ci
3153e41f4b71Sopenharmony_cihideNonSystemFloatingWindows(shouldHide: boolean, callback: AsyncCallback&lt;void&gt;): void
3154e41f4b71Sopenharmony_ci
3155e41f4b71Sopenharmony_ci设置是否隐藏非系统级悬浮窗口。使用callback异步回调。
3156e41f4b71Sopenharmony_ci
3157e41f4b71Sopenharmony_ci非系统级悬浮窗口是指非系统应用创建的悬浮窗口。默认情况下,一个系统应用主窗口可以与非系统级悬浮窗口共同显示,即该主窗口可以被上层的非系统级悬浮窗口遮挡,如果设置为true,则所有的非系统级悬浮窗口会被隐藏,此时该主窗口就不会被上层的非系统级悬浮窗口遮挡了。
3158e41f4b71Sopenharmony_ci
3159e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3160e41f4b71Sopenharmony_ci
3161e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3162e41f4b71Sopenharmony_ci
3163e41f4b71Sopenharmony_ci**参数:**
3164e41f4b71Sopenharmony_ci
3165e41f4b71Sopenharmony_ci| 参数名      | 类型                      | 必填 | 说明       |
3166e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | ---------- |
3167e41f4b71Sopenharmony_ci| shouldHide  | boolean                   | 是   | 指示是否隐藏非系统级的悬浮窗口,true表示隐藏,false表示不隐藏。 |
3168e41f4b71Sopenharmony_ci| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
3169e41f4b71Sopenharmony_ci
3170e41f4b71Sopenharmony_ci**错误码:**
3171e41f4b71Sopenharmony_ci
3172e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
3173e41f4b71Sopenharmony_ci
3174e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3175e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
3176e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3177e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3178e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
3179e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
3180e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
3181e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation. |
3182e41f4b71Sopenharmony_ci
3183e41f4b71Sopenharmony_ci**示例:**
3184e41f4b71Sopenharmony_ci
3185e41f4b71Sopenharmony_ci```ts
3186e41f4b71Sopenharmony_ci// EntryAbility.ets
3187e41f4b71Sopenharmony_ciimport { UIAbility, Want } from '@kit.AbilityKit';
3188e41f4b71Sopenharmony_ci
3189e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
3190e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage) {
3191e41f4b71Sopenharmony_ci    // 加载主窗口对应的页面
3192e41f4b71Sopenharmony_ci    windowStage.loadContent('pages/Index', (err) => {
3193e41f4b71Sopenharmony_ci      if (err.code) {
3194e41f4b71Sopenharmony_ci        console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`);
3195e41f4b71Sopenharmony_ci        return;
3196e41f4b71Sopenharmony_ci      }
3197e41f4b71Sopenharmony_ci      console.info('Succeeded in loading the content.');
3198e41f4b71Sopenharmony_ci    });
3199e41f4b71Sopenharmony_ci
3200e41f4b71Sopenharmony_ci    // 获取应用主窗口。
3201e41f4b71Sopenharmony_ci    let mainWindow: window.Window | undefined = undefined;
3202e41f4b71Sopenharmony_ci    windowStage.getMainWindow((err, data) => {
3203e41f4b71Sopenharmony_ci      if (err.code) {
3204e41f4b71Sopenharmony_ci        console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
3205e41f4b71Sopenharmony_ci        return;
3206e41f4b71Sopenharmony_ci      }
3207e41f4b71Sopenharmony_ci      mainWindow = data;
3208e41f4b71Sopenharmony_ci      console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
3209e41f4b71Sopenharmony_ci
3210e41f4b71Sopenharmony_ci      let shouldHide = true;
3211e41f4b71Sopenharmony_ci      // 调用带callback参数的hideNonSystemFloatingWindows接口
3212e41f4b71Sopenharmony_ci      mainWindow.hideNonSystemFloatingWindows(shouldHide, (err) => {
3213e41f4b71Sopenharmony_ci        if (err.code) {
3214e41f4b71Sopenharmony_ci          console.error(`Failed to hide the non-system floating windows. Cause code: ${err.code}, message: ${err.message}`);
3215e41f4b71Sopenharmony_ci          return;
3216e41f4b71Sopenharmony_ci        }
3217e41f4b71Sopenharmony_ci        console.info('Succeeded in hiding the non-system floating windows.');
3218e41f4b71Sopenharmony_ci      });
3219e41f4b71Sopenharmony_ci    });
3220e41f4b71Sopenharmony_ci  }
3221e41f4b71Sopenharmony_ci}
3222e41f4b71Sopenharmony_ci```
3223e41f4b71Sopenharmony_ci
3224e41f4b71Sopenharmony_ci### hideNonSystemFloatingWindows<sup>11+</sup>
3225e41f4b71Sopenharmony_ci
3226e41f4b71Sopenharmony_cihideNonSystemFloatingWindows(shouldHide: boolean): Promise&lt;void&gt;
3227e41f4b71Sopenharmony_ci
3228e41f4b71Sopenharmony_ci设置是否隐藏非系统级悬浮窗口。使用callback异步回调。
3229e41f4b71Sopenharmony_ci
3230e41f4b71Sopenharmony_ci非系统级悬浮窗口是指非系统应用创建的悬浮窗口。默认情况下,一个系统应用主窗口可以与非系统级悬浮窗口共同显示,即该主窗口可以被上层的非系统级悬浮窗口遮挡,如果设置为true,则所有的非系统级悬浮窗口会被隐藏,此时该主窗口就不会被上层的非系统级悬浮窗口遮挡了。
3231e41f4b71Sopenharmony_ci
3232e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3233e41f4b71Sopenharmony_ci
3234e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3235e41f4b71Sopenharmony_ci
3236e41f4b71Sopenharmony_ci**参数:**
3237e41f4b71Sopenharmony_ci
3238e41f4b71Sopenharmony_ci| 参数名      | 类型                      | 必填 | 说明       |
3239e41f4b71Sopenharmony_ci| ----------- | ------------------------- | ---- | ---------- |
3240e41f4b71Sopenharmony_ci| shouldHide  | boolean                   | 是   | 指示是否隐藏非系统级的悬浮窗口,true表示隐藏,false表示不隐藏。 |
3241e41f4b71Sopenharmony_ci
3242e41f4b71Sopenharmony_ci**返回值:**
3243e41f4b71Sopenharmony_ci
3244e41f4b71Sopenharmony_ci| 类型                | 说明                      |
3245e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
3246e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3247e41f4b71Sopenharmony_ci
3248e41f4b71Sopenharmony_ci**错误码:**
3249e41f4b71Sopenharmony_ci
3250e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
3251e41f4b71Sopenharmony_ci
3252e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3253e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
3254e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3255e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3256e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
3257e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
3258e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
3259e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation. |
3260e41f4b71Sopenharmony_ci
3261e41f4b71Sopenharmony_ci**示例:**
3262e41f4b71Sopenharmony_ci
3263e41f4b71Sopenharmony_ci```ts
3264e41f4b71Sopenharmony_ci// EntryAbility.ets
3265e41f4b71Sopenharmony_ciimport { UIAbility, Want } from '@kit.AbilityKit';
3266e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3267e41f4b71Sopenharmony_ci
3268e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
3269e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage) {
3270e41f4b71Sopenharmony_ci    // 加载主窗口对应的页面
3271e41f4b71Sopenharmony_ci    windowStage.loadContent('pages/Index', (err) => {
3272e41f4b71Sopenharmony_ci      if (err.code) {
3273e41f4b71Sopenharmony_ci        console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`);
3274e41f4b71Sopenharmony_ci        return;
3275e41f4b71Sopenharmony_ci      }
3276e41f4b71Sopenharmony_ci      console.info('Succeeded in loading the content.');
3277e41f4b71Sopenharmony_ci    });
3278e41f4b71Sopenharmony_ci
3279e41f4b71Sopenharmony_ci    // 获取应用主窗口。
3280e41f4b71Sopenharmony_ci    let mainWindow: window.Window | undefined = undefined;
3281e41f4b71Sopenharmony_ci    windowStage.getMainWindow((err, data) => {
3282e41f4b71Sopenharmony_ci      if (err.code) {
3283e41f4b71Sopenharmony_ci        console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
3284e41f4b71Sopenharmony_ci        return;
3285e41f4b71Sopenharmony_ci      }
3286e41f4b71Sopenharmony_ci      mainWindow = data;
3287e41f4b71Sopenharmony_ci      console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
3288e41f4b71Sopenharmony_ci
3289e41f4b71Sopenharmony_ci      let shouldHide = true;
3290e41f4b71Sopenharmony_ci      // 调用hideNonSystemFloatingWindows接口,获取promise对象
3291e41f4b71Sopenharmony_ci      let promise = mainWindow.hideNonSystemFloatingWindows(shouldHide);
3292e41f4b71Sopenharmony_ci      promise.then(()=> {
3293e41f4b71Sopenharmony_ci        console.info('Succeeded in hiding the non-system floating windows.');
3294e41f4b71Sopenharmony_ci      }).catch((err: BusinessError)=>{
3295e41f4b71Sopenharmony_ci        console.error(`Failed to hide the non-system floating windows. Cause code: ${err.code}, message: ${err.message}`);
3296e41f4b71Sopenharmony_ci      });
3297e41f4b71Sopenharmony_ci    });
3298e41f4b71Sopenharmony_ci  }
3299e41f4b71Sopenharmony_ci}
3300e41f4b71Sopenharmony_ci```
3301e41f4b71Sopenharmony_ci
3302e41f4b71Sopenharmony_ci### setTopmost<sup>12+</sup>
3303e41f4b71Sopenharmony_ci
3304e41f4b71Sopenharmony_cisetTopmost(isTopmost: boolean): Promise&lt;void&gt;
3305e41f4b71Sopenharmony_ci
3306e41f4b71Sopenharmony_ci系统应用主窗口调用,实现将窗口置于所有应用窗口之上不被遮挡,使用Promise异步回调。
3307e41f4b71Sopenharmony_ci
3308e41f4b71Sopenharmony_ci仅对2in1设备的悬浮窗口生效。
3309e41f4b71Sopenharmony_ci
3310e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3311e41f4b71Sopenharmony_ci
3312e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3313e41f4b71Sopenharmony_ci
3314e41f4b71Sopenharmony_ci**参数:**
3315e41f4b71Sopenharmony_ci
3316e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
3317e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
3318e41f4b71Sopenharmony_ci| isTopmost | boolean | 是   | 是否将系统应用主窗口置顶,true表示置顶,false表示取消置顶。 |
3319e41f4b71Sopenharmony_ci
3320e41f4b71Sopenharmony_ci**返回值:**
3321e41f4b71Sopenharmony_ci
3322e41f4b71Sopenharmony_ci| 类型                | 说明                      |
3323e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
3324e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3325e41f4b71Sopenharmony_ci
3326e41f4b71Sopenharmony_ci**错误码:**
3327e41f4b71Sopenharmony_ci
3328e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
3329e41f4b71Sopenharmony_ci
3330e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3331e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
3332e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3333e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3334e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
3335e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                |
3336e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
3337e41f4b71Sopenharmony_ci| 1300004 | Unauthorized operation.                       |
3338e41f4b71Sopenharmony_ci
3339e41f4b71Sopenharmony_ci**示例:**
3340e41f4b71Sopenharmony_ci
3341e41f4b71Sopenharmony_ci```ts
3342e41f4b71Sopenharmony_ci// EntryAbility.ets
3343e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
3344e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3345e41f4b71Sopenharmony_ci
3346e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
3347e41f4b71Sopenharmony_ci  // ...
3348e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
3349e41f4b71Sopenharmony_ci    // ...
3350e41f4b71Sopenharmony_ci    windowStage.getMainWindow().then((window) => {
3351e41f4b71Sopenharmony_ci      let isTopmost: boolean = true;
3352e41f4b71Sopenharmony_ci      let promise = window.setTopmost(isTopmost);
3353e41f4b71Sopenharmony_ci      promise.then(() => {
3354e41f4b71Sopenharmony_ci        console.info('Succeeded in setting the main window to be topmost.');
3355e41f4b71Sopenharmony_ci      }).catch((err: BusinessError) => {
3356e41f4b71Sopenharmony_ci        console.error(`Failed to set the main window to be topmost. Cause code: ${err.code}, message: ${err.message}`);
3357e41f4b71Sopenharmony_ci      });
3358e41f4b71Sopenharmony_ci    });
3359e41f4b71Sopenharmony_ci  }
3360e41f4b71Sopenharmony_ci}
3361e41f4b71Sopenharmony_ci```
3362e41f4b71Sopenharmony_ci
3363e41f4b71Sopenharmony_ci### setSingleFrameComposerEnabled<sup>11+</sup>
3364e41f4b71Sopenharmony_ci
3365e41f4b71Sopenharmony_cisetSingleFrameComposerEnabled(enable: boolean): Promise&lt;void&gt;
3366e41f4b71Sopenharmony_ci
3367e41f4b71Sopenharmony_ci禁止/使能单帧合成渲染节点的功能。使用Promise异步回调。
3368e41f4b71Sopenharmony_ci
3369e41f4b71Sopenharmony_ci单帧合成渲染节点的功能主要用于跟手性要求较高的场景,使能该功能之后可以降低渲染节点的上屏延时。通过setSingleFrameComposerEnabled接口,如果enable设置为true,则使能单帧合成渲染节点的功能,否则禁止单帧合成渲染节点的功能。
3370e41f4b71Sopenharmony_ci
3371e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3372e41f4b71Sopenharmony_ci
3373e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3374e41f4b71Sopenharmony_ci
3375e41f4b71Sopenharmony_ci**参数:**
3376e41f4b71Sopenharmony_ci
3377e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
3378e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
3379e41f4b71Sopenharmony_ci| enable   | boolean                   | 是   | 设置单帧合成渲染节点的功能是否使能,true表示使能,false表示禁止。 |
3380e41f4b71Sopenharmony_ci
3381e41f4b71Sopenharmony_ci**返回值:**
3382e41f4b71Sopenharmony_ci
3383e41f4b71Sopenharmony_ci| 类型                | 说明                      |
3384e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
3385e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3386e41f4b71Sopenharmony_ci
3387e41f4b71Sopenharmony_ci**错误码:**
3388e41f4b71Sopenharmony_ci
3389e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
3390e41f4b71Sopenharmony_ci
3391e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3392e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
3393e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3394e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3395e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
3396e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
3397e41f4b71Sopenharmony_ci
3398e41f4b71Sopenharmony_ci**示例:**
3399e41f4b71Sopenharmony_ci
3400e41f4b71Sopenharmony_ci```ts
3401e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3402e41f4b71Sopenharmony_ci
3403e41f4b71Sopenharmony_cilet enable = true;
3404e41f4b71Sopenharmony_cilet promise = windowClass.setSingleFrameComposerEnabled(enable);
3405e41f4b71Sopenharmony_cipromise.then(()=> {
3406e41f4b71Sopenharmony_ci    console.info('Succeeded in enabling the single-frame-composer function.');
3407e41f4b71Sopenharmony_ci}).catch((err: BusinessError)=>{
3408e41f4b71Sopenharmony_ci    console.error(`Failed to enable the single-frame-composer function. code:${err.code}, message:${err.message}.`);
3409e41f4b71Sopenharmony_ci});
3410e41f4b71Sopenharmony_ci```
3411e41f4b71Sopenharmony_ci
3412e41f4b71Sopenharmony_ci### setTitleButtonVisible<sup>12+</sup>
3413e41f4b71Sopenharmony_ci
3414e41f4b71Sopenharmony_cisetTitleButtonVisible(isMaximizeVisible: boolean, isMinimizeVisible: boolean, isSplitVisible: boolean): void
3415e41f4b71Sopenharmony_ci
3416e41f4b71Sopenharmony_ci设置主窗标题栏上的最大化、最小化、分屏按钮是否可见。
3417e41f4b71Sopenharmony_ci
3418e41f4b71Sopenharmony_ci此接口仅支持2in1设备且仅对在当前场景下可见的标题栏按钮(最大化、最小化、分屏)生效。
3419e41f4b71Sopenharmony_ci
3420e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3421e41f4b71Sopenharmony_ci
3422e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3423e41f4b71Sopenharmony_ci
3424e41f4b71Sopenharmony_ci**参数:**
3425e41f4b71Sopenharmony_ci
3426e41f4b71Sopenharmony_ci| 参数名    | 类型    | 必填 | 说明                                          |
3427e41f4b71Sopenharmony_ci| --------- | ------- | ---- | --------------------------------------------- |
3428e41f4b71Sopenharmony_ci| isMaximizeVisible | boolean | 是   | 设置最大化按钮是否可见,true为可见,false为隐藏。 |
3429e41f4b71Sopenharmony_ci| isMinimizeVisible | boolean | 是   | 设置最小化按钮是否可见,true为可见,false为隐藏。 |
3430e41f4b71Sopenharmony_ci| isSplitVisible | boolean | 是   | 设置分屏按钮是否可见,true为可见,false为隐藏。 |
3431e41f4b71Sopenharmony_ci
3432e41f4b71Sopenharmony_ci**错误码:**
3433e41f4b71Sopenharmony_ci
3434e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
3435e41f4b71Sopenharmony_ci
3436e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                       |
3437e41f4b71Sopenharmony_ci| -------- | ------------------------------ |
3438e41f4b71Sopenharmony_ci| 202      | Permission verification failed. A non-system application calls a system API. |
3439e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3440e41f4b71Sopenharmony_ci| 801      | Capability not supported. Failed to call the API due to limited device capabilities. |
3441e41f4b71Sopenharmony_ci| 1300002  | This window state is abnormal. |
3442e41f4b71Sopenharmony_ci| 1300004  | Unauthorized operation. |
3443e41f4b71Sopenharmony_ci
3444e41f4b71Sopenharmony_ci**示例:**
3445e41f4b71Sopenharmony_ci
3446e41f4b71Sopenharmony_ci```ts
3447e41f4b71Sopenharmony_ci// EntryAbility.ets
3448e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
3449e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3450e41f4b71Sopenharmony_ci
3451e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
3452e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage): void {
3453e41f4b71Sopenharmony_ci    // 加载主窗口对应的页面
3454e41f4b71Sopenharmony_ci    windowStage.loadContent('pages/Index', (err) => {
3455e41f4b71Sopenharmony_ci      let mainWindow: window.Window | undefined = undefined;
3456e41f4b71Sopenharmony_ci      // 获取应用主窗口。
3457e41f4b71Sopenharmony_ci      windowStage.getMainWindow().then(
3458e41f4b71Sopenharmony_ci        data => {
3459e41f4b71Sopenharmony_ci          mainWindow = data;
3460e41f4b71Sopenharmony_ci          console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
3461e41f4b71Sopenharmony_ci          // 调用setTitleButtonVisible接口,隐藏主窗标题栏最大化、最小化、分屏按钮。
3462e41f4b71Sopenharmony_ci          mainWindow.setTitleButtonVisible(false, false, false);
3463e41f4b71Sopenharmony_ci        }
3464e41f4b71Sopenharmony_ci      ).catch((err: BusinessError) => {
3465e41f4b71Sopenharmony_ci          if(err.code){
3466e41f4b71Sopenharmony_ci            console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
3467e41f4b71Sopenharmony_ci          }
3468e41f4b71Sopenharmony_ci      });
3469e41f4b71Sopenharmony_ci    });
3470e41f4b71Sopenharmony_ci  }
3471e41f4b71Sopenharmony_ci}
3472e41f4b71Sopenharmony_ci```
3473e41f4b71Sopenharmony_ci
3474e41f4b71Sopenharmony_ci### setWindowType<sup>(deprecated)</sup>
3475e41f4b71Sopenharmony_ci
3476e41f4b71Sopenharmony_cisetWindowType(type: WindowType, callback: AsyncCallback&lt;void&gt;): void
3477e41f4b71Sopenharmony_ci
3478e41f4b71Sopenharmony_ci设置窗口类型,使用callback异步回调。
3479e41f4b71Sopenharmony_ci
3480e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3481e41f4b71Sopenharmony_ci
3482e41f4b71Sopenharmony_ci> **说明:**
3483e41f4b71Sopenharmony_ci>
3484e41f4b71Sopenharmony_ci> 从 API version 7开始支持,从API version 9开始废弃。
3485e41f4b71Sopenharmony_ci
3486e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3487e41f4b71Sopenharmony_ci
3488e41f4b71Sopenharmony_ci**参数:**
3489e41f4b71Sopenharmony_ci
3490e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
3491e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
3492e41f4b71Sopenharmony_ci| type     | [WindowType](#windowtype7) | 是   | 窗口类型。 |
3493e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
3494e41f4b71Sopenharmony_ci
3495e41f4b71Sopenharmony_ci**示例:**
3496e41f4b71Sopenharmony_ci
3497e41f4b71Sopenharmony_ci```ts
3498e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3499e41f4b71Sopenharmony_ci
3500e41f4b71Sopenharmony_cilet type = window.WindowType.TYPE_SYSTEM_ALERT;
3501e41f4b71Sopenharmony_ciwindowClass.setWindowType(type, (err: BusinessError) => {
3502e41f4b71Sopenharmony_ci  const errCode: number = err.code;
3503e41f4b71Sopenharmony_ci  if (errCode) {
3504e41f4b71Sopenharmony_ci    console.error(`Failed to set the window type. Cause code: ${err.code}, message: ${err.message}`);
3505e41f4b71Sopenharmony_ci    return;
3506e41f4b71Sopenharmony_ci  }
3507e41f4b71Sopenharmony_ci  console.info('Succeeded in setting the window type.');
3508e41f4b71Sopenharmony_ci});
3509e41f4b71Sopenharmony_ci```
3510e41f4b71Sopenharmony_ci
3511e41f4b71Sopenharmony_ci### setWindowType<sup>(deprecated)</sup>
3512e41f4b71Sopenharmony_ci
3513e41f4b71Sopenharmony_cisetWindowType(type: WindowType): Promise&lt;void&gt;
3514e41f4b71Sopenharmony_ci
3515e41f4b71Sopenharmony_ci设置窗口类型,使用Promise异步回调。
3516e41f4b71Sopenharmony_ci
3517e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3518e41f4b71Sopenharmony_ci
3519e41f4b71Sopenharmony_ci> **说明:**
3520e41f4b71Sopenharmony_ci>
3521e41f4b71Sopenharmony_ci> 从 API version 7开始支持,从API version 9开始废弃。
3522e41f4b71Sopenharmony_ci
3523e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3524e41f4b71Sopenharmony_ci
3525e41f4b71Sopenharmony_ci**参数:**
3526e41f4b71Sopenharmony_ci
3527e41f4b71Sopenharmony_ci| 参数名 | 类型                      | 必填 | 说明       |
3528e41f4b71Sopenharmony_ci| ------ | ------------------------- | ---- | ---------- |
3529e41f4b71Sopenharmony_ci| type   | [WindowType](#windowtype7) | 是   | 窗口类型。 |
3530e41f4b71Sopenharmony_ci
3531e41f4b71Sopenharmony_ci**返回值:**
3532e41f4b71Sopenharmony_ci
3533e41f4b71Sopenharmony_ci| 类型                | 说明                      |
3534e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
3535e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3536e41f4b71Sopenharmony_ci
3537e41f4b71Sopenharmony_ci**示例:**
3538e41f4b71Sopenharmony_ci
3539e41f4b71Sopenharmony_ci```ts
3540e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3541e41f4b71Sopenharmony_ci
3542e41f4b71Sopenharmony_cilet type = window.WindowType.TYPE_SYSTEM_ALERT;
3543e41f4b71Sopenharmony_cilet promise = windowClass.setWindowType(type);
3544e41f4b71Sopenharmony_cipromise.then(() => {
3545e41f4b71Sopenharmony_ci  console.info('Succeeded in setting the window type.');
3546e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3547e41f4b71Sopenharmony_ci  console.error(`Failed to set the window type. Cause code: ${err.code}, message: ${err.message}`);
3548e41f4b71Sopenharmony_ci});
3549e41f4b71Sopenharmony_ci```
3550e41f4b71Sopenharmony_ci
3551e41f4b71Sopenharmony_ci### requestFocus<sup>13+</sup>
3552e41f4b71Sopenharmony_ci
3553e41f4b71Sopenharmony_cirequestFocus(isFocused: boolean): Promise&lt;void&gt;
3554e41f4b71Sopenharmony_ci
3555e41f4b71Sopenharmony_ci支持当前窗口主动请求获焦/失焦,使用Promise异步回调。调用成功即返回,该接口返回值不代表最终获焦/失焦生效结果。可使用[on('windowEvent')](js-apis-window.md#onwindowevent10)监听窗口获焦/失焦状态。
3556e41f4b71Sopenharmony_ci
3557e41f4b71Sopenharmony_ci获焦请求发送后,窗口获焦结果受到窗口可获焦属性及窗口可见状态的限制。获焦成功的窗口需满足以下约束:1.窗口支持获焦;2.窗口可见(窗口已显示,未销毁且未退至后台)。
3558e41f4b71Sopenharmony_ci
3559e41f4b71Sopenharmony_ci失焦请求发送后,窗口无条件失焦。
3560e41f4b71Sopenharmony_ci
3561e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3562e41f4b71Sopenharmony_ci
3563e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3564e41f4b71Sopenharmony_ci
3565e41f4b71Sopenharmony_ci**参数:**
3566e41f4b71Sopenharmony_ci
3567e41f4b71Sopenharmony_ci| 参数名   | 类型                      | 必填 | 说明       |
3568e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------- |
3569e41f4b71Sopenharmony_ci| isFocused | boolean | 是   | 是否获取焦点,true表示请求获焦,false表示请求失焦。 |
3570e41f4b71Sopenharmony_ci
3571e41f4b71Sopenharmony_ci**返回值:**
3572e41f4b71Sopenharmony_ci
3573e41f4b71Sopenharmony_ci| 类型                | 说明                      |
3574e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
3575e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
3576e41f4b71Sopenharmony_ci
3577e41f4b71Sopenharmony_ci**错误码:**
3578e41f4b71Sopenharmony_ci
3579e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
3580e41f4b71Sopenharmony_ci
3581e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3582e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
3583e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3584e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3585e41f4b71Sopenharmony_ci| 801     | Capability not supported. Failed to call the API due to limited device capabilities. |
3586e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal.                |
3587e41f4b71Sopenharmony_ci| 1300003 | This window manager service works abnormally. |
3588e41f4b71Sopenharmony_ci
3589e41f4b71Sopenharmony_ci**示例:**
3590e41f4b71Sopenharmony_ci
3591e41f4b71Sopenharmony_ci```ts
3592e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3593e41f4b71Sopenharmony_ci
3594e41f4b71Sopenharmony_cilet isFocused: boolean = true;
3595e41f4b71Sopenharmony_cilet promise = windowClass.requestFocus(isFocused);
3596e41f4b71Sopenharmony_cipromise.then(() => {
3597e41f4b71Sopenharmony_ci  console.info('Succeeded in requesting focus.');
3598e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3599e41f4b71Sopenharmony_ci  console.error(`Failed to request focus. Cause code: ${err.code}, message: ${err.message}`);
3600e41f4b71Sopenharmony_ci});
3601e41f4b71Sopenharmony_ci```
3602e41f4b71Sopenharmony_ci
3603e41f4b71Sopenharmony_ci## SubWindowOptions<sup>11+</sup>
3604e41f4b71Sopenharmony_ci
3605e41f4b71Sopenharmony_ci子窗口创建参数。
3606e41f4b71Sopenharmony_ci
3607e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3608e41f4b71Sopenharmony_ci
3609e41f4b71Sopenharmony_ci| 名称      | 类型  | 只读 | 可选 | 说明         |
3610e41f4b71Sopenharmony_ci| ---------- | ---- | ---- | ---- | ----------- |
3611e41f4b71Sopenharmony_ci| isTopmost<sup>12+</sup>  | boolean | 否 | 是 | 子窗口是否启用置顶属性。true表示子窗口置顶,false表示子窗口不置顶。不设置,则默认为false。       |
3612e41f4b71Sopenharmony_ci
3613e41f4b71Sopenharmony_ci## WindowStage<sup>9+</sup>
3614e41f4b71Sopenharmony_ci
3615e41f4b71Sopenharmony_ci窗口管理器。管理各个基本窗口单元,即[Window](#window)实例。
3616e41f4b71Sopenharmony_ci
3617e41f4b71Sopenharmony_ci下列API示例中都需在[onWindowStageCreate()](../apis-ability-kit/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate)函数中使用WindowStage的实例调用对应方法。
3618e41f4b71Sopenharmony_ci
3619e41f4b71Sopenharmony_ci### disableWindowDecor<sup>9+</sup>
3620e41f4b71Sopenharmony_ci
3621e41f4b71Sopenharmony_cidisableWindowDecor(): void
3622e41f4b71Sopenharmony_ci
3623e41f4b71Sopenharmony_ci禁止窗口装饰。
3624e41f4b71Sopenharmony_ci
3625e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。
3626e41f4b71Sopenharmony_ci
3627e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3628e41f4b71Sopenharmony_ci
3629e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3630e41f4b71Sopenharmony_ci
3631e41f4b71Sopenharmony_ci**错误码:**
3632e41f4b71Sopenharmony_ci
3633e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
3634e41f4b71Sopenharmony_ci
3635e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3636e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
3637e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3638e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
3639e41f4b71Sopenharmony_ci| 1300005 | This window stage is abnormal. |
3640e41f4b71Sopenharmony_ci
3641e41f4b71Sopenharmony_ci**示例:**
3642e41f4b71Sopenharmony_ci
3643e41f4b71Sopenharmony_ci```ts
3644e41f4b71Sopenharmony_ci// EntryAbility.ets
3645e41f4b71Sopenharmony_ciimport { UIAbility, Want } from '@kit.AbilityKit';
3646e41f4b71Sopenharmony_ci
3647e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
3648e41f4b71Sopenharmony_ci  // ...
3649e41f4b71Sopenharmony_ci
3650e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage) {
3651e41f4b71Sopenharmony_ci    console.log('disableWindowDecor');
3652e41f4b71Sopenharmony_ci    windowStage.disableWindowDecor();
3653e41f4b71Sopenharmony_ci  }
3654e41f4b71Sopenharmony_ci};
3655e41f4b71Sopenharmony_ci```
3656e41f4b71Sopenharmony_ci
3657e41f4b71Sopenharmony_ci### setShowOnLockScreen<sup>9+</sup>
3658e41f4b71Sopenharmony_ci
3659e41f4b71Sopenharmony_cisetShowOnLockScreen(showOnLockScreen: boolean): void
3660e41f4b71Sopenharmony_ci
3661e41f4b71Sopenharmony_ci设置应用显示在锁屏之上。
3662e41f4b71Sopenharmony_ci
3663e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3664e41f4b71Sopenharmony_ci
3665e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。
3666e41f4b71Sopenharmony_ci
3667e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3668e41f4b71Sopenharmony_ci
3669e41f4b71Sopenharmony_ci**参数:**
3670e41f4b71Sopenharmony_ci
3671e41f4b71Sopenharmony_ci| 参数名           | 类型    | 必填 | 说明                         |
3672e41f4b71Sopenharmony_ci| ---------------- | ------- | ---- | ---------------------------- |
3673e41f4b71Sopenharmony_ci| showOnLockScreen | boolean | 是   | 是否设置应用显示在锁屏之上。true表示显示在锁屏之上;false表示不显示在锁屏之上。 |
3674e41f4b71Sopenharmony_ci
3675e41f4b71Sopenharmony_ci**错误码:**
3676e41f4b71Sopenharmony_ci
3677e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[窗口错误码](errorcode-window.md)。
3678e41f4b71Sopenharmony_ci
3679e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3680e41f4b71Sopenharmony_ci| ------- | ------------------------------ |
3681e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3682e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3683e41f4b71Sopenharmony_ci| 1300002 | This window state is abnormal. |
3684e41f4b71Sopenharmony_ci| 1300005 | This window stage is abnormal. |
3685e41f4b71Sopenharmony_ci
3686e41f4b71Sopenharmony_ci**示例:**
3687e41f4b71Sopenharmony_ci
3688e41f4b71Sopenharmony_ci```ts
3689e41f4b71Sopenharmony_ci// EntryAbility.ets
3690e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
3691e41f4b71Sopenharmony_ci
3692e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
3693e41f4b71Sopenharmony_ci  // ...
3694e41f4b71Sopenharmony_ci
3695e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage) {
3696e41f4b71Sopenharmony_ci    console.log('onWindowStageCreate');
3697e41f4b71Sopenharmony_ci    try {
3698e41f4b71Sopenharmony_ci      windowStage.setShowOnLockScreen(true);
3699e41f4b71Sopenharmony_ci    } catch (exception) {
3700e41f4b71Sopenharmony_ci      console.error(`Failed to show on lockscreen. Cause code: ${exception.code}, message: ${exception.message}`);
3701e41f4b71Sopenharmony_ci    }
3702e41f4b71Sopenharmony_ci  }
3703e41f4b71Sopenharmony_ci};
3704e41f4b71Sopenharmony_ci```
3705e41f4b71Sopenharmony_ci
3706e41f4b71Sopenharmony_ci## TransitionContext<sup>9+</sup>
3707e41f4b71Sopenharmony_ci
3708e41f4b71Sopenharmony_ci属性转换的上下文信息。
3709e41f4b71Sopenharmony_ci
3710e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3711e41f4b71Sopenharmony_ci
3712e41f4b71Sopenharmony_ci### 属性
3713e41f4b71Sopenharmony_ci
3714e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3715e41f4b71Sopenharmony_ci
3716e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.WindowManager.WindowManager.Core
3717e41f4b71Sopenharmony_ci
3718e41f4b71Sopenharmony_ci| 名称                  | 类型          | 可读 | 可写 | 说明             |
3719e41f4b71Sopenharmony_ci| --------------------- | ----------------- | ---- | ---- | ---------------- |
3720e41f4b71Sopenharmony_ci| toWindow<sup>9+</sup> | [Window](#window) | 是   | 是   | 动画的目标窗口。 |
3721e41f4b71Sopenharmony_ci
3722e41f4b71Sopenharmony_ci### completeTransition<sup>9+</sup>
3723e41f4b71Sopenharmony_ci
3724e41f4b71Sopenharmony_cicompleteTransition(isCompleted: boolean): void
3725e41f4b71Sopenharmony_ci
3726e41f4b71Sopenharmony_ci设置属性转换的最终完成状态。该函数需要在动画函数[animateTo()](arkui-ts/ts-explicit-animation.md)执行后设置。
3727e41f4b71Sopenharmony_ci
3728e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3729e41f4b71Sopenharmony_ci
3730e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.WindowManager.WindowManager.Core
3731e41f4b71Sopenharmony_ci
3732e41f4b71Sopenharmony_ci**参数:**
3733e41f4b71Sopenharmony_ci
3734e41f4b71Sopenharmony_ci| 参数名      | 类型    | 必填 | 说明                                                         |
3735e41f4b71Sopenharmony_ci| ----------- | ------- | ---- | ------------------------------------------------------------ |
3736e41f4b71Sopenharmony_ci| isCompleted | boolean | 是   | 窗口属性转换是否完成。true表示完成本次转换;false表示撤销本次转换。 |
3737e41f4b71Sopenharmony_ci
3738e41f4b71Sopenharmony_ci**错误码:**
3739e41f4b71Sopenharmony_ci
3740e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
3741e41f4b71Sopenharmony_ci
3742e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3743e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
3744e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3745e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.               |
3746e41f4b71Sopenharmony_ci
3747e41f4b71Sopenharmony_ci**示例:**
3748e41f4b71Sopenharmony_ci
3749e41f4b71Sopenharmony_ci```ts
3750e41f4b71Sopenharmony_ci(context: window.TransitionContext) => {
3751e41f4b71Sopenharmony_ci  let toWindow: window.Window = context.toWindow;
3752e41f4b71Sopenharmony_ci  animateTo({
3753e41f4b71Sopenharmony_ci    duration: 1000, // 动画时长
3754e41f4b71Sopenharmony_ci    tempo: 0.5, // 播放速率
3755e41f4b71Sopenharmony_ci    curve: Curve.EaseInOut, // 动画曲线
3756e41f4b71Sopenharmony_ci    delay: 0, // 动画延迟
3757e41f4b71Sopenharmony_ci    iterations: 1, // 播放次数
3758e41f4b71Sopenharmony_ci    playMode: PlayMode.Normal, // 动画模式
3759e41f4b71Sopenharmony_ci  }, () => {
3760e41f4b71Sopenharmony_ci    let obj: window.TranslateOptions = {
3761e41f4b71Sopenharmony_ci      x: 100.0,
3762e41f4b71Sopenharmony_ci      y: 0.0,
3763e41f4b71Sopenharmony_ci      z: 0.0
3764e41f4b71Sopenharmony_ci    };
3765e41f4b71Sopenharmony_ci    toWindow.translate(obj);
3766e41f4b71Sopenharmony_ci    console.info('toWindow translate end');
3767e41f4b71Sopenharmony_ci  }
3768e41f4b71Sopenharmony_ci  );
3769e41f4b71Sopenharmony_ci  try {
3770e41f4b71Sopenharmony_ci    context.completeTransition(true)
3771e41f4b71Sopenharmony_ci  } catch (exception) {
3772e41f4b71Sopenharmony_ci    console.error(`toWindow translate fail. Cause code: ${exception.code}, message: ${exception.message}`);
3773e41f4b71Sopenharmony_ci  }
3774e41f4b71Sopenharmony_ci  console.info('complete transition end');
3775e41f4b71Sopenharmony_ci};
3776e41f4b71Sopenharmony_ci```
3777e41f4b71Sopenharmony_ci
3778e41f4b71Sopenharmony_ci## TransitionController<sup>9+</sup>
3779e41f4b71Sopenharmony_ci
3780e41f4b71Sopenharmony_ci属性转换控制器。使用其子接口之前得先创建系统窗口,参照示例代码。
3781e41f4b71Sopenharmony_ci
3782e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3783e41f4b71Sopenharmony_ci
3784e41f4b71Sopenharmony_ci**示例:**
3785e41f4b71Sopenharmony_ci
3786e41f4b71Sopenharmony_ci```ts
3787e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3788e41f4b71Sopenharmony_ci
3789e41f4b71Sopenharmony_cilet windowClass: window.Window | undefined = undefined;
3790e41f4b71Sopenharmony_cilet config: window.Configuration = {
3791e41f4b71Sopenharmony_ci  name: "systemTypeWindow",
3792e41f4b71Sopenharmony_ci  windowType: window.WindowType.TYPE_PANEL, //根据需要自选系统窗口类型
3793e41f4b71Sopenharmony_ci  ctx: this.context
3794e41f4b71Sopenharmony_ci};
3795e41f4b71Sopenharmony_cilet promise = window.createWindow(config);
3796e41f4b71Sopenharmony_cipromise.then((data) => {
3797e41f4b71Sopenharmony_ci  windowClass = data;
3798e41f4b71Sopenharmony_ci  console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
3799e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
3800e41f4b71Sopenharmony_ci  console.error(`Failed to create the Window. Cause code: ${err.code}, message: ${err.message}`);
3801e41f4b71Sopenharmony_ci});
3802e41f4b71Sopenharmony_ci```
3803e41f4b71Sopenharmony_ci
3804e41f4b71Sopenharmony_ci### animationForShown<sup>9+</sup>
3805e41f4b71Sopenharmony_ci
3806e41f4b71Sopenharmony_cianimationForShown(context: TransitionContext): void
3807e41f4b71Sopenharmony_ci
3808e41f4b71Sopenharmony_ci窗口显示时的自定义动画配置。
3809e41f4b71Sopenharmony_ci
3810e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3811e41f4b71Sopenharmony_ci
3812e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3813e41f4b71Sopenharmony_ci
3814e41f4b71Sopenharmony_ci**参数:**
3815e41f4b71Sopenharmony_ci
3816e41f4b71Sopenharmony_ci| 参数名  | 类型                                     | 必填 | 说明                 |
3817e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | ---- | -------------------- |
3818e41f4b71Sopenharmony_ci| context | [TransitionContext](#transitioncontext9) | 是   | 属性转换时的上下文。 |
3819e41f4b71Sopenharmony_ci
3820e41f4b71Sopenharmony_ci**错误码:**
3821e41f4b71Sopenharmony_ci
3822e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
3823e41f4b71Sopenharmony_ci
3824e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3825e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
3826e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3827e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.               |
3828e41f4b71Sopenharmony_ci
3829e41f4b71Sopenharmony_ci**示例:**
3830e41f4b71Sopenharmony_ci
3831e41f4b71Sopenharmony_ci```ts
3832e41f4b71Sopenharmony_ci// xxx.ts
3833e41f4b71Sopenharmony_ciexport class AnimationConfig {
3834e41f4b71Sopenharmony_ci  private animationForShownCallFunc_: Function = undefined;
3835e41f4b71Sopenharmony_ci  ShowWindowWithCustomAnimation(windowClass: window.Window, callback) {
3836e41f4b71Sopenharmony_ci    if (!windowClass) {
3837e41f4b71Sopenharmony_ci      console.error('windowClass is undefined');
3838e41f4b71Sopenharmony_ci      return false;
3839e41f4b71Sopenharmony_ci    }
3840e41f4b71Sopenharmony_ci    this.animationForShownCallFunc_ = callback;
3841e41f4b71Sopenharmony_ci    let controller: window.TransitionController = windowClass.getTransitionController();
3842e41f4b71Sopenharmony_ci    controller.animationForShown = (context : window.TransitionContext)=> {
3843e41f4b71Sopenharmony_ci      this.animationForShownCallFunc_(context);
3844e41f4b71Sopenharmony_ci    };
3845e41f4b71Sopenharmony_ci    windowClass.showWithAnimation(()=>{
3846e41f4b71Sopenharmony_ci      console.info('Show with animation success');
3847e41f4b71Sopenharmony_ci    });
3848e41f4b71Sopenharmony_ci  }
3849e41f4b71Sopenharmony_ci}
3850e41f4b71Sopenharmony_ci```
3851e41f4b71Sopenharmony_ci
3852e41f4b71Sopenharmony_ci```ts
3853e41f4b71Sopenharmony_ci// xxx.ets
3854e41f4b71Sopenharmony_cilet animationConfig = new AnimationConfig();
3855e41f4b71Sopenharmony_cilet systemTypeWindow = window.findWindow("systemTypeWindow"); // 此处需要获取一个系统类型窗口。
3856e41f4b71Sopenharmony_citry {
3857e41f4b71Sopenharmony_ci  animationConfig?.ShowWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{
3858e41f4b71Sopenharmony_ci    console.info('complete transition end');
3859e41f4b71Sopenharmony_ci    let toWindow = context.toWindow;
3860e41f4b71Sopenharmony_ci    animateTo({
3861e41f4b71Sopenharmony_ci      duration: 1000, // 动画时长
3862e41f4b71Sopenharmony_ci      tempo: 0.5, // 播放速率
3863e41f4b71Sopenharmony_ci      curve: Curve.EaseInOut, // 动画曲线
3864e41f4b71Sopenharmony_ci      delay: 0, // 动画延迟
3865e41f4b71Sopenharmony_ci      iterations: 1, // 播放次数
3866e41f4b71Sopenharmony_ci      playMode: PlayMode.Normal, // 动画模式
3867e41f4b71Sopenharmony_ci      onFinish: () => {
3868e41f4b71Sopenharmony_ci        console.info('onFinish in animation');
3869e41f4b71Sopenharmony_ci        context.completeTransition(true)
3870e41f4b71Sopenharmony_ci      }
3871e41f4b71Sopenharmony_ci    }, () => {
3872e41f4b71Sopenharmony_ci      let obj : window.TranslateOptions = {
3873e41f4b71Sopenharmony_ci        x : 100.0,
3874e41f4b71Sopenharmony_ci        y : 0.0,
3875e41f4b71Sopenharmony_ci        z : 0.0
3876e41f4b71Sopenharmony_ci      };
3877e41f4b71Sopenharmony_ci      toWindow.translate(obj); // 设置动画过程中的属性转换
3878e41f4b71Sopenharmony_ci      console.info('toWindow translate end in animation');
3879e41f4b71Sopenharmony_ci    });
3880e41f4b71Sopenharmony_ci    console.info('complete transition end');
3881e41f4b71Sopenharmony_ci  });
3882e41f4b71Sopenharmony_ci} catch (error) {
3883e41f4b71Sopenharmony_ci  console.error(`ShowWindowWithCustomAnimation error code: ${error.code}, message: ${error.message}`);
3884e41f4b71Sopenharmony_ci}
3885e41f4b71Sopenharmony_ci```
3886e41f4b71Sopenharmony_ci
3887e41f4b71Sopenharmony_ci### animationForHidden<sup>9+</sup>
3888e41f4b71Sopenharmony_ci
3889e41f4b71Sopenharmony_cianimationForHidden(context: TransitionContext): void
3890e41f4b71Sopenharmony_ci
3891e41f4b71Sopenharmony_ci窗口隐藏时的自定义动画配置。
3892e41f4b71Sopenharmony_ci
3893e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3894e41f4b71Sopenharmony_ci
3895e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3896e41f4b71Sopenharmony_ci
3897e41f4b71Sopenharmony_ci**参数:**
3898e41f4b71Sopenharmony_ci
3899e41f4b71Sopenharmony_ci| 参数名  | 类型                                     | 必填 | 说明                 |
3900e41f4b71Sopenharmony_ci| ------- | ---------------------------------------- | ---- | -------------------- |
3901e41f4b71Sopenharmony_ci| context | [TransitionContext](#transitioncontext9) | 是   | 属性转换时的上下文。 |
3902e41f4b71Sopenharmony_ci
3903e41f4b71Sopenharmony_ci**错误码:**
3904e41f4b71Sopenharmony_ci
3905e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
3906e41f4b71Sopenharmony_ci
3907e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
3908e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
3909e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API. |
3910e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.               |
3911e41f4b71Sopenharmony_ci
3912e41f4b71Sopenharmony_ci**示例:**
3913e41f4b71Sopenharmony_ci
3914e41f4b71Sopenharmony_ci```ts
3915e41f4b71Sopenharmony_ci// xxx.ts
3916e41f4b71Sopenharmony_ciexport class AnimationConfig {
3917e41f4b71Sopenharmony_ci  private animationForHiddenCallFunc_: Function = undefined;
3918e41f4b71Sopenharmony_ci  HideWindowWithCustomAnimation(windowClass: window.Window, callback) {
3919e41f4b71Sopenharmony_ci    if (!windowClass) {
3920e41f4b71Sopenharmony_ci      console.error('windowClass is undefined');
3921e41f4b71Sopenharmony_ci      return false;
3922e41f4b71Sopenharmony_ci    }
3923e41f4b71Sopenharmony_ci    this.animationForHiddenCallFunc_ = callback;
3924e41f4b71Sopenharmony_ci    let controller: window.TransitionController = windowClass.getTransitionController();
3925e41f4b71Sopenharmony_ci    controller.animationForHidden = (context : window.TransitionContext)=> {
3926e41f4b71Sopenharmony_ci      this.animationForHiddenCallFunc_(context);
3927e41f4b71Sopenharmony_ci    };
3928e41f4b71Sopenharmony_ci    windowClass.hideWithAnimation(()=>{
3929e41f4b71Sopenharmony_ci      console.info('hide with animation success');
3930e41f4b71Sopenharmony_ci    });
3931e41f4b71Sopenharmony_ci  }
3932e41f4b71Sopenharmony_ci}
3933e41f4b71Sopenharmony_ci```
3934e41f4b71Sopenharmony_ci
3935e41f4b71Sopenharmony_ci```ts
3936e41f4b71Sopenharmony_ci// xxx.ets
3937e41f4b71Sopenharmony_cilet animationConfig = new AnimationConfig();
3938e41f4b71Sopenharmony_cilet systemTypeWindow = window.findWindow("systemTypeWindow"); // 此处需要获取一个系统类型窗口。
3939e41f4b71Sopenharmony_citry {
3940e41f4b71Sopenharmony_ci  animationConfig?.HideWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{
3941e41f4b71Sopenharmony_ci    console.info('complete transition end');
3942e41f4b71Sopenharmony_ci    let toWindow = context.toWindow;
3943e41f4b71Sopenharmony_ci    animateTo({
3944e41f4b71Sopenharmony_ci      duration: 1000, // 动画时长
3945e41f4b71Sopenharmony_ci      tempo: 0.5, // 播放速率
3946e41f4b71Sopenharmony_ci      curve: Curve.EaseInOut, // 动画曲线
3947e41f4b71Sopenharmony_ci      delay: 0, // 动画延迟
3948e41f4b71Sopenharmony_ci      iterations: 1, // 播放次数
3949e41f4b71Sopenharmony_ci      playMode: PlayMode.Normal, // 动画模式
3950e41f4b71Sopenharmony_ci      onFinish: () => {
3951e41f4b71Sopenharmony_ci        console.info('onFinish in animation');
3952e41f4b71Sopenharmony_ci        context.completeTransition(true)
3953e41f4b71Sopenharmony_ci      }
3954e41f4b71Sopenharmony_ci    }, () => {
3955e41f4b71Sopenharmony_ci      let obj : window.TranslateOptions = {
3956e41f4b71Sopenharmony_ci        x : 100.0,
3957e41f4b71Sopenharmony_ci        y : 0.0,
3958e41f4b71Sopenharmony_ci        z : 0.0
3959e41f4b71Sopenharmony_ci      };
3960e41f4b71Sopenharmony_ci      toWindow.translate(obj); // 设置动画过程中的属性转换
3961e41f4b71Sopenharmony_ci      console.info('toWindow translate end in animation');
3962e41f4b71Sopenharmony_ci    });
3963e41f4b71Sopenharmony_ci    console.info('complete transition end');
3964e41f4b71Sopenharmony_ci  });
3965e41f4b71Sopenharmony_ci} catch (error) {
3966e41f4b71Sopenharmony_ci  console.error(`HideWindowWithCustomAnimation error code: ${error.code}, message: ${error.message}` );
3967e41f4b71Sopenharmony_ci}
3968e41f4b71Sopenharmony_ci```
3969e41f4b71Sopenharmony_ci
3970e41f4b71Sopenharmony_ci## ExtensionWindowAttribute<sup>14+</sup>
3971e41f4b71Sopenharmony_ci
3972e41f4b71Sopenharmony_ci扩展窗口的属性枚举。
3973e41f4b71Sopenharmony_ci
3974e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。
3975e41f4b71Sopenharmony_ci
3976e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3977e41f4b71Sopenharmony_ci
3978e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3979e41f4b71Sopenharmony_ci
3980e41f4b71Sopenharmony_ci| 名称      | 值 | 说明         |
3981e41f4b71Sopenharmony_ci| ---------- | ----- | ----------- |
3982e41f4b71Sopenharmony_ci| SYSTEM_WINDOW  | 0 | 系统窗口。|
3983e41f4b71Sopenharmony_ci| SUB_WINDOW  | 1 | 子窗口。|
3984e41f4b71Sopenharmony_ci
3985e41f4b71Sopenharmony_ci## SystemWindowOptions<sup>14+</sup>
3986e41f4b71Sopenharmony_ci
3987e41f4b71Sopenharmony_ci系统窗口的创建参数。
3988e41f4b71Sopenharmony_ci
3989e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。
3990e41f4b71Sopenharmony_ci
3991e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
3992e41f4b71Sopenharmony_ci
3993e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
3994e41f4b71Sopenharmony_ci
3995e41f4b71Sopenharmony_ci| 名称 | 类型                      | 只读  |可选 | 说明       |
3996e41f4b71Sopenharmony_ci| ------ | ------------------------- | ---- | ---- |---------- |
3997e41f4b71Sopenharmony_ci| windowType   | [WindowType](#windowtype7) | 否   | 否   | 窗口类型。无默认类型,不配置会导致窗口创建失败。不支持TYPE_DIALOG类型。 |
3998e41f4b71Sopenharmony_ci
3999e41f4b71Sopenharmony_ci## ExtensionWindowConfig<sup>14+</sup>
4000e41f4b71Sopenharmony_ci
4001e41f4b71Sopenharmony_ci创建扩展窗口时需要配置的参数。
4002e41f4b71Sopenharmony_ci
4003e41f4b71Sopenharmony_ci**模型约束:** 此接口仅可在Stage模型下使用。
4004e41f4b71Sopenharmony_ci
4005e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
4006e41f4b71Sopenharmony_ci
4007e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Window.SessionManager
4008e41f4b71Sopenharmony_ci
4009e41f4b71Sopenharmony_ci| 名称 | 类型                      | 只读  |可选 | 说明       |
4010e41f4b71Sopenharmony_ci| ------ | ------------------------- | ---- | ---- |---------- |
4011e41f4b71Sopenharmony_ci| windowName   | string | 否 | 否  | 窗口名。 |
4012e41f4b71Sopenharmony_ci| windowAttribute   | [ExtensionWindowAttribute](#extensionwindowattribute14) | 否 | 否   | 窗口的属性。用于配置创建的窗口是子窗口还是系统窗口。当windowAttribute配置为SUB_WINDOW时须配置subWindowOptions,当windowAttribute配置为SYSTEM_WINDOW时须配置systemWindowOptions,否则创建窗口失败。|
4013e41f4b71Sopenharmony_ci| windowRect   | [Rect](js-apis-window.md#rect7) | 否 | 否   | 窗口矩形区域。 |
4014e41f4b71Sopenharmony_ci| subWindowOptions   | [SubWindowOptions](js-apis-window.md#subwindowoptions12) | 否 | 是 | 创建子窗口的参数。无默认参数,当windowAttribute配置为SUB_WINDOW时必选,否则会导致窗口创建失败。 |
4015e41f4b71Sopenharmony_ci| systemWindowOptions   | [SystemWindowOptions](#systemwindowoptions14) | 否 | 是 | 创建系统窗口的参数。无默认参数,当windowAttribute配置为SYSTEM_WINDOW时必选,否则会导致窗口创建失败。 |