Skip to content
⌘ NSIS Forum Archive

referencing Data entered in NSIS Dialog Designer Form

8 posts

coderwolf#edited

referencing Data entered in NSIS Dialog Designer Form

I have a form(created with NSIS Dialog Designer) with 1 checkbox, 1 groupbox, 2 RadioButtons(grouped together), 2 textboxes, 1 password, 3 Labels on it. How would I reference the data that is entered in the form.

edit: I have tried the $R0-$R4 and $0 - $4 and it gave me nothing (fnc_Config is located in DialogTest1.nsdinc)


!include MUI2.nsh
!include "DialogTest1.nsdinc"

Page custom fnc_Config_Show fnc_Show_Config

Function fnc_Show_Config
MessageBox MB_OK "$R0, $R1, $R2, $R3, $R4, $0, $1"
FunctionEnd
coderwolf#
Do the "handle variables" section hold the Hwnd values to be used in the GetUserData? If not , how would I get the HWND variables needed?
Anders#
I have never used that dialog designer so I don't know. I would guess they are in that .nsdinc file...
coderwolf#
They are. I am not sure of all the sides of NSIS as well. I am just 3 days into using it. And there are some areas that are still confusing to me.

The relevant pieces appear to be:
(inside the nsdinc file)

Var hCtl_Config_TB_FTPUser
Function fnc_Config_Create
nsDialogs::Create 1018
Pop $hCtl_Config
${If} $hCtl_Config == error
Abort
${EndIf}
!insertmacro MUI_HEADER_TEXT "Configuration" "Config"
; === TB_FTPUser (type: Text) ===
${NSD_CreateText} 68u 57u 59u 10u ""
Pop $hCtl_Config_TB_FTPUser
FunctionEnd

Function fnc_Config_Show
Call fnc_Config_Create
nsDialogs::Show $hCtl_Config
FunctionEnd
I tried this as a change to the below function in my file and it did not work.

Function fnc_Show_Config
nsDialogs::GetUserData ${hwnd} hCtl_Config_TB_FTPUser
Pop $user
MessageBox MB_OK "$User"
FunctionEnd
Anders#
Pop $hCtl_Config_TB_FTPUser is the part that saves the hwnd.

I assume you got a compiler warning, don't ignore them!

nsDialogs::GetUserData $hCtl_Config_TB_FTPUser
coderwolf#
this was a temporarily put aside project, however, I had another one come up that was very similar.

On the below project I am getting no results in the Variables I am trying to get the data out of. The dialog was also created by the Coolsoft NSIS Dialog Designer. What am I doing wrong?

Office Path.nsdinc(Form file) contains: (FR_*_BTN is the button of a FileRequest, FR_*_TXT is the TextBox portion of it)
; handle variables
Var hCtl_Office_Path
Var hCtl_Office_Path_LB_ExcelEXEFile
Var hCtl_Office_Path_LBL_WordEXEFile
Var hCtl_Office_Path_FR_ExcelPath_Txt
Var hCtl_Office_Path_FR_ExcelPath_Btn
Var hCtl_Office_Path_FR_WordPath_Txt
Var hCtl_Office_Path_FR_WordPath_Btn
I am using a Function in my file to try to get the data:
Function fnc_Office_PathData_Show
!insertmacro NSD_GetUserData $hCtl_Office_Path_FR_ExcelPath_Txt $ExcelEXEPath
!insertmacro NSD_GetUserData $hCtl_Office_Path_FR_WordPath_Txt $WordEXEPath
MessageBox MB_OK "Excel = $ExcelEXEPath; Word = $WordEXEPath"
FunctionEnd
To support this I took the code off of a webpage and placed it in NSD_GetUserData.nsh file (which I !included in my file with the function)
!macro NSD_SetUserData hwnd data
nsDialogs::SetUserData ${hwnd} ${data}
!macroend
!define NSD_SetUserData `!insertmacro NSD_SetUserData`

!macro NSD_GetUserData hwnd outvar
nsDialogs::GetUserData ${hwnd}
Pop ${outvar}
!macroend
!define NSD_GetUserData `!insertmacro NSD_GetUserData`
Anders#
Use the NSD_GetText macro to read text from a edit field. GetUserData only has data if you add something there yourself with SetUserData.