大网数据广告活动
安装更新与部署

Authoring a ProgressBar Control

· 52CE 我爱测

Windows Installer contains functionality to display a progress indicator in an action display dialog.

Windows Installer contains functionality to display a progress indicator in an action display dialog. The ProgressBar control graphically represents the installation of individual components and reports either the total time elapsed relative to time remaining or the approximate total time remaining until the installation is complete.

To determine the total time anticipated for the installation, the installer tracks the total progress ticks anticipated by each action during generation of the execution script. When script generation is complete, the progress tick total is stored and the installation begins.

Progress messages detailing the elapsed number of progress ticks are sent to the active message handler as each action in the script is executed. On each progress message, the installer broadcasts a SetProgress ControlEvent to the currently active dialog box. The UI sequence should be authored to create the action display dialog box during script execution to receive the SetProgress ControlEvent messages from the installer.

When the action display dialog box receives a SetProgress ControlEvent, it checks the EventMapping table for any controls subscribing to the ControlEvent. The ProgressBar control on the action display dialog box is subscribed to with the Progress control attribute specified in the Attributes column. The Progress Control attribute specifies that the ProgressBar control will be passed "ticksSoFar" and "totalTicks" values along with the SetProgress ControlEvent. The progress bar control uses this information to advance the graphical bar from left to right for an installation and from right to left for a rollback operation.

In addition, the installer broadcasts a TimeRemaining ControlEvent on each progress message. The total time remaining for the installation is determined by first calculating the execution rate, which is the total number of ticks elapsed divided by the total time since the installation began. The total ticks remaining divided by the execution rate gives the approximate time remaining.

When the action display dialog box receives the TimeRemaining ControlEvent, it again looks in the EventMapping table for any controls that are subscribed. In order to display the time remaining, a Text control must be subscribed to the TimeRemaining ControlEvent with the TimeRemaining control attribute specified in the Attributes column.

The subscribed Text control queries the UIText table for a parameterized template string named "TimeRemaining". This string has two parameters, [1] for minutes, and [2] for seconds. The Text control converts each value to minutes and seconds, evaluates the TimeRemaining template string, and updates the text control with the new information.

If the UI display level is set to basic or lower, the installer displays a default dialog box containing a progress bar and TimeRemaining text field. For more information, see User Interface Levels.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。