将图像添加到组件列表中-组件描述 [英] Add image into the components list - component description

查看:87
本文介绍了将图像添加到组件列表中-组件描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户将鼠标悬停在选择组件" 页面上的组件上时,我想显示一点图像.

I would like to display a little image, when user hovers mouse cursor over a component on the "Select Components" page.

例如,我想做这样的事情:

For example, I would like to do something like this:

我在这里找到了一半解决方案:有关Inno Setup组件的详细说明

I found a half solution here: Long descriptions on Inno Setup components.

但是我缺少图像部分.

推荐答案

基于我的回答有关Inno Setup组件的详细说明.您将需要复制HoverTimerProc及其支持功能和全局变量.

Building upon my answer to Long descriptions on Inno Setup components. You will need to copy HoverTimerProc and its supporting functions and global variables.

此答案修改了HoverComponentChangedInitializeWizard程序以支持除描述标签之外的图像.

This answer modifies the HoverComponentChanged and InitializeWizard procedures to support the images in addition to description labels.

[Files]
...
Source: Main.bmp; Flags: dontcopy
Source: Additional.bmp; Flags: dontcopy
Source: Help.bmp; Flags: dontcopy

[Code]

var
  CompLabel: TLabel;
  CompImage: TBitmapImage;
  LoadingImage: Boolean;

procedure HoverComponentChanged(Index: Integer);
var 
  Description: string;
  Image: string;
  ImagePath: string;
begin
  case Index of
    0: begin Description := 'This is the description of Main Files'; Image := 'main.bmp'; end;
    1: begin Description := 'This is the description of Additional Files'; Image := 'additional.bmp'; end;
    2: begin Description := 'This is the description of Help Files'; Image := 'help.bmp'; end;
  else
    Description := 'Move your mouse over a component to see its description.';
  end;
  CompLabel.Caption := Description;

  if Image <> '' then
  begin
    { The ExtractTemporaryFile pumps the message queue, prevent recursion }
    if not LoadingImage then
    begin
      LoadingImage := True;
      try
        ImagePath := ExpandConstant('{tmp}\' + Image);
        if not FileExists(ImagePath) then
        begin
          ExtractTemporaryFile(Image);
        end;
        CompImage.Bitmap.LoadFromFile(ImagePath);
      finally
        LoadingImage := False;
      end;
    end;
    CompImage.Visible := True;
  end
    else
  begin
    CompImage.Visible := False;
  end;
end;

procedure InitializeWizard();
var
  HoverTimerCallback: LongWord;
begin
  { For HoverTimerProc and its supporting functions, }
  { see https://stackoverflow.com/q/10867087/850848#37796528 }
  HoverTimerCallback := WrapTimerProc(@HoverTimerProc, 4);

  SetTimer(0, 0, 50, HoverTimerCallback);

  CompLabel := TLabel.Create(WizardForm);
  CompLabel.Parent := WizardForm.SelectComponentsPage;
  CompLabel.Left := WizardForm.ComponentsList.Left;
  CompLabel.Width := (WizardForm.ComponentsList.Width - ScaleX(16)) div 2;
  CompLabel.Height := ScaleY(64);
  CompLabel.Top := WizardForm.ComponentsList.Top + WizardForm.ComponentsList.Height - CompLabel.Height;
  CompLabel.AutoSize := False;
  CompLabel.WordWrap := True;

  CompImage := TBitmapImage.Create(WizardForm);
  CompImage.Parent := WizardForm.SelectComponentsPage;
  CompImage.Top := CompLabel.Top;
  CompImage.Width := CompImage.Width;
  CompImage.Height := CompLabel.Height;
  CompImage.Left := WizardForm.ComponentsList.Left + WizardForm.ComponentsList.Width - CompLabel.Width;

  WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height - CompLabel.Height - ScaleY(8);
end;

这篇关于将图像添加到组件列表中-组件描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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