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