Archive: Changing Images using Install Options


Install Options Run-Time
How can I change an image of an image control (the images are the same size) in an Install Options page after selecting a radiobutton with NOTIFY flag? (means in run-time)


This page shows you how to use the APIs you need:

http://nsis.sourceforge.net/archive/...php?pageid=405


I'll test that. And just another question, how I can check/uncheck checkboxes in run-time using Install Options?


By sending a window message. You can find a reference of all messages in the MSDN library.


I tried the code but it didn't work (EDIT: The object is not deleted, so continue the same):

    System::Call "${sysDeleteObject} (R1) .R2"
MessageBox MB_OK $R2
System::Call '${sysLoadImage} (0, s, ${IMAGE_BITMAP}, 0, 0, ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) .R1' "$0\$1.bmp"
SendMessage $0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $R1


The MessageBox should show a non-zero result as MSDN says, but I put the right image handle, field 16 (before have only labels, textboxes, checkboxes and groupboxes):

[Field 16]
Type=Bitmap
Text=C:\Games\C-evo\HAL.bmp
State="C:\Games\C-evo\HAL.bmp"
Left=257
Right=300
Top=3
Bottom=43


What is wrong?

Why are you deleting an object before loading the image?

Did you detect the inner window field hwnd correctly (as described in the IO documentation)?

Is that bitmap path correct? Does it return a valid bitmap handle?


I fixed it. YEAH, it's working!


About the checkbox thing, I know that is BM_SETCHECK, but I don't know its number value. Where I can find it?


The value is:

0xF1


Oh yeah! It works too. If someone wants the code, it is right here:

!define BM_SETCHECK 0x00F1 # Message

!define BST_UNCHECKED 0x0000
!define BST_CHECKED 0x0001
!define BST_INDETERMINATE 0x0002

SendMessage $0 ${BM_SETCHECK} ${BST_CHECKED} ""

# Replace ${BST_CHECKED} with one of those "BST_" you want (uncheck, check or gray/check).


Thanks Joost. NSIS is really the best. :up:

The StrCtlColors command supports variable for input? I'm having problems using this command.


It does not take variables, you should add two commands and run one of them.


Are you planning to add this "variable support" to StrCtlColors soon? If not that soon, have another way to paint controls without StrCtlColors?


Why do you need variable support? Use StrCmp to check the value of a variable and then run the SetCtlColors commands you need.


Because it depends from the user input from InstallOptions, if I do this the program script size will be gigantic.


So you want to use to be able to choose every possible color for your installer dialog? That's not currently possible.


Is why that question:

Are you planning to add this "variable support" to StrCtlColors soon? If not that soon, have another way to paint controls without StrCtlColors?

You can sumbit a feature request at the project page. There is no other way to set a color.


the "!define BM_SETCHECK 0x00F1" is mentioned at this thread.
could that be included in the winmessages.nsh, or isn't that a winmessage?


Currently WinMessages.nsi only contains the generic window messages, not the messages for all user interface controls.

If anyone wants to extend this header file that would be nice :)


i'd do it, but i don't know the messages. :)


I was thinking this entire week about that. Including some API's commonly used too.

I've got the SDK and .NET SDK to use "cl.exe" compiler, but I have some problems when compiling NSIS; it gives me errors like files missing from NSIS Source:

"NSIS\Source\exehead\Release-zlib\icon.h"

Is it my problem or NSIS Source problem?

(Target file: "NSIS\Source\exedata.cpp")


It means that you didn't compile the exehead project. But what does this have to do with the messages header file?


It's my lazyness to post new threads... If want you can move my post to a new thread. (I'll post the file in the next post)


I did the work for yesterday's entire morning to include all messages, styles... (defines) in just one file.

To this work, delete all defines in your script for APIs messages (not the APIs themselves!) and include this powerful file.

(just some defines which are the combination of other ones I don't know really how to calculate, and some others those have "L" at end of the number which I don't know what it means)

The file is too big I had to upload it in my site (Size: 105kb):

WinMessages.nsh.txt


L means that it is a long number. NSIS won't do anything with it, so it should be removed.


But when calling System plugin it does:

!define HKEY_LOCAL_MACHINE 0x80000002

System::Call "Advapi32::RegCreateKeyA(l ${ROOT_KEY}, t 'Software/Test', i.r0) i.r1"
$1 = 0, means it passed. But replacing "l" with "i" gives error.

The original number was "(( HKEY ) (ULONG_PTR)((LONG)0x80000002) )"

So should be a warning for who uses System plugin.

Indeed, but the constant itself should not contain a L.


Yep, I'll comment those "L", so they will know about that.


OK, updated with L's commented, fixed some calculations (combinations with ORs and ANDs) and added Basic Registry (just those ones someone is talking about in another thread). I'll include more tomorrow.

WinMessages.nsh.txt (Size: 109kb)


Can you split it up in multiple header files?


All those were inside WinUser.h, this one is the biggest file of defines on the SDK (I think).

Yes, I can. But by what way do you suggest? I'm putting even more defines from other SDK files now (separated by comments of each file name included)...


Using such huge files will slow down compilation. It's better to split it up and let people choose.


I was thinking this way, as every define is from a group of defines, to organize them as they were organizated, like:

All "HKEY_*" defines will be in one group called HKEY.
All "WM_*" defines will be in one group called WM.

So the compilation will be not so big as before, and you'll use those really you want.

What do you think about this?


Please test how long it takes to include the files or groups.


My computer is too fast it compiles the Modern UI examples (for example) in less than 1 second. Including with this huge file. But I didn't finished my work here, I need to add more define, however I didn't split it up yet. I'm working on several things at the same time so don't expect this done to today, nor tomorrow...