Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 27th March 2019, 04:53   #1
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Smile Can not SETTEXT for the textbox directory after user choose a folder

!include 'MUI2.nsh'

Var /GLOBAL Var_INSTDIR

!define MUI_DIRECTORYPAGE_VARIABLE $Var_INSTDIR
!insertmacro MUI_PAGE_DIRECTORY

Function .onInit
StrCpy '$Var_INSTDIR' '$PROGRAMFILES32'
FunctionEnd

Function .onVerifyInstDir
FindWindow $R2 "#32770" "" $HWNDPARENT
GetDlgItem $R3 $R2 1019
SendMessage $R3 ${WM_SETTEXT} 0 "STR:$Var_INSTDIR\InsertMyNameProgram"
FunctionEnd

Section ABC
SectionEnd



It not SETTEXT for the textbox directory after user choose a folder by click OK on the "DialogBrowseFolder".
meoit is offline   Reply With Quote
Old 27th March 2019, 05:29   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 881
You can see the path changing when you click on folders in the browse dialog, but as soon as ok is clicked, it just puts a backslash on it (because the directory is not valid). The whole point of .onverifyinstdir is to check for an existing folder, and your code always fails because the folder does not exist yet.

It's probably better to just choose the root directory (ie $programfiles32), and append your subdirectories to the path later and create the directories in a section.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 27th March 2019, 07:27   #3
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Yes, Is there a way to automatically add "MyNameProgram" to the path which users selected.

For example, the user selects D:\Software, it automatically add the string MyNameProgram in the end to become D:\Software\MyNameProgram
meoit is offline   Reply With Quote
Old 27th March 2019, 08:22   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,163
Why are you not using InstallDir?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th March 2019, 09:33   #5
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Yes, I need check my path in registry

!include 'MUI2.nsh'

!define FullName 'MyProgramFullName'
!define InstDirDefault '$PROGRAMFILES32\${FullName}'

Var /GLOBAL Var_FINS
Var /GLOBAL Var_INSTDIR

!define MUI_DIRECTORYPAGE_VARIABLE $Var_INSTDIR
!insertmacro MUI_PAGE_DIRECTORY

Function .onInit
ReadRegStr $Var_FINS HKLM 'Software\${FullName}' 'PathInstall'
${If} '$Var_FINS' != ''
StrCpy '$Var_INSTDIR' '$Var_FINS'
${Else}
StrCpy '$Var_INSTDIR' '${InstDirDefault}'
${EndIf}
FunctionEnd

Function .onVerifyInstDir
FindWindow $R2 "#32770" "" $HWNDPARENT
GetDlgItem $R3 $R2 1019
SendMessage $R3 ${WM_SETTEXT} 0 "STR:$Var_INSTDIR\${FullName}"
FunctionEnd

Section ABC
SectionEnd
meoit is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump