Archive: NSIS - Dynamic custom pages


NSIS - Dynamic custom pages
Hello,

I'm using NSIS with Eclipse plugin to build custom pages.
My custom pages are ".ini" files and used like that:
Page Custom MyPage MyPageLeave " : This is my page"

In a custom page, I have "2 group boxes":

The first group box contains 2 radio buttons
The second contains a textbox

When checking a radio button, I want to disable the textbox.
When checking the other radio button, I want to enable the textbox.

Is it possible ?

Thanks a lot


NOTIFY flag


Hi, thanks for your answer... it's seems to work.

No my problems are:

1/ When my radio is checked, the "leave" function is invoked. In my leave function, I'm setting values like

WriteINIStr $R0 "Field 7" "State" "localhost"
WriteINIStr $R0 "Field 7" "Flags" "DISABLED"

My my page is not reloaded so my changes are not uploaded on the page. How can I do that ?

2/ When my radio is checked, the "leave" function is invoked. How can I make the difference between the "leave" function invoked by my NOTIFY flag and the leave function invoked when the page is leaved ?

Thank you very much for your help


the installoptions readme tells you how


In the documentation, it's written that changes on the new version "Made pages refresh after an aborted leave function".

But if I'm doing "Abort" in the leave function, my page is not refreshed !!

I didn't find anything about how I can make the difference between the "leave" function invoked by my NOTIFY flag and the leave function invoked when the page is leaved.

Can you help me or tell me in which part of the documentation I can find that information ?

Thanks


Your validation/leave function can read the "State" value from the "Settings" section to determine which control caused the notification, if any, and perform some appropriate action followed by an Abort instruction (to tell NSIS to return to the page). The Examples\InstallOptions folder contains an example script showing how this might be used.
Your page is not refreshed, you need to update the controls and not the .ini

Hi,

Sorry but I didn't find how to change control value instead of ini values.

The only thing I found was :

Writing to INI files

The INSTALLOPTIONS_WRITE macro allows you to write values to the INI file to change texts or control settings on runtime:

!insertmacro INSTALLOPTIONS_WRITE "myFile.ini" "Field #" "Name" "Value"

But that doesn't update my control value...


I forgot to tell I'm using NSIS InstallOptions....


I have tried with the following instructions (the field number of the text i want to update is 2):

GetDlgItem $R1 $HWNDPARENT 1201 ;1200 + Field number - 1
MessageBox MB_OK "R1 = $R1"
SendMessage $R1 ${WM_SETTEXT} "STR:MY NEW VALUE" 0

The messagebox instruction always displays R1 = 0


I have found how to set the text value :

;Get the HWND ID of the field
ReadINIStr $idChampIP "$R0" "Field 2" "HWND"

,;Sets the value to "localhost"
SendMessage $idChampIP ${WM_SETTEXT} 1 "STR:localhost"

But I would like to set the flag "DISABLED" to 1 on this field

I have tried that without success ("2" means that this is the 2nd flag but I'm not sure it works like that)

SendMessage $idChampIP ${BM_SETCHECK} 1 "2"


Don't know how it works and can't find any documentation givin' all the constants we can use 'BM_, WM_, ...)

Can someone help me please ?

Thanks


EnableWindow

I recommend you switch to MUI2 and nsDialogs.

Stu


I just want to disable the text box, not the entire Page.
How can I use that flag ? I thought that "EnableWindow" had effect on the entire page....


Tu sum up I've gt two problems, after searching all the day in the documentation and code examples.

1/ How to dynamically disable a textbox

I have found how to set the text value :

;Get the HWND ID of the field
ReadINIStr $idChampIP "$R0" "Field 2" "HWND"

,;Sets the value to "localhost"
SendMessage $idChampIP ${WM_SETTEXT} 1 "STR:localhost"

But I would like to set the flag "DISABLED" to 1 on this field

I have tried that without success ("2" means that this is the 2nd flag but I'm not sure it works like that)

SendMessage $idChampIP ${BM_SETCHECK} 1 "2"


Don't know how it works and can't find any documentation givin' all the constants we can use 'BM_, WM_, ...)

