Archive: nsdialogs and installer icon


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


You can call LoadIcon to load that icon. The C code that does it is:

LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(103))

thanks for your answer,
i will try it ... and i'll let you know if it works


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...


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

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 ?


That random number is the icon handle. The fifth parameter sets the text, not the icon. Use STM_SETICON as you've originally done.


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 ?


You're passing the wrong parameters for STM_SETICON.


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

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);

nsDialogs is built to be used along with System. It has no capabilities of its own to load images, yet.


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!


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.


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.


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.


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.


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.


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.


you probably don't want LR_DEFAULTSIZE


Could you submit it along with the appropriate documentation changes as a patch?


I should also add a 'ClearImage' macro for clearing icons. I will post here again once uploaded to the patch tracker.


Patch is now added in the patch tracker.

http://sourceforge.net/tracker/?grou...49&atid=373087


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