Archive: NSIS is revolting!


NSIS is revolting!
  Well, the time has come to make an installer that does everything I've been trying to avoid. (Well, almost...) Anyway, I hate functions. They hate me. I've attempted to draw up a treaty, NSIS responded with a Molotov cocktail... :hang:

So, since I couldn't figure out how to do what I needed myself, I turned to the docs, examples, FAQ, forum, and archive to find out if anyone else has needed these things. Sure enough, they have... Looks like I won the battle... But NSIS is trying to win the war... :mad:

1) I want to only allow the installer to be invoked once. Apparently, we had an issue with a previous installer when someone tried to install twice at once. :igor: I found the mutex recipe, but it always pops up the message box.

2) I have 3 subsections in my components page. I want 0 or 1 of the 5 items in the first subsection to always be selected. (Oh, yeah... none of the items should be a default selection.) I looked at one-section.nsi, ripped the function out and tried to modify it to fit my needs. I failed. Miserably. It's currently almost exactly as it is in one-section.nsi. It almost works. If your first selection is the subsection itself, they are all selected...

3) I have a couple of custom pages with text boxes that I would love to have white backgrounds on to match, for example, the readme page. Neither example I found wants to work and tinkering with them too much gives me a totally blank page. Go me.

I'm going to continue to pound on this nsi to try to make it submit to my will, but if someone out there in NSISland is willing to be a mediator, world peace will be reached that much sooner! :D

Seriously, though, since I'm having a difficult time, any assistance would be appreciated.

I'm hearing NSIS readying another assault, so I should get back to work. If anyone is interested, I have attached a somewhat stripped down sample. I probably should have stripped it more, but this is an accurate picture of the problem and compiles into something that shows it. Just search for [XXX] in the .nsi.

Since the zip is a bit on the larger side and is likely to be rejected by the board, you can grab it from http://www.mpsmultimedia.com/lewellyn-nsi.zip Let me know if I missed anything in this message or if I need to clarify anything.

Viva!

--_Lewellyn

P.S. I just noticed that you can't make 2 links on the finish page. Is this intentional? Is it easily surmountable with a custom page, or should I just give in? An example of that is also in that zip file. I think that's all I have left... :/

[edit]I am using whatever NSIS Update gave me from CVS a couple of hours ago. So it should be fairly up-to-date. And none of these things sound like bugs, just a case of PEBKAC or something similar. Diagnoses welcome.[/edit]


I had a look at your script and found the problem with your first question. First of all to get rid of the MessageBox just remove the MessageBox command. Also one of your call had an error. I created an archive page on this subject and it can be found here.

Good luck with the other problems.

Vytautas :D


1) There as indeed a typo in the FAQ item. This has been solved: http://nsis.sourceforge.net/site/ind...&tx_faq_faq=29

2) Use a read-only (RO) Section, see documentation for details.

3) The InstallOptions / Modern UI documentation show you how to use custom colors (using SetCtlColors).

4) You can easily add one item to the custom page INI file (you can write to the ioSpecial.ini file in a custom pre function).


1) I hadn't noticed this typo. And all of the versions I came across looked the same to my unenlightened eye... ;)

2) I've tried using a RO section. However if I make one of the sections in that subsection RO, the section can't be selected at all, not even when you choose an InstType that includes it. I'm sure I've borked something, but I can't figure out how to unbork it... :igor:

3) Shouldn't this give me a window with Times New Roman for the background of the text box (Field 1)? Does the position of the function in the script matter? This example is from the MUI docs.


Pop $HWND ;HWND of dialog


GetDlgItem $DLGITEM $HWND 1202;1200 + Field number - 1

>;$DLGITEM contains the HWND of the first field
CreateFont $FONT"Times New Roman" 10 700
SendMessage $DLGITEM${WM_SETFONT} $FONT 0
>
4) If I feel like attempting this, I may. It shouldn't be too hard, but neither should any of the rest of this... :(

Thanks for the help, both of you. :)

--_Lewellyn

3) Works fine for me. Replace the function in the InstallOptions.nsi Modern UI example by:

Var HWND
Var DLGITEM
Var FONT

Function CustomPageA

!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE)" "$(TEXT_IO_SUBTITLE)"

!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "ioA.ini"
Pop $HWND ;HWND of dialog

GetDlgItem $DLGITEM $HWND 1200 ;1200 + Field number - 1

;$DLGITEM contains the HWND of the first field
CreateFont $FONT "Times New Roman" 10 700
SendMessage $DLGITEM ${WM_SETFONT} $FONT 0

!insertmacro MUI_INSTALLOPTIONS_SHOW

FunctionEnd

Ah... I incorrectly parsed that "1200 + Field number -1" comment. *kicks himself*

Anyway, it works now for changing the font. But, changing the color to white isn't working. (The license page uses white, correct? Or is it using a system color of some sort?) I replaced the CreateFont and SendMessage lines with the following and did not get the color to change:


SetCtlColors $DLGITEM $0x00FFFFFF 

>
However, that's just a minor annoyance. I really need to figure out how to fix the "only one or none selected" issue still, so I'll go back to that now.

Thanks again. :)

Please check the users manual. There are multiple parmaters for SetCtlColors (text/background).


Thanks. I'll look at the manual again after I get the sections issue resolved, since that's more of a show-stopper. :)


The sections work fine for me. Put "SectionIn RO" in one of the Sections in a SubSection.


I did that with the topmost Section in the top SubSection. However it's always unchecked, and I can't check it. And, to boot, checking the subsection as the first selection made selects everything BUT that RO section.

I don't want clicking on the subsection to be possible, just one or none of the sections in that section. By playing with that .onSelChange function that is in one-section.nsi, I have made some interesting effects but none what I want. I'm trying to parse exactly how it works now.


I don't understand what you mean. When using RO for a section inside a subsection, the section checkbox will be greyed out (disabled), that means that you can't change it (read-only).


OK. I think I'm following now... I moved the hidden required section as a (visible) read-only section in that subsection. The section checkbox is greyed out (disabled/selected), and the subsection checkbox is shaded (partially selected). However, when you click the subsection, everything becomes selected. I guess I need to make the subsection header unselectable somehow.

This is the line I should be modifying with the number of sections to be exclusive of one another, right?


StrCmp $2 $1 0 +5 ; selection hasnt changed 

>

If you click on a subsection, all sections will be selected, but the RO section still remain the same. What's wrong with that?


I am trying to emulate one-section.nsi's behavior, only without a default selection for the group.


For the benefit of those searching the forums at a later date:

kichik helped me figure it out. The solution? Don't change anything. :) Well, that's not quite true, but close.

According to kichik: "Don't use $1 anywhere", "copy the first section you want selected, not the sub-section" to $1 in .onInit, and "you don't have to make the default section selected by default, just specify it as default". Oh, and to add a new section: "everywhere a section index is defined, you need to add another block of that for the new section", "everywhere there is ${sec4}, add the same block for ${sec5}".

Hope that helps someone else who can't figure it all out. one-section.nsi is just magic... :)