- NSIS Discussion
- Adding Button on Cutom Page
Archive: Adding Button on Cutom Page
atliano
26th May 2011 06:12 UTC
Adding Button on Cutom Page
Hello All,
I have created a custom page in which we can entered input required for database connection like username,password,url ... I want to add a button "test" that immediate test whether connection can be established ..
Can anyone suggest me how can i add a button on custom page and how can i check databse connection on button click event..
Thanks...
MSG
26th May 2011 06:17 UTC
The nsDialogs readme has an excellent tutorial:
http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html
As for database connection, you can try searching the forums, but NSIS is not database software so we can't help you unless you give more information.
atliano
26th May 2011 07:10 UTC
Originally posted by MSG
The nsDialogs readme has an excellent tutorial:
http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html
As for database connection, you can try searching the forums, but NSIS is not database software so we can't help you unless you give more information.
Thanks for your reply..
Could you please let me know how can i perform operation on clicking button..
for databse connection i have wriiten batch file which takes database information from custom pages and i have add a button test on that page olso..now i want to run that batch file which checks whether the information provided by user makes the connection or not...
Thanks
T.Slappy
26th May 2011 08:23 UTC
Use
nsDialogs::OnClick control_HWND function_address
Example:
12u Test
>Var /Global BUTTON
Pop $BUTTON
GetFunctionAddress$0 OnClick
nsDialogs
::OnClick $BUTTON $0
>Function OnClick
Pop$0 # HWND
# Do your stuff here...
# MessageBox MB_OK clicky
>FunctionEnd
>
atliano
26th May 2011 10:06 UTC
Thanks for your reply...
This is not what i required..
I have posted my page ..as you can see i have add a button "Test" now i want that on clicking this test button my batch file starts running and from that batch file i need to redirect my db connectivity output to my installer page..
can anyone help me in doin this..?
Thanks..
atliano
26th May 2011 12:19 UTC
Hi All.
MSG
26th May 2011 14:35 UTC
We are not going to write your installer for you. You have already been given all the information you need to make your custom page work. Slappy's post describes exactly what you need (and you could also have found that information yourself if you had looked at the nsDialogs readme).
As for your question about how to capture the output of a batch file, I think the ExecDos plugin can do that (to some extent). But it's better to write to a .txt file for example (use something like "command.exe param1 param2 > yourfile.txt" in the batch file), and read that using the FileRead command.
atliano
31st May 2011 07:56 UTC
Hi All,
Thanks MSG for ur reply ..even i am not saying to write an installer for me..Watever Solution Slappy had wriiten is not working for me..its because i have mase my custom page usinh ini file...
and i want to perform some task on clicking my button that is defined in ini file...
Above wriiten code bascically adds a new dialog that i dont required...
Can any one knw how to get address of button defined in '.ini' file at run time and do some operations on clicking that button..
Thanks
MSG
31st May 2011 08:24 UTC
I haven't used InstallOptions in ages, so I really can't remember if it even supports onClick events in the first place... But either way, please switch to nsDialogs. InstallOptions is only supplied with NSIS for backwards compatibility. It should not be used for new installers.
pengyou
31st May 2011 11:54 UTC
Can any one knw how to get address of button defined in '.ini' file at run time and do some operations on clicking that button..
This is explained in the InstallOptions Readme documentation. You should also look at the InstallOptions example scripts that come with NSIS.
atliano
31st May 2011 13:46 UTC
Hi All,
Thanks a ton Peng You..yeah i Read it from manual and i got the Solution of my problem...
I need to know one more thing, I want that on clicking button (defined in my ini file), dynamically it generates a label on same page and display text whatever we want...
Can anyone have idea about it??
Thanks...
pengyou
31st May 2011 14:59 UTC
Define the label in your .ini file but use the ShowWindow command to hide the label before the custom page is shown. When the button is clicked use SendMessage to set the label text and use ShowWindow to show the label. (The testnotify.nsi example script uses SendMessage to change the text on some controls.)
atliano
2nd June 2011 08:47 UTC
Hi All,
Hey Pengyou Thanks for ur Wonderful Help...I really got good suggestion on my post..
Thanx to all..
I just left with one thing ...i need to know how can i change text color of label...Please if anyone know the color values...post here..Basically i need color value (Red and Green) for my text of label...
Thanks
pengyou
2nd June 2011 10:45 UTC
The answer is in the manual (SetCtlColors):
http://nsis.sourceforge.net/Docs/Cha...html#4.9.14.15
There are some color definitions in Colors.nsh
Here is one way to use red text for a label:
ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 7" "HWND"
SetCtlColors $1 0xFF0000 transparent