Archive: Optional install


Optional install
Will the installer support optional install? Like letting the user choose among COM ports or enter a text?
Whats the status on this?


i have a small app which I coded to do something similar. you run it from your installer and give it the hwnd of the installer and the name of an INI file. it starts up, reparents itself to the installer (so that it looks seemless), and dynamically generates a dialog based on the INI file. Then, when the user clicks OK it saves the values back to the INI which can be read from the installer. Just include the file and extract to the temp directory. Delete it after you have your values.

I know it would be better to put this in the source of NSIS, but I did it this way because 1) I had just gotten NSIS and wasn't comfortable with the source yet and 2) needed very quick (about 2 hour) results.

Right now, you can put labels, text boxes, and password boxes onto the form along with a caption. It could be easily modified to allow combo box support also.

it's on my other computer but can post it (along with source code) if you are interested.


please do so!
regards jfina@online.no


Yes if you want, I can include this utility with the nsis distro (like splash.exe, etc :).

-Justin


absolutely! :)


Here it is. There really isn't a lot of documentation, but I did include a sample install script. Also, I went ahead and threw in support for comboboxes (both comboboxes and dropdown lists).

You can do with the source code all you want, just imagine I wrote a license for it similar to NSIS is under.

If somebody wants to do what they can to squeeze a few bytes out of the program, that would probably be pretty cool.

If you notice any bugs, you can either fix them yourself (since you have the source code) or let me know and I'll do it. If you do fix any bugs or add features, I'd love to have a copy of your modifications also. You can email me at: mbishop at bytealliance dot com

(edited the attachment to actually include a license for those who require it.)


update
Well, I apoligize but I realized there is a slight problem with the above archive. When you have multiple controls on your dialog, it sets the focus to the last control created instead of the first as you'd expect. I introduced this when I threw in the combobox stuff at the last minute and didn't test it enough.

Anyway, here is the fixed archive. Please download this one if you already have the above.

If you've already started modifying the code, just make sure the for loop exits the first time. The break that's in there right now only gets it out of the switch statement, then goes to the next control and sets focus all over again.

later.


Thanks!
I'll look at it!


update
Ok, due to a request I received I've fixed/added a few things.
* I fixed the keyboard accelerator for the ENTER key.
* Moved the OK button so it's a standard size and in the same location as the NSIS buttons.
* Added a "Title" option to set the title caption of the installer window while the options screen is being displayed.
* I changed the documentation into an HTML file and added a bit more description.

I recommend this download, if for no other reason than the first item. This behavior really annoyed me also.

Let me know if you have any questions or any more requests.


one feature that i would like to see in it.. Is i am needing some way for users to specify another folder outside of NSIS's Dir page.. Since i am installed something and then i need to install plugins to a few different programs but the problem is they don't set registry keys to where they are installed. Right now using this it makes the user type it in by hand.. But would nice if you could add another option like define a dir choice and place a small button that opens up a browseinfo box to select a dir.. thanks..


another update
Schultz, this one's for you...and everybody else of course.
Included in this release is support for two additional controls. "FileRequest" and "DirRequest". These controls are drawn as a text box with a command button right next to it. The command button has a caption of "..." and clicking it will pop up a dialog of the appropriate browse type.

The FileRequest control has properties for setting the filter, specify "Open" or "Save" dialog, and a few other things.

I also added a few other things. The next biggest change is that I added "MaxLen", "MinLen", and "ValidateText" properties to each control. If the MaxLen or MinLen is not satisfied, then a messagebox with ValidateText is shown. MinLen can be used to force input to a textbox, or to force selection of an item in a combobox.

I also made a few more changes to the documentation to hopefully explain it even better and cleaned the source code a little bit.

As always, let me know of any ideas/problems.

michael


I took a few minutes and reduced the size of the latest installeroptions (1.2) to 8.5kb. Attached. =)

My modifications to this are pretty much public domain, do whatever you want with em =)

-Justin


thanks locnar42 that was exactly what i am looking for. and dang justin you sure know how to make stuff alot smaller.


well i have a bug report.. it seems that if you just add two fields like this.
[Settings]
title=Select Dir
Caption=Testing this
ParentWnd=0
NumFields=2
DefaultField=2

[Field 1]
Type=label
text=Select Dir
left=10
right=300
top=100
bottom=120

[Field 2]
Type=DirRequest
left=10
right=300
top=122
bottom=142

and when you click on the ... button it automatically closes the windows like you are hitting the OK button.. but if you add in a Combo box for Field 3 then it works.. or if you reverse the two and have the DirRequest as Field 1 and label as Field 2 it works except that the label is not displayed at all.


Ok, sorry about this one. I accidently reused the identifier of the OK button when creating controls.

