Archive: Many buttons on Custom page


Many buttons on Custom page
I am trying to study InstallOptions. I see some things which I can not do.
If somebody used to pass them,please help me!!!!
In my custom page, I have 4 button and two button (View Readme and exit)
----------------
| Button 1 |
----------------
| Button 2 |
----------------
| Button 3 |
----------------
| Button 4 |
----------------
------ ------
|View| |Exit|
------ ------

I want to disable button 2,3,4.When my application run only button 1, view, and exit enable.
I also set FLAGS =DISABLES for three button and in my script,I set it

WriteINIStr $INI "Field 2" "Flags" "DISABLES"
WriteINIStr $INI "Field 3" "Flags" "DISABLES"
WriteINIStr $INI "Field 4" "Flags" "DISABLES"

It does not work.
I used to think that

GetDlgItem $1 $HWNDPARENT 1
EnableWindow $1 0

To enable/disable button but I do not know id dialog item.
If the first button is pressed, application is executed.
After finishing, button 2 is enable and button 1 is diables.
One more question, I look for information on forum and I see software Resource Hacker.But I do not know what it work and support???
If Someone know please help me!!!

Thank alot,


Hi sunlight112,

I guess the problem with the quotes in WriteINIStr statements. Apart from that, I would suggest you to have 4 different custom pages instead one in place having 4 buttons on it. I guess the user also should be ok with it unless it is a long process.

Resource hacker available at: http://www.angusj.com/resourcehacker/
XN Resource Editor
http://www.wilsonc.demon.co.uk/d10resourceeditor.htm

This are both very powerful resource editors to edit any PE file(.exe/.dll). This softwares normally used for changing string, editing icons or Bitmaps and even add/remove some of the Dialog items as well. You can manuplate many things with this softwares if such Exe is not compressed with the executable packer softwares like UPX (http://upx.sourceforge.net/).

I hope, this is helpful to you.
Best of luck.


Thank n_baua for your reply,
Because my application need to install many software to support for it. I want to create the first page give above. When the user click on Button 1,the first software will install and follow these steps. Finishing the first, the button 1 is disenable and button 2 is enable for user to set up the second software.The process continue to the end.
If I create 4 custom page,I am worry it is difficult for user to run my installer.
Once again thank you for your document about ResourceHacker and XN Resource Editor.
I read it careful but I do not know when we use this. I can change page my custom page yet???
XN Resource Editor is a screen for us to create my dialog???
Please tell me more clearly about XN Resource Editor or ResourceHacker(RH) because I do not know to use it in NSIS.
If I use RH to change dialog and save them with file *.rec.
After that, I do not know what I can do with it.
Please hellp me!!!


I am afraid about my word if someone read my messages not clearly.
Please do not hesistace to tell me about my words.
Once things, I want to express more clearly about my questions.I only want to know how to change state of button on file ini.
In my case, I have six button (include exit and view readme) to control. I want to change the status of these buttons.
I mean when my menu run, Button 1 is enable, button 2,3,4 is disable . Untill finishing the first install, Button 1,3,4 is disable and button 2 is enable
One button which user click is one application.
How can I know state of buttons to run application which is suitable??
Please help me!!!
I read these files InstallOptions and on forum carefully but I can not find out it.
I am sorry for my bad words,
Thank in advance,
:)


The flag name is DISABLED not DISABLES and the control id of the buttons is not 1. The first control is 1200, the second 1201 and so on. You can also get the HWND from the INI after the dialog shows. Every field has the HWND value after InstallOptions loads the INI. There's no need for GetDlgItem.

Resource Hacker is not related to InstallOptions, it for something else.


Thank Kichik,
Now I can do it well. However, I have one more question.
In my case, user click on BUTTON 1 to run my application,the other buttons is disable.After finishing process, I want to disable button 1 and enable button 1 to install the second application.
My code here:


;$INI is file menu.ini

Function .onInit

WriteINIStr $INI "Field 2" "Flags" "DISABLED"
WriteINIStr $INI "Field 3" "Flags" "DISABLED"
WriteINIStr $INI "Field 4" "Flags" "DISABLED"

FunctionEnd
Function ShowCustom
InstallOptions::initDialog /NOUNLOAD "$INI"
Pop $0
InstallOptions::show
Pop $0
FunctionEnd
Function LeaveCustom1
ReadINIStr $0 $INI "Settings" "State"
StrCmp $0 1 Button1
StrCmp $0 2 Button2
StrCmp $0 3 Button3
StrCmp $0 4 Button4
StrCmp $0 0 ReadMe
Abort
Button1:
SetOutPath $PLUGINSDIR
File "c:\test\java.exe"
Exec "$PLUGINSDIR\java.exe"

