Old 16th April 2006, 16:25   #1
CancerFace
Senior Member
 
Join Date: Apr 2006
Posts: 289
Send a message via ICQ to CancerFace
Question Add Icons to a custom Page

I have created a custom page (for InstallOptionsEx) that contains among other things two fields for images/icons. I have also added two different icons in my file using a small script that injects the second icon to the header then compresses it with upx (using the --compress-icons=0 flag)
In other words in my NSIS file I have
code:
!define MUI_UI "src\custom_header.exe"
!define MUI_ICON "icons\FirstIcon.ico"
!packhdr "$%TEMP%\exehead.dat" 'header.cmd'


and header.cmd is
code:
"%ProgramFiles%\Resource Hacker\ResHacker.exe" -add "%TEMP%\exehead.dat", "%TEMP%\exehead.dat", "%~dps0icons\SecondIcon.ico" , ICONGROUP,104,
upx --best --compress-icons=0 "%TEMP%\exehead.dat"


Once I initiallize the page both images show FirstIcon.ico.

If I change my .ini file that generates the page, so that it points to the exe containing the icons then I get two different icons on the page, but SecondIcon.ico is displayed as if it was 32x32 extraploated to 128x128.

Is there a way to change any of the images on the page before displaying it? I am not sure how to use, say, {STM_SETICON} or something similar.Something like this:
code:
InstallOptionsEx::initDialog /NOUNLOAD "$PLUGINSDIR\${IniFileName}"
Pop $R1
GetDlgItem $0 $R1 1202
SendMessage $0 ${STM_SETICON} ?? ??


I played around with the ?? using the icon index in my file etc but couldn't get it to work ...

I found a thread that suggested (for a different issue though) to use a system call to LoadIcon, but then I am not sure how to pass the information to the SendMessage command ...


Any ideas?

CF
CancerFace is offline   Reply With Quote
Old 16th April 2006, 17:29   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Not tested, but should work.

code:

!define IMAGE_ICON 1
!define LR_LOADFROMFILE 0x10

...

Pop $R1

System::Call `user32::LoadImage(, t "$PLUGINSDIR\SecondIcon.ico", i ${IMAGE_ICON}, , , i ${LR_LOADFROMFILE}) i.R0`
GetDlgItem $R2 $R1 1202
SendMessage $R2 ${STM_SETICON} $R0 0



-Stu
Afrow UK is offline   Reply With Quote
Old 16th April 2006, 17:44   #3
CancerFace
Senior Member
 
Join Date: Apr 2006
Posts: 289
Send a message via ICQ to CancerFace
Thanks for the info Afrow UK
I had seen in this thread a similar example but I was trying to get the ico from within my installer, without extracting it. Since it already is allocated as a resource, isn't there a way to tell the window to use that specific resource instead of another one?
CF
CancerFace is offline   Reply With Quote
Old 16th April 2006, 18:22   #4
CancerFace
Senior Member
 
Join Date: Apr 2006
Posts: 289
Send a message via ICQ to CancerFace
I think what I am looking for is something like this:
code:
InstallOptionsEx::initDialog /NOUNLOAD "$PLUGINSDIR\${IniFileName}"
Pop $R1
GetDlgItem $0 $R1 1202
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
System::Call 'kernel32::GetModuleHandleA(t R0)i .r2'
System::Call `user32::LoadImage(i r2, t "1", i ${IMAGE_ICON}, , , ) i.R0`
SendMessage $0 ${STM_SETICON} $R0 0
InstallOptionsEx::Show

which does not work since according to this MSDN page
Quote:
If the image resource is to be loaded by ordinal, use the MAKEINTRESOURCE macro to convert the image ordinal into a form that can be passed to the LoadImage function.
...


CF
CancerFace is offline   Reply With Quote
Old 16th April 2006, 19:17   #5
CancerFace
Senior Member
 
Join Date: Apr 2006
Posts: 289
Send a message via ICQ to CancerFace
Got it
code:
!define LR_SHARED 0x8000
define IMAGE_ICON 1
InstallOptionsEx::initDialog /NOUNLOAD "$PLUGINSDIR\${IniFileName}"
Pop $R1
GetDlgItem $0 $R1 1202
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
System::Call 'kernel32::GetModuleHandleA(t R0)i .r2'
System::Call `user32::LoadImage(i r2, i 104, i ${IMAGE_ICON}, , , i ${LR_SHARED}) i.R0`
SendMessage $0 ${STM_SETICON} $R0 0
InstallOptionsEx::Show

Note that 104 is the resource ID that I am using for the second icon inside my installer

CF
CancerFace is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump