Hello!
Does anyone know how you can clean a text field?
How to Clear field from text?
5 posts
A text field where? On a custom page? Please take a bit more time to provide useful information when posting questions!
On customized page using nsDialogs::CreateControl EDIT
I assume by clear you mean just make it empty? Just do
${NSD_SetText} $myTextbox ""
Something like this
# Test Read File
Name "NSIS Test"
Caption "NSIS Test"
OutFile "NSIS Test.exe"
InstallDir "$TEMP\NSIS Test"
# COMPRESS
SetCompressor lzma
# RUN
RequestExecutionLevel user
# INCLUDES
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "FileFunc.nsh"
!include "WinMessages.nsh"
# Icon & Stye
BrandingText /TRIMRIGHT " "
Page custom Page.Custom.Test /ENABLECANCEL
Page instfiles
# LANGUAGES
!insertmacro MUI_LANGUAGE "English" # first language
Function Page.Custom.Test
var /GLOBAL Dialog
var /GLOBAL Btn_Read
var /GLOBAL Path.READ
var /GLOBAL Lbl.Add
var /GLOBAL PATH.FILE
var /GLOBAL Btn_Add
GetDlgItem $0 $HWNDPARENT 1
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 2
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 3
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1990
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1991
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1992
ShowWindow $0 ${SW_HIDE}
System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 632,i 466,i 0x16)"
nsDialogs::Create /NOUNLOAD 1044
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
System::Call "user32::MoveWindow(i$Dialog,i0,i0,i 632,i 466,i0)"
SetCtlColors $Dialog 0xbbbbbb 0x323232
# ...:: ADD FILE ::... #
nsDialogs::CreateControl STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 2% 2% 165u 15u "Add Your File:"
pop $Lbl.Add
SetCtlColors $Lbl.Add 0xbbbbbb 0x323232
CreateFont $0 "MV Boli" "12" "100"
SendMessage $Lbl.Add ${WM_SETFONT} $0 0
nsDialogs::CreateControl /NOUNLOAD EDIT 0x40000000|0x10000000|0x04000000|0x00010000|0x00000080 0 2% 7% 79% 15u ""
Pop $PATH.FILE
CreateFont $0 "MV Boli" "12" "100"
SendMessage $PATH.FILE ${WM_SETFONT} $0 0
SetCtlColors $PATH.FILE 0xbbbbbb 0x424242
# ...:: BTN ADD ::... #
nsDialogs::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 82% 7% 65u 15u ""
Pop $Btn_Add
Strcpy $1 $Btn_Add
GetFunctionAddress $3 "on.Click.Add"
nsDialogs::onClick $1 $3
SetCtlColors $Btn_Add 0xbbbbbb 0x323232
CreateFont $0 "MV Boli" "10" "400"
SendMessage $Btn_Add ${WM_SETFONT} $0 0
SendMessage $Btn_Add '${WM_SETTEXT}' '0' "STR:Add ..."
# ...:: READ LOCATION ::... #
nsDialogs::CreateControl /NOUNLOAD EDIT 0x40000000|0x10000000|0x04000000|0x00010000|0x00000080|0x00000004|0x00200000|0x00100000|0x00000800 0 2% 15% 96% 190u "" # 0x00000100|0x00000200
Pop $PATH.READ
CreateFont $0 "MV Boli" "12" "100"
SendMessage $PATH.READ ${WM_SETFONT} $0 0
SetCtlColors $PATH.READ 0xbbbbbb 0x424242
# ...:: BTN READ ::... #
nsDialogs::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 145u 245u 120u 18u "Read Now ..." ; Read
Pop $Btn_Read
StrCpy $1 $Btn_Read
GetFunctionAddress $3 "On.Click.Read"
nsDialogs::onClick $1 $3
SetCtlColors $Btn_Read 0xbbbbbb 0x323232
CreateFont $0 "MV Boli" "12" "100"
SendMessage $Btn_Read 0x0030 $0 0
nsDialogs::Show
FunctionEnd
# ...:: ADD ::... #
var /global MYFILES
Function "on.Click.Add"
nsDialogs::SelectFileDialog "open" "C:\" "All Files|*.txt;*.ini;*.pls;*.m3u;*.bat;*.nsi;*.nsh;*.dat;*.htm;*.html;*.css;*.js;*.xml;*.rtf;*.log;*.reg;*.lng;*.data;*.json|*.*"
Pop $0
StrCpy $MYFILES "$0"
${NSD_SetText} $PATH.FILE "$MYFILES"
SendMessage $PATH.READ ${WM_SETTEXT} 0 "STR: "
FunctionEnd
Function "On.Click.Read"
FileOpen $4 "$MYFILES" r
loop:
FileRead $4 $1
SendMessage $PATH.READ ${EM_REPLACESEL} 0 "STR:$1"
IfErrors +1 loop
FileClose $4
FunctionEnd
Section "Main" SEC01
SectionEnd
Function .onGUIEnd
FunctionEnd