Archive: MUI Example


MUI Example
I have never built an interface before. I want to build a screen to control an INI. The screen should have places where users can input the variable data like port numbers, IP addresses, and other preferences, and also have check marks for true/false data. It only needs to be this one window, everything else can be invisible. Is there a good stand-alone example of this anywhere?


Hi torpark!

There are a lot of examples. Have a look at NSIS Examples folder.

Creating a dialog can be done with Eclipse [1] or HM NIS Edit [2].

You can find out how to include and validate a dialog in the Modern UI Readme [3]. By the way, there's an excellent function to validate ip addresses. [4]

[1] http://eclipsensis.sourceforge.net/
[2] http://hmne.sourceforge.net/
[3] http://nsis.sourceforge.net/Docs/Mod...ml#customPages
[4] http://nsis.sourceforge.net/Validate_IP_function

Cheers

Bruno


So I create the dialog with Eclipse, and validate and include it. What, uh, do you think I would do with an IP validator. or are you referring to the Torpark program I wrote?


Erm, you wrote that you would like to ask an ip address from users. To be sure that the ip is correct, I'd validate the input.


I am collecting the IP as a string. It would be great to have the "." separators though. Okay, I wrote the UI, now I need to figure out how to install brains and functionality behind it, and get it to write the settings to a .ini file. INI File Attached.


Sample script
Hi torpark!

I made a short sample script based on the Modern UI InstallOptions example.

It shows how to validate the IP and makes sure, that the port number is in a certain range.

You can easily extend the script to your needs.

I'd suggest changing the taborder for the controls. Keyboard users jump with tab to the next control, which should therefore follow each other in a certain order.

I usually create a define for every (used) control in the ini file. If you happen to change the order or insert a control you only have to change the defines and you don't need to change something in the code.

Hope this helps...

Have a nice day!

Cheers

Bruno

edit: You'll find more information for the logiclib in the wiki
http://nsis.sourceforge.net/LogicLib


that IP address validator doesn't work too well. It doesn't recognize when values are over 255. I'll keep playing with it to figure out how to push and pull data into those controls.

edit Actually, my fault, I changed a field. It works great. Now how to push and pull data...


Okay. I figured out how to pull the data, using mui_installoption_read. I imagine "write" works the same way. So now another question, How do I make some settings greyed out? For example, I want to add a check mark for "requires proxy", so that in the case that requires proxy state = 1, all the fields in group "proxy settings" become active. Else, they are inactive and not required to be checked. Ideas or examples on that? latest updates attached.


duped in other thread.


http://forums.winamp.com/showthread....hreadid=261025


Bruno,

That worked like a charm. Just one last question. For the "Save" button, where do I put the commands it will execute? Do I have to create a new page?


Hi torpark!

You're welcome! :-)

Put the code instead of the line


; TODO: save values to ini file/registry...


This code is executed if there's no notify event.

Cheers

Bruno

Awesome. I just put it at the end of the leavepage area. Thanks very much Bruno.


Bruno,

I duplicated the changestate macro. However, I am having a pretty obvious problem.

The natural state is for the control item to be unchecked. When it is checked, it is then supposed to change the state of the controlgroup 2. Instead, on the first check, it does nothing. On unchecking it, it THEN changes the state.

If "Disable Tor Management" is checked, all the settings in the tor box should be greyed out.

Why is it acting like this?


Hi torpark!

The current code just sets the state according to a control. Therefore we have to introduce some logic to change the state. Enabled -> disabled, disabled -> enabled.


${Case} "${UIDISABLETOR}"
!insertmacro MUI_INSTALLOPTIONS_READ $tmpstate2 "tcw.ini" "${UIDISABLETOR}" "State"
${If} $tmpstate2 == "1"
StrCpy $tmpstate2 "0"
${Else}
StrCpy $tmpstate2 "1"
${EndIf}
!insertmacro CHANGEGROUPSTATE2 $tmpstate2
Abort


Cheers

Bruno