Skip to content
⌘ NSIS Forum Archive

Add stuff to a form

24 posts

anvinh173#

Add stuff to a form

I'd like to add a label or a text box into the form which shows the destination folder to install, but I don't know how? Please help. thanks.
anvinh173#
I meaned I want to add another DIRREQUEST box into dir-page (original page which comes with NSIS package).
Animaether#
You'll have to create a custom one using InstallOptions or InstallOptionsEx. The first is documented and available from the NSIS help, the latter you can find a discussion on here :
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
Animaether#
By the way.. I've done a directory page with two directory fields - it's a bit intricate and has a few 'hacks' to get things looking well. I would recommend using InstallOptionsEx instead of InstallOptions for this.

Two reasons that pop into mind:
1. you can get a NOTIFY event from a user changing the directory path - you can't with InstallOptions (only when going through the browse button, and technically that's not supported - but hey, it works)

2. you can specify the text of the browse button (defaults to "...") - can't do that in InstallOptions, so you have to set the text on the control manually, re-size the control, move it to the left, an then re-size the directory path textbox control to fit. Totally doable, but not preferable 😉
anvinh173#
thank you very much.
I have a droplist on my custom page, and I used GetDrive to get all available drives on my computer. How to list all drives under listItems of droplist (it means when I click the arrow of droplist, it displays drives so I can select one). Thank you
Afrow UK#
You need to write to ListItems with WriteINIStr before showing the page. The value that you write should be in the format "str1|str2|etc"

-Stu
anvinh173#
thanks
when I call GetDrive "ALL" "FunctionName", in FunctionName I got drive in $9 and drive type in $8, and I have more than 4 dif. drives, how can I write these drives to my droplist. Please help, thanks
Animaether#
Function SomePrePageFunction
# clear variable R9, just in case
# we'll be using it to store the list of drives
StrCpy $R9 ""
# call the GetDrives function
${GetDrives} "ALL" "CallBackFunc"
# $R9 now contains e.g. "|C:\|D:\|E:\"
# chop the first "|" off
StrCpy $R9 $R9 -1 1
# now you have a list of drives in the format a listbox requires
# if you're using MUI, you can then write it to your
# InstallOptions file using the following:
!insertmacro MUI_INSTALLOPTIONS_WRITE "InstallOptions.ini" "Field 1" "ListItems" $R9
# please keep in mind that you need to put in the correct ini filename
# and the correct Field number
# initialize the dialog
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "InstallOptions.ini"
# and show it
!insertmacro MUI_INSTALLOPTIONS_SHOW
SectionEnd
Function CallBackFunc
  # add the drive to the drives list
  StrCpy $R9 "$R9|$9"
  Push $0
FunctionEnd 
anvinh173#
I have a custom page, in there I have a DirRequest control, and I want to change the text of Browse button. This is what I did, but it didn't work:
GetDlgItem $1 $HWND 1200
SendMessage $1 ${WM_SETTEXT}1 "STR:Browse"
When I compile, this gives me a warning and ignore the line GetDlgItem because it doesn't recognize the constant HWND. What should I do? Thanks.
Afrow UK#
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R1 $R0 1200
SendMessage $R1 ${WM_SETTEXT} 1 "STR:Browse"

$HWND is a variable not a constant that you'd have to define yourself.

-Stu
anvinh173#
I got it. Thank u very much. Can you show me how to resize the browse button of DirRequest? (since after I change its text from "..." to "browser", it doesn't not display right) thanks.
anvinh173#
I got it. Thank you.
I have a DirRequest on a custom page, when I click browse button it displays browser window, is there any way that I can add text to this window (below the title "Browse for folder")? thanks.
anvinh173#
Custom page

I have a DIrRequest on a custom page. Right after I click OK button on the browser window, is there any way that I can get the selected path, so I can modify it, and display a message box to user before it (selected path) is displayed on the text box of DirRequest? Thanks
anvinh173#
I have a DIrRequest on a custom page. Right after I click OK button on the browser window, is there any way that I can get the selected path, so I can modify it, and display a message box to user before it (selected path) is displayed on the text box of DirRequest? Thanks
Afrow UK#
All the InstallOptions examples show you how to validate input on an InstallOptions page.
Tip: From the Leave function with ReadINIStr (DirRequest>State). To go back to a page, call Abort from the pages' Leave function.

-Stu
anvinh173#
validate the selected dir

I think I didn't state clearly my problem before. This is it: I have a DirRequest on a custom page. I click browse button-> browser window appears-> I select a dir ( C:\ProgramFiles)-> I click OK on browser window-> the selected dir (C:\ProgramFiles) is displayed on text box of dirRequest, but I don't want this, I want to change C:\ProgramFiles to C:\balba and display a message-> and user click OK button on the message wind.-> then new path(C:\balba)is displayed on the text box of dirRequest. It means somehow I can read and modify the selected path before it is displayed on the textbox of DirRequest control. I have tried many times in many ways, couldn't do it. Please help. Thank you.
Afrow UK#
Use Flags=NOTIFY
This will act like the user clicking next when he clicks OK (on the browse window) but the field number of the DirRequest control will be written to Settings>State which you can check with ReadINIStr. For examples see Examples\InstallOptions\NotifyTest.nsi

-Stu

-Stu