Archive: update objects created by nsDialogs


update objects created by nsDialogs
hello to everyone,

how can I update an InputBox created by nsDialogs?

Starting from "NSIS\Examples\nsDialogs\welcome.nsi" of NSIS\

I've created a button that open a selection folder box and it saves the path on a variable but I don't understood how update the InputBox.

This is the button "Browse":

nsDialogs::CreateControl BUTTON ${BS_PUSHBUTTON}|${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP} 0 350 138 90 24 "Browse..."
Pop $MyBrowseVar
GetFunctionAddress $0 BrowseFolder
nsDialogs::OnClick $MyBrowseVar $0

Function BrowseFolder
nsDialogs::SelectFolderDialog /NOUNLOAD "Select folder" "C:\MyApp"
Pop $0 # dir hwnd
${If} ${FileExists} "$0\*.*"
StrCpy $DIRECTORY $0
${EndIf}
FunctionEnd

This is the InputBox that I would update:

nsDialogs::CreateControl EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 15 138 70% 12u "$DIRECTORY"
Pop $DIRECTORY
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $DIRECTORY 1
GetFunctionAddress $0 DirChange

nsDialogs::OnChange $DIRECTORY $0
System::Call shlwapi::SHAutoComplete(i$DIRECTORY,i${SHACF_FILESYSTEM})

Thankss
Bruno


in your dirChange function, simply add ${NSD_SetText} $UI_DIRECTORY "$VAR_DIRECTORY".

Note that I'm specifically stating variables UI_DIRECTORY and VAR_DIRECTORY. Right now you're Pop'ing the 'nsDialogs::CreateControl EDIT' into the variable $DIRECTORY, but you're also using that variable in the StrCpy from the 'nsDialogs::SelectFolderDialog' part of the code. You'll want to split those two up. One to hold the hwnd to the control, and one to hold the value of the directory chosen.


http://nsis.sourceforge.net/Docs/nsD...l#mref-settext


Thanks Animaether, I'm not sure to had understood you mean to do this:

Function DirChange

${NSD_SetText} $UI_DIRECTORY "$VAR_DIRECTORY"

Pop $0 # dir hwnd

GetDlgItem $0 $HWNDPARENT 1

System::Call user32::GetWindowText(i$DIRECTORY,t.d,i${NSIS_MAX_STRLEN})

${If} ${FileExists} $INSTDIR\MyApp.exe
EnableWindow $0 1
${Else}
EnableWindow $0 0
${EndIf}

Call UpdateFreeSpace

FunctionEnd


please some one can post an example?


Thanksss now I've understood and it works.

As you told me a I've splited directory path in two variables ($DIRECTORY and $SELECTEDDIRECTORY) and I've added "$SELECTEDDIRECTORY" as value of the InputBox.

The only difference beetween your suggestions is that I've included the command ${NSD_SetText} inside the function BrowseFolder called by the button "Browse".

Thanksss

I found my mistake. This works:

nsDialogs::CreateControl BUTTON ${BS_PUSHBUTTON}|${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP} 0 350 138 90 24 "Browse..."
Pop $MyBrowseVar
GetFunctionAddress $0 BrowseFolder
nsDialogs::OnClick $MyBrowseVar $0

nsDialogs::CreateControl EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 15 138 70% 12u "$SELECTEDDIRECTORY"
Pop $DIRECTORY
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $DIRECTORY 1
GetFunctionAddress $0 DirChange

nsDialogs::OnChange $DIRECTORY $0
System::Call shlwapi::SHAutoComplete(i$DIRECTORY,i${SHACF_FILESYSTEM})

Function BrowseFolder
nsDialogs::SelectFolderDialog /NOUNLOAD "Select folder" "C:\MyApp"
Pop $0 # dir hwnd
${If} ${FileExists} "$0\*.*"
StrCpy $SELECTEDDIRECTORY $0
${NSD_SetText} $DIRECTORY $SELECTEDDIRECTORY
${EndIf}
FunctionEnd

Function DirChange
Pop $0 # dir hwnd
GetDlgItem $0 $HWNDPARENT 1
System::Call user32::GetWindowText(i$DIRECTORY,t.d,i${NSIS_MAX_STRLEN})
${If} ${FileExists} $INSTDIR\makensis.exe
EnableWindow $0 1
${Else}
EnableWindow $0 0
${EndIf}
Call UpdateFreeSpace
FunctionEnd


solved
Thanksss now I've understood and it works.

As you told me a I've splited directory path in two variables ($DIRECTORY and $SELECTEDDIRECTORY) and I've added "$SELECTEDDIRECTORY" as value of the InputBox.

The only difference beetween your suggestions is that I've included the command ${NSD_SetText} inside the function BrowseFolder called by the button "Browse".

Thanksss

I found my mistake. This works:

nsDialogs::CreateControl BUTTON ${BS_PUSHBUTTON}|${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP} 0 350 138 90 24 "Browse..."
Pop $MyBrowseVar
GetFunctionAddress $0 BrowseFolder
nsDialogs::OnClick $MyBrowseVar $0

nsDialogs::CreateControl EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 15 138 70% 12u "$SELECTEDDIRECTORY"
Pop $DIRECTORY
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $DIRECTORY 1
GetFunctionAddress $0 DirChange

nsDialogs::OnChange $DIRECTORY $0
System::Call shlwapi::SHAutoComplete(i$DIRECTORY,i${SHACF_FILESYSTEM})

Function BrowseFolder
nsDialogs::SelectFolderDialog /NOUNLOAD "Select folder" "C:\MyApp"
Pop $0 # dir hwnd
${If} ${FileExists} "$0\*.*"
StrCpy $SELECTEDDIRECTORY $0
${NSD_SetText} $DIRECTORY $SELECTEDDIRECTORY
${EndIf}
FunctionEnd

Function DirChange
Pop $0 # dir hwnd
GetDlgItem $0 $HWNDPARENT 1
System::Call user32::GetWindowText(i$DIRECTORY,t.d,i${NSIS_MAX_STRLEN})
${If} ${FileExists} $INSTDIR\makensis.exe
EnableWindow $0 1
${Else}
EnableWindow $0 0
${EndIf}
Call UpdateFreeSpace
FunctionEnd