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