Archive: how to change the browse button text of the dirrequest control


how to change the browse button text of the dirrequest control
in custom page,I create a dirrequest control,
the browse button has no text,only three dot,I want to change these three dot to text,such as "click here to browser"

thanks


You'll have to work some magic to do that, since InstallOptions doesn't support it. You'll have to call SetWindowPos using the System plug-in to set the button's size and then use SendMessage with WM_SETTEXT to set the new text.

These should help:

http://nsis.sourceforge.net/Moving_i..._of_the_screen
http://nsis.sourceforge.net/Change_c...ler_at_runtime


Hi Kichik or anybody,

Sorry I am very new to write NSIS scripts. I’ve the same problem, too. Can anybody help?

I don’t quite understand what is “call SetWindowPos using the System plug-in to set the button's size” and “use SendMessage with WM_SETTEXT to set the new text”

I only know how to use SetWindowPos for setting the Window position? How can it set the button position?

According to the example provided in http://nsis.sourceforge.net/Change_...ller_at_runtime
Like:

SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:We are waiting... [Section 1]"

The SendMessage and WM_SETTEXT only set the heading of the window. I try to set it to DirRequest, it is not working.

Would you mind explaining more about how to do so?

Thanks for your help.
:cry:


Alternatively you may use the function BrowseForFolder somehow like in the following example.
The function BrowseForFolder spreads around the forum with some examples as well.

Name "My Application"
OutFile 'test.exe'
LicenseData '${NSISDIR}\License.txt'
LicenseBkColor 0xFFFFFF
ShowInstDetails show

!include WinMessages.nsh

Page License
Page Custom CustomCreate CustomLeave
Page InstFiles

Section "boo"
SetOutPath '$INSTDIR'
SectionEnd

Function CustomCreate
WriteIniStr '$PLUGINSDIR\custom.ini' 'Settings' 'NumFields' '2'

WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Type' 'Text'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Left' '5'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Top' '36'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Right' '166'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Bottom' '48'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'Flags' 'READONLY|NOWORDWRAP'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'State' ''

WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Type' 'Button'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Left' '174'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Top' '35'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Right' '-5'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Bottom' '49'
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Flags' 'Notify'
; WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'State' ''
WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 2' 'Text' 'This button really sucks'

push $0
InstallOptions::InitDialog /NOUNLOAD '$PLUGINSDIR\custom.ini'
pop $0
ReadINIStr $1 "$PLUGINSDIR\custom.ini" "Field 1" "HWND"
SetCtlColors $1 0x000000 0xFFFFFF
InstallOptions::Show '$PLUGINSDIR\custom.ini'
pop $0
pop $0
FunctionEnd

Function CustomLeave
ReadIniStr $0 '$PLUGINSDIR\custom.ini' 'Settings' 'State'
StrCmp $0 '2' 0 next

Call BrowseForFolder
StrCmp $3 '' _abort

WriteIniStr '$PLUGINSDIR\custom.ini' 'Field 1' 'State' '$3'
ReadIniStr $0 '$PLUGINSDIR\custom.ini' 'Field 1' 'HWND'
SendMessage $0 ${WM_SETTEXT} 0 'STR:$3'
_abort:
Abort

next:
ReadIniStr $0 '$PLUGINSDIR\custom.ini' 'Field 1' 'State'
StrCmp $0 '' 0 exit
MessageBox MB_OK|MB_ICONEXCLAMATION "Plz browse for a folder"
Abort
exit:
StrCpy '$INSTDIR' '$0'
FunctionEnd

Function BrowseForFolder
System::Store "s r9"

; BrowseInfo structure
System::Call '*(i $HWNDPARENT, i 0, t "", t r9, i 0x45, i 0, i, i) i.r1'
System::Call 'shell32::SHBrowseForFolderA(i r1) i.r2'
System::Free $1

; now we should determine folder name from given PIDL
System::Call 'shell32::SHGetPathFromIDListA(i $2, t "" r3)'

; IMalloc->Free work
System::Call 'shell32::SHGetMalloc(*i . r4)' ; Get the pointer to interface
; IMalloc->Free call
System::Call '$4->5(i r2)'
; IMalloc->Release
System::Call '$4->2()'

System::Store "p3 l"
FunctionEnd

Function .onInit
InitPluginsDir
GetTempFileName $0
Rename $0 '$PLUGINSDIR\custom.ini'
FunctionEnd

I did this quite a while ago:
http://forums.winamp.com/showthread.php?threadid=245878

-Stu


Thank you. It's working. :D