2

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:

enter image description here

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

But I'm missing the image part.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Susanna
  • 23
  • 5
  • So what part/half do you need a help with? Show us what you have already (a link is not enough). Why is the image crossed on the screenshot? What does that mean? – Martin Prikryl Jun 13 '16 at 14:39
  • I need a description for each component . The solution I found . Now I would also add image to each component. The sample image I found here . When I pass the mouse on component would that also displays a picture and not just the description – Susanna Jun 13 '16 at 14:53
  • i am trying to insert the code.. but i am not able to do it. i dont know how to insert. – Susanna Jun 13 '16 at 15:50
  • [link] (http://i68.tinypic.com/5a45mx.jpg) – Susanna Jun 13 '16 at 16:34
  • 1
    Code belongs here, in your question, as text, not off-site in an image. Copy the code from your editor to the clipboard, switch back here to your question, paste the code in, highlight all the code and either press Ctrl+K on your keyboard or click the toolbar button that looks like **{}**. There's no magic involved in adding code here. – Ken White Jun 13 '16 at 18:12
  • You have to add the `Source: InnoCallback.dll; Flags: dontcopy` to the `[Files]` section as seen in the http://stackoverflow.com/a/37796528/850848 – Martin Prikryl Jun 14 '16 at 12:15
  • Thanks a lot for your answers and patience. I did it exactly like in that link. But now i have the Runtime Error: Cannot Import dll:C:\Users\User1\AppData\Local\Temp\is-RUNLD.tmp\InnoCallback.dll – Susanna Jun 14 '16 at 12:48
  • Where did you get the `innocallback.dll` from? Do you use Ansi or Unicode version of Inno Setup? – Martin Prikryl Jun 14 '16 at 12:59
  • And the other question (Where did you get the `innocallback.dll` from?) – Martin Prikryl Jun 14 '16 at 14:09
  • ....ehmmmm on google, found this: [http://www.sherlocksoftware.org/innotools/files/innocallback.zip] – Susanna Jun 14 '16 at 14:12

1 Answers1

1

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

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;

enter image description here

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • This is what i am looking for. I am trying to do this, but i am having the error: "Unknown identifier 'WrapTimerProc' ". – Susanna Jun 13 '16 at 20:32
  • As mentioned twice in my response, you have to copy most of the code (except for the `HoverComponentChanged`, the `InitializeWizard` and the `CompLabel` variable) from the http://stackoverflow.com/a/37796528/850848 and put it into front of the code from this answer. – Martin Prikryl Jun 14 '16 at 06:45
  • @ Martin Prikryl I resolved it. And it seems that works great. The last question what i would like to ask you is, how to make bigger the components page and the images too. Thank you very much!!! – Susanna Jun 14 '16 at 14:28
  • The space reserved for the description and the label is determined by the line `CompLabel.Height := ScaleY(64);`. As for the wizard window size, that's for a new question (make sure you explain if you want to make the wizard window larger in general, or if you want to make it larger temporarily, just for this page - neither seems good to me). – Martin Prikryl Jun 15 '16 at 05:53
  • I solved it by following your instructions . And with the code you posted. – Susanna Jun 15 '16 at 08:27
  • But how did you solve the *"Cannot Import dll"* error specifically? – Martin Prikryl Jun 15 '16 at 08:37
  • I downloaded the InnoCallback.dll.At [Files] section i added InnoCallback.dll with doncopy Flag. And with the indications and code what you posted its seems to work well.I don't know if it was the right solution. But it works. – Susanna Jun 15 '16 at 09:00