I'm going to post the fix here in a second, but I'm going to go ahead and use Justin's improvements because I definatly want to see this thing smaller. The problem is, if you make that change to the code which Justin posted, then the application won't exit cleanly. This only affects the Release build, not if you compile for debug.

It restores the NSIS window, saves the settings, and then hangs. In fact, I've traced it all the way to the return statement from WinMain so it's in some of the cleanup code.

I don't know if it's something that Justin changed or (more likely) something in the original code. I'll put the update here as soon as I have this problem worked out.

If you have my code and can compile it yourself, then change the 1100 in ReadSettings() and AddBrowseButtons(). This will fix the problem. Otherwise, wait a bit and I'll put the fix here.

I've got some other stuff I've got to do right now, but I'll get to it later today hopefully.

michael


Oops, the hanging bug was my fault. I forgot that when not using the CRT for WinMain, you have to call ExitProcess() directly. Attached.

-Justin


ok, this one has it all.
Ok, this version here incorporates the bug fix which Justin just posted and the fix for the problem which Schultz reported.

Check back in a day or two because a couple of the things I'm about to put in are (with priority):
* checkbox and radio button controls. (high)
* Specify the title for the open/save dialog box. (medium)
* Specify the caption for the directory browser. (high)
* Adding a couple of additional flags for controls. (medium)
* Add an icon so the dialog can match the main NSIS window. (low)
* Ability to use a separate window (outside of NSIS) of any size so you can include as many controls as you need. (medium)

I know how I can cut a bit more space inside the program, so all this should stay at the newly improved size of 8.5k

Thanks Justin for pointing that out. I was scratching my head thinking that I wasn't freeing memory or freeing it twice or something. Thanks for the size reduction as well. That's some diet you put it on there. It makes it more attactive to include in a smaller installation.

michael


Great. =) I'll be glad to shrink other parts too if you like. I just did the most obvious optimizations =)

I'm kind of thinking of including a contrib\ directory in the installer, for apps like this (and I guess zip2exe and splash would go there too). Sound like a good idea? Would you be ok with having your code distributed along with it?

-Justin


sounds good to me
Distributing it with NSIS would be fine by me. I think a contrib directory sounds like a good idea, especially if more add-ons are available. It was a while from when I started using NSIS until I came here and if others are the same way it could prove useful.

I have already cut the compiled version down by another 512 bytes (~250 compressed bytes) and I modified a lot of lines of code to do it. If you plan on having another round of it, let me know and I'll get you the newest copy. Otherwise I'm going to wait until I add a couple of the above mentioned features before I post again. I've noticed that the mouse cursor will sometimes disappear (btw, wiggling the mouse always brings the cursor back), so I'll be fixing that as well.

UPDATE: Project is approved and the source code should be on SourceForge sometime today. The website will be located at http://installoptions.sourceforge.net and the project page at http://sourceforge.net/projects/installoptions/

michael


I've tried the installeroption and i'm very satisfied with what i see. The only thing i'm missing is the posibility to set default vaules for the combo box

/Jon


hum not sure if this is just my system or another bug.. but sometimes when you select a folder and come back to the installer it don't repaint itself.. until you either click on the text area or the browse button again.. but again not sure if my system is what is causing this.


The defaults for the combobox are going to be implemmented via the Text value in the INI file. This was supposed to already be done (I think it says so in the documentation), but it slipped my mind. Thanks for reminding me.

As for the repaint, I'm not sure yet. I force the window to be invalidated after the browser dialog closes, but I'll check and make sure it's working all the time. Is there any way that you can see where it always happens?


i think the easiest way to test this is after you select a directory.. drag an application over the text box.. After this part of the text box won't be repainted. and sometimes the ok button is also.. You can still click in there but it is a little annoying if you are doing multiple things at once..
also not sure if this matter usin WinXP


cool, can reproduce that exactly so I should have it fixed in no time. It was a bit different problem than I was thinking, but shouldn't be a problem at all.

I already fixed the problem about not being able to set the initial value of a combobox.


Ok, fixed the problem with the window being redrawn. After staring at the screen for a bit wondering why it was doing that, I thought I'd try something out.
What's happening is, my program does redraw the controls, but right after that the main NSIS window draws over them. To fix this, I temporarily set the window flags of the main NSIS window to include WS_CLIPCHILDREN so that it won't draw on top of my window. I restore the window flags when my program exits.

also included here are a few more size reductions and the fix for the combobox initial value.

Let me know if this fixes your problem.

My apoligizies to everyone, but I changed the EXE name to InstallOptions. Make sure you change this everywhere in your script.


Neato
Glad I caught this in another thread. I'm working on a registration dialog and this is much nicer than my quick/dirty first try.