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