- NSIS Discussion
- NSIS - Dynamic custom pages
Archive: NSIS - Dynamic custom pages
sylvinhio
21st April 2009 09:40 UTC
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
Anders
21st April 2009 10:08 UTC
NOTIFY flag
sylvinhio
21st April 2009 11:01 UTC
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
Anders
21st April 2009 11:05 UTC
the installoptions readme tells you how
sylvinhio
21st April 2009 12:59 UTC
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
Anders
21st April 2009 13:09 UTC
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
sylvinhio
21st April 2009 13:46 UTC
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....
sylvinhio
21st April 2009 15:13 UTC
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
sylvinhio
21st April 2009 16:25 UTC
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
Afrow UK
21st April 2009 19:04 UTC
EnableWindow
I recommend you switch to MUI2 and nsDialogs.
Stu
sylvinhio
21st April 2009 21:49 UTC
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....
sylvinhio
22nd April 2009 09:19 UTC
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
Anders
22nd April 2009 09:36 UTC
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
sylvinhio
22nd April 2009 14:47 UTC
Thanks a lot, everything works fine !!!
glambert
5th May 2009 09:38 UTC
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?
Afrow UK
5th May 2009 10:16 UTC
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
glambert
5th May 2009 10:26 UTC
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.
Afrow UK
5th May 2009 10:51 UTC
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
glambert
5th May 2009 11:01 UTC
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?
Afrow UK
5th May 2009 11:04 UTC
I assume you have Page Custom ShowDLLPage ProcessDLLPage?
What is the value of $0 after the ::Dialog call?
Stu
glambert
5th May 2009 11:10 UTC
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
glambert
5th May 2009 15:47 UTC
resolved by using nsDialogs
Afrow UK
5th May 2009 16:40 UTC
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
jpderuiter
5th May 2009 17:22 UTC
If I recall correctly 'Flags' in [Field 1] should be NOTIFY|GROUP