Archive: Adding Button on Cutom Page


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...


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.


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

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
>

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..


Hi All.


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.


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


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.


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.

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...


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.)


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


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