2/ When I'm in a "leave" function of a custom page, how to know if I'm coming from the NOITIFY event of a control or from the "NEXT button click".


If someone can help me...

Thanks a lot


1)
ReadINIStr $idChampIP "$R0" "Field 2" "HWND"
EnableWindow $idChampIP 0

2)
read the state value in the settings section IIRC, like I said, read the docs, and the docs will tell you to check testnotify.nsi

as far as docs for WM_,BM_ etc, check www.MSDN.com


Thanks a lot, everything works fine !!!


Hi,

I've got a custom page with 2 radio buttons on it, whatever I do on it I can't go through to the next page.

My code is -


Function ShowDLLPage
InstallOptions::initDialog "$PLUGINSDIR\dlltype.ini"
Pop $0
InstallOptions::show
Pop $0
FunctionEnd

Function ProcessDLLPage
ReadINIStr $0 "$PLUGINSDIR\dlltype.ini" "Settings" "State"
StrCmp $0 1 pcs
StrCmp $0 2 lv
Abort

pcs:
FileOpen $9 $INSTDIR\config\mode.conf w
FileWrite $9 "1"
FileClose $9
Abort
lv:
FileOpen $9 $INSTDIR\config\mode.conf w
FileWrite $9 "0"
FileClose $9
Abort
FunctionEnd


at first I thought, it must be the Abort's, but when I removed them, just clicking on the radio buttons went through to the next page and didn't do the file writing stuff at all.

can anyone point out where i'm going wrong here?

Depending on your NSIS version you may need to use /NOUNLOAD on your InitDialog call.

Edit: If it is not that, check the INI file exists and that it does not contain errors.

Stu


Originally posted by Afrow UK
Depending on your NSIS version you may need to use /NOUNLOAD on your InitDialog call.

Edit: If it is not that, check the INI file exists and that it does not contain errors.

Stu
Hi Stu,

I appreciate the quick reply.

It didn't fix it unfortunately. My version of NSIS is 2.42

The INI file is -


[Settings]
NumFields=2
Title="Choose Install Type"

[Field 1]
Type="RadioButton"
Text="PCS"
Flags=NOTIFY
State=0
Left=10
Right=100
Top=17
Bottom=25

[Field 2]
Type="RadioButton"
Text="LV"
Flags=NOTIFY
State=1
Left=10
Right=100
Top=30
Bottom=38


EDIT: it is going through to the "leave" page when it isn't allowing the next button to be clicked, I checked the file it should be writing to and it is working properly.

So the file exists in $PLUGINSDIR?
You should try the InstallOptions helper script header.

But first try replacing both plugin calls with just a call to InstallOptions::Dialog

Stu


Originally posted by Afrow UK
So the file exists in $PLUGINSDIR?
You should try the InstallOptions helper script header.

But first try replacing both plugin calls with just a call to InstallOptions::Dialog

Stu
Hi Stu,

in the .onInit function I'm doing -


InitPluginsDir
File /oname=$PLUGINSDIR\dlltype.ini "dlltype.ini"


I have changed initDialog to Dialog and still no joy with it.

Are there any errors in my ini file that you can see? Do I have to do something special for the next button?

I assume you have Page Custom ShowDLLPage ProcessDLLPage?
What is the value of $0 after the ::Dialog call?

Stu


Originally posted by Afrow UK
I assume you have Page Custom ShowDLLPage ProcessDLLPage?
What is the value of $0 after the ::Dialog call?

Stu
Yes -


!insertmacro MUI_PAGE_INSTFILES
Page custom ShowDLLPage ProcessDLLPage


I set an alert to come up with the value of $0.

When I click the following, these values appear -

PCS = 1
LV = 2
Next = 0

resolved by using nsDialogs


Shame you had to go down that route (even though it is best to switch anyway). Would be nice to know what went wrong.

Stu


If I recall correctly 'Flags' in [Field 1] should be NOTIFY|GROUP