WriteINIStr $INI "Field 1" "Flags" "DISABLED"
WriteINIStr $INI "Field 2" "Flags" ""

Button2:
File "c:\test\mysql.exe"
Exec "$PLUGINSDIR\mysql.exe"

WriteINIStr $INI "Field 2" "Flags" "DISABLED"
WriteINIStr $INI "Field 3" "Flags" ""


Button3:
File "c:\test\test_game.exe"
Exec "$PLUGINSDIR\test_game.exe"

WriteINIStr $INI "Field 3" "Flags" "DISABLED"
WriteINIStr $INI "Field 4" "Flags" ""

Button4:
File "c:\test\myproduct.exe"
Exec "$PLUGINSDIR\myproduct.exe"

WriteINIStr $INI "Field 4" "Flags" "DISABLED"


ReadMe:
SetOutPath $PLUGINSDIR
File "e:\server\script\readme.txt"
ExecWait "readme.txt"
Abort
FunctionEnd

My question:
+ I do not know how to change state button from disable to enable and otherwise when I has already shown custom page.
+ In my code, ReadMe part also does not execute file readme.
Your help is very useful for me,
Thank a lot,

your script is fraught with issues, I'm afraid


Function .onInit
WriteINIStr $INI "Field 2" "Flags" "DISABLED"
WriteINIStr $INI "Field 3" "Flags" "DISABLED"
WriteINIStr $INI "Field 4" "Flags" "DISABLED"
FunctionEnd


Is $INI hardcoded to a specific location? Consider using the plugins folder instead:

InitPluginsDir
File /oname=$PLUGINSDIR\test.ini test.ini


Next point.. you change the Flags for the buttons to "DISABLED" - by doing so, you clear the "NOTIFY" flag, so the user can't press them. You should set "DISABLED|NOTIFY" instead:

InitPluginsDir
File /oname=$PLUGINSDIR\test.ini test.ini
WriteINIStr "$PLUGINSDIR\test.ini" "Field 2" "Flags" "DISABLED|NOTIFY"
WriteINIStr "$PLUGINSDIR\test.ini" "Field 3" "Flags" "DISABLED|NOTIFY"
WriteINIStr "$PLUGINSDIR\test.ini" "Field 4" "Flags" "DISABLED|NOTIFY"


However, if the buttons should be disabled by default anyway - consider hard-coding that in the .ini, and do away with those WriteINIStr's altogether.

Now to enable/disable buttons...
You'll want a variable to hold the InstallOptions dialog's handle:

var hwnd


Then store that handle when you initialize the dialog (note that this also shows how to re-use that $PLUGINSDIR here):

Function ShowCustom
InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\test.ini"
Pop $hwnd
InstallOptions::show
Pop $0
FunctionEnd


Now you can use GetDlgItem to get the button(s), and enable/disable them at will. I've condensed your code a bit for clarity here. Note how it makes use of $hwnd:

Function LeaveCustom
ReadINIStr $0 "$PLUGINSDIR\test.ini" "Settings" "State"
MessageBox MB_OK "Leave value: $0"
StrCmp $0 1 Button1
StrCmp $0 2 Button2
StrCmp $0 3 Button3
StrCmp $0 4 Button4
StrCmp $0 0 ReadMe
Abort
Button1:
MessageBox MB_OK "Button 1 pressed"
GetDlgItem $1 $hwnd 1200
EnableWindow $1 0
GetDlgItem $1 $hwnd 1201
EnableWindow $1 1
Abort
Button2:
MessageBox MB_OK "Button 2 pressed"
GetDlgItem $1 $hwnd 1201
EnableWindow $1 0
GetDlgItem $1 $hwnd 1202
EnableWindow $1 1
Abort
; etc. for the other buttons!


Lastly, for your readme...

ReadMe:
SetOutPath $PLUGINSDIR
File "e:\server\script\readme.txt"
ExecWait "readme.txt"
Abort

Two things...
1. you are extracting the file to $PLUGINSDIR, so you should also execute it from that location, not just as "readme.txt"
2. ExecWait does not take documents/etc. as a command, only applications (with optional parameters).

So try..

ReadMe:
SetOutPath $PLUGINSDIR
File "c:\temp\readme.txt"
ExecWait "notepad.exe $PLUGINSDIR\readme.txt"
Abort


or, more cleanly as it does not assume "notepad.exe" to exist and will use the user's default application for handling .txt files:


ReadMe:
SetOutPath $PLUGINSDIR
File "c:\temp\readme.txt"
ExecShell "open" "$PLUGINSDIR\readme.txt"
Abort


I hope this helps :)

Thank Animaether very much,
Now I can run my application well.