- NSIS Discussion
- nsdialogs and installer icon
Archive: nsdialogs and installer icon
WebMatze
4th September 2008 12:11 UTC
nsdialogs and installer icon
Hello, i'm trying to do something but i dont know if it is possible.
Here is my question: Is it possible in a custom page generated with nsdialogs to have the installer icon ?
I know it is possible to load external images (like in the welcome.nsi example), but i would like to have on my page the icon i specified with the Icon instruction at the beginning of my script.
If it is possible, could someone tell me how to do ?
Thanks in advance
kichik
5th September 2008 12:20 UTC
You can call LoadIcon to load that icon. The C code that does it is:
LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(103))
WebMatze
5th September 2008 16:31 UTC
thanks for your answer,
i will try it ... and i'll let you know if it works
WebMatze
5th September 2008 16:39 UTC
Hello,
I tried the follwing:
nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_ICON} 0 0 0 109u 193u ""
Pop $IMAGECTL
System::Call 'user32::LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(103))i.s'
Pop $IMAGE
SendMessage $IMAGECTL ${STM_SETICON} ${IMAGE_ICON} $IMAGE
but it doesn't work...
kichik
5th September 2008 17:06 UTC
That's because I gave you the C code, not System::Call code.
System::Call kernel32::GetModuleHandle(i0)i.s
System::Call user32::LoadIcon(is,i103)i.s
Pop $IMAGE
WebMatze
5th September 2008 20:20 UTC
Hello, and thanks again for your help
i tried:
System::Call kernel32::GetModuleHandle(i0)i.s
System::Call user32::LoadIcon(is,i103)i.s
Pop $IMAGE
${NSD_CreateIcon} 0 0 100% 12u $IMAGE
without success
if i replace createicon by createlabel i get a random number.
do you have an idea ?
kichik
5th September 2008 21:32 UTC
That random number is the icon handle. The fifth parameter sets the text, not the icon. Use STM_SETICON as you've originally done.
WebMatze
6th September 2008 06:30 UTC
Hello,
i retried with the original code:
nsDialogs::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_ICON} 0 0 0 109u 193u ""
Pop $IMAGECTL
System::Call kernel32::GetModuleHandle(i0)i.s
System::Call user32::LoadIcon(is,i103)i.s
Pop $IMAGE
SendMessage $IMAGECTL ${STM_SETICON} ${IMAGE_ICON} $IMAGE
but without success. What am i doing wrong ?
kichik
6th September 2008 06:40 UTC
You're passing the wrong parameters for STM_SETICON.
WebMatze
6th September 2008 10:02 UTC
Thanks Kichik, that works
Here is the working code:
nsDialogs
::CreateControl /NOUNLOAD STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_ICON} 30 30 0 109u 193u ""
>Pop $IMAGECTL
System::Call kernel32::GetModuleHandle(i0)i.s
System::Call user32::LoadIcon(is,i103)i.s
Pop$0
SendMessage $IMAGECTL${STM_SETICON} $0 ""
Thanks again for your help
JasonFriday13
26th December 2008 14:32 UTC
Hi, I want to do the same thing, but I want to stay away from using the system plug-in (installer + 11kb, not cool for the wiki). I also want to avoid writing a single function plugin with a single line of code to do the same job (my IDE isn't installed ATM). Using NSIS code is preferable, but adding the code to nsDialogs would be even better.
[edit] I am updating my InstallSpider User Interface to Modern UI 2 and I don't really want to include the system plugin with it.
Code fragment from SpiderBanner plugin (most of it):
SendMessage([hwnd], STM_SETICON, (WPARAM)(HICON)LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(103)), 0);
kichik
26th December 2008 18:16 UTC
nsDialogs is built to be used along with System. It has no capabilities of its own to load images, yet.
JasonFriday13
26th December 2008 19:11 UTC
If you can't beat it, join it. I have whipped up a patch that loads icons from both a file and the installer (using system plugin).
[edit] And I am now 60% ubuntu linux, 20% debian and 20% WinXP, and loving it!
kichik
26th December 2008 20:44 UTC
What's wrong with NSD_SetImage? Or is it especially for icons where NSD_SetImage works just for bitmaps? If it's the second, it'd be better to extract the commons into another macro instead of duplicating the code between the two.
JasonFriday13
27th December 2008 03:17 UTC
Its the latter, and no, there is not much in common (API call wise). I found that if LR_DEFAULTSIZE is omitted, the icon is 16x16, so I added it for 32x32 icons to appear. Plus, the image type is specifically for icons, so they have the IMAGE_ICON type in the arguments.
JasonFriday13
27th December 2008 04:08 UTC
So, something like this then?
[edit] I have noticed the coding of the macros is different to most macros I have seen. These ones ask for a return value, much like standard nsis functions, and pops the handle at the end of the macro. Different, but a bit easier to follow.
kichik
27th December 2008 10:22 UTC
You can go even further by passing IMAGE_BITMAP and IMAGE_ICON as another parameter to the macro. No need to write the LoadImage line more than once.
JasonFriday13
28th December 2008 12:48 UTC
Yeah I could. This kind of programming is new to me, coding the most common code (in the script) so that its only coded once.
JasonFriday13
28th December 2008 13:23 UTC
Well, I optimized the code to a point where if you made any changes, the code gets worse (I hope, although including LR_DEFAULTSIZE is debatable).
[edit] I did say in an earlier post why I put it in.
Anders
28th December 2008 13:47 UTC
you probably don't want LR_DEFAULTSIZE
kichik
10th January 2009 22:00 UTC
Could you submit it along with the appropriate documentation changes as a patch?
JasonFriday13
12th January 2009 07:48 UTC
I should also add a 'ClearImage' macro for clearing icons. I will post here again once uploaded to the patch tracker.
JasonFriday13
12th January 2009 08:58 UTC
Patch is now added in the patch tracker.
http://sourceforge.net/tracker/?grou...49&atid=373087
aluna
26th January 2009 17:14 UTC
Hello
I'm new to NSIS coding.
I have a custom page and want it to give the same look of other built-in pages, i.e, with installer icon at top left (I'm not using modern ui).
So, I downloaded your patch but don't know who to use it.
Could you please, post sample code?
Thank you
Regards
Alex