Skip to content
⌘ NSIS Forum Archive

nsdialogs and installer icon

24 posts

WebMatze#

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#
You can call LoadIcon to load that icon. The C code that does it is:
LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(103))
WebMatze#
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#
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#
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#
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#
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 ?
WebMatze#
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#edited
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#
nsDialogs is built to be used along with System. It has no capabilities of its own to load images, yet.
JasonFriday13#
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#
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#
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#
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#
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#
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#edited
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.
JasonFriday13#
I should also add a 'ClearImage' macro for clearing icons. I will post here again once uploaded to the patch tracker.
JasonFriday13#
Patch is now added in the patch tracker.

aluna#
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