WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Add Icons to a custom Page
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
CancerFace
Senior Member

Registered: Apr 2006
From:

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

Quick Link | Report this post to a moderator | IP: Logged

CancerFace is offline Old Post 04-16-2006 04:25 PM
Click Here to See the Profile for CancerFace Click here to Send CancerFace a Private Message Find more posts by CancerFace Add CancerFace to your buddy list Edit/Delete Message Reply w/Quote
Afrow UK
Moderator

Registered: Nov 2002
From: Shropshire, England

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

__________________
afrowuk.co.uk

Quick Link | Report this post to a moderator | IP: Logged

Afrow UK is offline Old Post 04-16-2006 05:29 PM
Click Here to See the Profile for Afrow UK Click here to Send Afrow UK a Private Message Click Here to Email Afrow UK Visit Afrow UK's homepage! Find more posts by Afrow UK Add Afrow UK to your buddy list Edit/Delete Message Reply w/Quote
CancerFace
Senior Member

Registered: Apr 2006
From:

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

Quick Link | Report this post to a moderator | IP: Logged

CancerFace is offline Old Post 04-16-2006 05:44 PM
Click Here to See the Profile for CancerFace Click here to Send CancerFace a Private Message Find more posts by CancerFace Add CancerFace to your buddy list Edit/Delete Message Reply w/Quote
CancerFace
Senior Member

Registered: Apr 2006
From:

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

Quick Link | Report this post to a moderator | IP: Logged

CancerFace is offline Old Post 04-16-2006 06:22 PM
Click Here to See the Profile for CancerFace Click here to Send CancerFace a Private Message Find more posts by CancerFace Add CancerFace to your buddy list Edit/Delete Message Reply w/Quote
CancerFace
Senior Member

Registered: Apr 2006
From:

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

Quick Link | Report this post to a moderator | IP: Logged

CancerFace is offline Old Post 04-16-2006 07:17 PM
Click Here to See the Profile for CancerFace Click here to Send CancerFace a Private Message Find more posts by CancerFace Add CancerFace to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 08:59 PM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Add Icons to a custom Page
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON