Archive: INI File


INI File
  Hello everyone.

Someone can guide me in the following?

I have a custom page with three text fields empty. What I do is that the next button is enabled only when these fields are left empty.

I am looking for how to do something similar to an onchange to validate at this time but I can not find it.

Since already I thank you very much.


My ini file

[Settings]
NumFields=6
NextEnabled=NO

[Field 1]
Type=Label
Text=IP o Host de la base de datos de Cronos
Left=18
Right=174
Top=24
Bottom=36

[Field 2]
Type=Label
Text=Ubicación de la base de datos de Cronos(cronos.fdb)
Left=18
Right=275
Top=60
Bottom=70

[Field 3]
Type=Label
Text=Nombre de estación local
Left=18
Right=278
Top=97
Bottom=105

[Field 4]
Type=Text
Left=18
Right=297
Top=38
Bottom=51
Flags=


[Field 5]
Type=Text
Left=18
Right=297
Top=74
Bottom=87
Flags=

[Field 6]
Type=Text
Left=18
Right=297
Top=110
Bottom=123
Flags=


I think you would need to catch the empty fields in the 'leave' event on that custom page and call Abort.

It would be better to do this through nsDialogs as it has the exact functionality you are looking for. Check out the "\Examples\nsDialogs\example.nsi" file in your NSIS install folder.


I agree nsDialogs is the way to go. So I would do something like the following:


"LogicLib.nsh"

>!include "WinMessages.nsh"
>!include "nsDialogs.nsh"

>Name "dialog"
>OutFile "dialog.exe"

>Page custom nsConfigDialog
Page instfiles

XPStyle on

>Var FIELD1
>Var FIELD2
>Var FIELD3

>Function .onInit
InitPluginsDir
FunctionEnd

>Function nsConfigDialog
; 1018 = resource identifier for child rectangle
nsDialogs
::Create 1018
Pop$0

; Create labels
${NSD_CreateLabel} 18u 24u 156u 12u "IP o Host de la base de datos de Cronos"
Pop $0
${NSD_CreateLabel} 18u 60u 257u 10u "Ubicación de la base de datos de Cronos(cronos.fdb)"
Pop $0
${NSD_CreateLabel} 18u 97u 260u 8u "Nombre de estación loca"
Pop $0

; Create edit fields
${NSD_CreateText} 18u 38u 279u 13u ""
Pop $FIELD1
${NSD_CreateText} 18u 74u 279u 13u ""
Pop $FIELD2
${NSD_CreateText} 18u 110u 279u 13u ""
Pop $FIELD3

; Register callback function to be notified regarding any change
; of the edit fields
GetFunctionAddress$0 OnChange
nsDialogs::OnChange $FIELD1 $0
nsDialogs::OnChange $FIELD2 $0
nsDialogs::OnChange $FIELD3 $0

; Disable Install button by default
GetDlgItem $0 $HWNDPARENT 1
EnableWindow$0 0

nsDialogs::Show
FunctionEnd

>Function OnChange
Exch$0 ; HWND
Push$1
Push$2
Push$3

; Read contents of edit fields
${NSD_GetText} $FIELD1 $1
${NSD_GetText} $FIELD2 $2
${NSD_GetText} $FIELD3 $3

GetDlgItem$0 $HWNDPARENT 1
${If} $1 != ""
${AndIf} $2 != ""
${AndIf} $3 != ""
; Enable Install button
EnableWindow$0 1
${Else}
; Disable Install button
EnableWindow$0 0
${EndIf}

Pop $3
Pop$2
Pop$1
Pop$0
FunctionEnd

Section
SectionEnd
>