如何在Inno Setup中更改进度栏的颜色? [英] How do I change the color of my progress bar in Inno Setup?

查看:151
本文介绍了如何在Inno Setup中更改进度栏的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用TNewProgressBar创建进度条.
进度栏的默认颜色为绿色.
我想将颜色更改为蓝色.

I create a progress bar using TNewProgressBar.
The default color of the progress bar is green.
I would like to change the color to blue.

推荐答案

您不能.

进度栏由当前Windows主题设置样式.在默认的Windows主题中,进度条为绿色(或黄色或红色,如果进度条处于暂停或错误状态,请参见TNewProgressBar.State.)

The progress bar is styled by the current Windows theme. In the default Windows theme, the progress bar is green (or yellow or red, if the progress bar is in paused or error state, see TNewProgressBar.State).

您将必须完全重新实现进度条的绘制或禁用整个安装程序的视觉主题.
请参见如何在C#.NET 3.5中更改进度条的颜色?

You would have to completely reimplement the drawing of the progress bar or disable visual themes of whole installer.
See How to change the color of progressbar in C# .NET 3.5?

但是Inno Setup API不允许您重新实现图形.而且您可能不想禁用视觉主题.

But the Inno Setup API does not allow you to reimplement the drawing. And you probably do not want to disable the visual themes.

如果您确实需要蓝色,则可以考虑使用TBitmapImage.Bitmap.Canvas(使用类似.Rectangle的方法)自己实现进度条.

If you really need the blue color, you may consider implementing the progress bar yourself using TBitmapImage.Bitmap.Canvas (using methods like .Rectangle).

一个简单的例子:

var
  ProgressImage: TBitmapImage;

procedure InitializeWizard();
begin
  ProgressImage := TBitmapImage.Create(WizardForm);
  ProgressImage.Parent := WizardForm;
  ProgressImage.Left := ScaleX(10);
  ProgressImage.Top := WizardForm.ClientHeight - ScaleY(34);
  ProgressImage.Width := ScaleX(200);
  ProgressImage.Height := ScaleY(20);
  ProgressImage.BackColor := clWhite;
  ProgressImage.Bitmap.Width := ProgressImage.Width;
  ProgressImage.Bitmap.Height := ProgressImage.Height;
end;

procedure DrawProgress(Image: TBitmapImage; Progress: Integer);
var
  Canvas: TCanvas;
  Width: Integer;
begin
  Log(Format('Drawing progress %d', [Progress]));

  Canvas := Image.Bitmap.Canvas;

  Canvas.Pen.Style := psClear;

  Width := Image.Bitmap.Width * Progress / 100
  Log(Format('Bar size: %d x %d', [Width, Image.Bitmap.Height]));

  Canvas.Brush.Color := clHighlight;
  Canvas.Rectangle(1, 1, Width, Image.Bitmap.Height);

  Canvas.Brush.Color := clBtnFace;
  Canvas.Rectangle(Width - 1, 1, Image.Bitmap.Width, Image.Bitmap.Height);

  Canvas.Pen.Style := psSolid;
  Canvas.Pen.Mode := pmCopy;
  Canvas.Pen.Color := clBlack;
  Canvas.Brush.Style := bsClear;
  Canvas.Rectangle(1, 1, Image.Bitmap.Width, Image.Bitmap.Height);
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  Log(Format('CurPageChanged %d', [CurPageID]));
  DrawProgress(ProgressImage, (CurPageID * 100 / wpFinished));
end;

这篇关于如何在Inno Setup中更改进度栏的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