Archive: catch more then 1 event on custom page


catch more then 1 event on custom page
Hello,

at first sorry for my bad english, but i hope you understand me.



Function getDataTestDBLeave

readinistr $0 'getDataTestDB.ini' 'Settings' 'State'
StrCmp $0 10 TestDB_checked TestDB_nocheck

TestDB_checked:

ReadIniStr $3 "getDataTestDB.ini" "Field 3" "HWND"
ReadIniStr $5 "getDataTestDB.ini" "Field 5" "HWND"
ReadIniStr $7 "getDataTestDB.ini" "Field 7" "HWND"
ReadIniStr $9 "getDataTestDB.ini" "Field 9" "HWND"

ReadIniStr $1 "getDataTestDB.ini" "Field 10" "state"
StrCmp $1 1 enable disable

disable:
EnableWindow $3 0
EnableWindow $5 0
EnableWindow $7 0
EnableWindow $9 0

WriteIniStr "getDataTestDB.ini" "Field 3" "Flags" "DISABLED"
WriteIniStr "getDataTestDB.ini" "Field 5" "Flags" "DISABLED"
WriteIniStr "getDataTestDB.ini" "Field 7" "Flags" "DISABLED"
WriteIniStr "getDataTestDB.ini" "Field 9" "Flags" "DISABLED"
pop $0
pop $1
pop $3
pop $5
pop $7
pop $9
abort

enable:
EnableWindow $3 1
EnableWindow $5 1
EnableWindow $7 1
EnableWindow $9 1

WriteIniStr "getDataTestDB.ini" "Field 3" "Flags" ""
WriteIniStr "getDataTestDB.ini" "Field 5" "Flags" ""
WriteIniStr "getDataTestDB.ini" "Field 7" "Flags" ""
WriteIniStr "getDataTestDB.ini" "Field 9" "Flags" ""
pop $0
pop $1
pop $3
pop $5
pop $7
pop $9

abort


/* Here begins my Problem */



Readinistr '$TestDB_Hostname_state' 'getDataTestDB.ini' 'Field 3' 'State'
${If} $TestDB_Hostname_state == ''
MessageBox MB_OK "Hostname nicht gesetzt"
abort
${Endif}

Readinistr '$TestDB_TNSname_state' 'getDataTestDB.ini' 'Field 5' 'State'
${If} $TestDB_TNSname_state == ''
MessageBox MB_OK "TNS Name nicht gesetzt"
abort
${Endif}

Readinistr '$TestDB_DBSID_state' 'getDataTestDB.ini' 'Field 7' 'State'
${If} $TestDB_DBSID_state == ''
MessageBox MB_OK "DB SID nicht gesetzt"
abort
${Endif}

Readinistr '$TestDB_Listenerport_state' 'getDataTestDB.ini' 'Field 9' 'State'
${If} $TestDB_Listenerport_state == ''
MessageBox MB_OK "Listenerport nicht gesetzt"
abort
${Endif}

TestDB_nocheck:

FunctionEnd


The first part should enable the 4 text-fields and this works fine.
The second part of the funtion should only work, if the user click on next-button.
if the checkbox not enabled, the second part musst not used.

actually, if i enable the checkbox, the code test directly, before i can fill in the fields.

Can anyone help me?

I will check if the fields are filled.

Field 10 is supposed to have the notify flag right?

    Function getDataTestDBLeave

readinistr $0 'getDataTestDB.ini' 'Settings' 'State'
StrCmp $0 0 TestDB_nocheck

ReadIniStr $3 "getDataTestDB.ini" "Field 3" "HWND"
ReadIniStr $5 "getDataTestDB.ini" "Field 5" "HWND"
ReadIniStr $7 "getDataTestDB.ini" "Field 7" "HWND"
ReadIniStr $9 "getDataTestDB.ini" "Field 9" "HWND"

ReadIniStr $1 "getDataTestDB.ini" "Field 10" "state"

EnableWindow $3 $1
EnableWindow $5 $1
EnableWindow $7 $1
EnableWindow $9 $1
Abort

TestDB_nocheck:

Readinistr '$TestDB_Hostname_state' 'getDataTestDB.ini' 'Field 3' 'State'
${If} $TestDB_Hostname_state == ''
MessageBox MB_OK "Hostname nicht gesetzt"
abort
${Endif}

Readinistr '$TestDB_TNSname_state' 'getDataTestDB.ini' 'Field 5' 'State'
${If} $TestDB_TNSname_state == ''
MessageBox MB_OK "TNS Name nicht gesetzt"
abort
${Endif}

Readinistr '$TestDB_DBSID_state' 'getDataTestDB.ini' 'Field 7' 'State'
${If} $TestDB_DBSID_state == ''
MessageBox MB_OK "DB SID nicht gesetzt"
abort
${Endif}

Readinistr '$TestDB_Listenerport_state' 'getDataTestDB.ini' 'Field 9' 'State'
${If} $TestDB_Listenerport_state == ''
MessageBox MB_OK "Listenerport nicht gesetzt"
abort
${Endif}

FunctionEnd

oh sorry, yes field 10 is the checkbox and has the notify flag

field 3,5,7,9 are the text-fields, which are enabled if the checkbox is are enabled.


here the inifile:

Function write_getDataTestDB.ini

  

WriteIniStr 'getDataTestDB.ini' 'Settings' 'NumFields' '10'
WriteIniStr 'getDataTestDB.ini' 'state' 'State' '0'

WriteIniStr 'getDataTestDB.ini' 'Field 1' 'Type' 'Label'
WriteIniStr 'getDataTestDB.ini' 'Field 1' 'Text' 'Bitte geben Sie die Daten ihrer Test-Datenbank ein.\r\nAlle Felder müssen ausgefüllt werden!'
WriteIniStr 'getDataTestDB.ini' 'Field 1' 'Left' '0'
WriteIniStr 'getDataTestDB.ini' 'Field 1' 'Right' '250'
WriteIniStr 'getDataTestDB.ini' 'Field 1' 'Top' '0'
WriteIniStr 'getDataTestDB.ini' 'Field 1' 'Bottom' '20'

WriteIniStr 'getDataTestDB.ini' 'Field 10' 'Type' 'Checkbox'
WriteIniStr 'getDataTestDB.ini' 'Field 10' 'Text' 'TestDatenbank aktivieren'
WriteIniStr 'getDataTestDB.ini' 'Field 10' 'Left' '0'
WriteIniStr 'getDataTestDB.ini' 'Field 10' 'Right' '100'
WriteIniStr 'getDataTestDB.ini' 'Field 10' 'Top' '30'
WriteIniStr 'getDataTestDB.ini' 'Field 10' 'Bottom' '40'
WriteIniStr 'getDataTestDB.ini' 'Field 10' 'State' '0'
WriteIniStr 'getDataTestDB.ini' 'Field 10' 'Flags' 'NOTIFY'

WriteIniStr 'getDataTestDB.ini' 'Field 2' 'Type' 'Label'
WriteIniStr 'getDataTestDB.ini' 'Field 2' 'Text' 'Hostname:'
WriteIniStr 'getDataTestDB.ini' 'Field 2' 'Left' '0'
WriteIniStr 'getDataTestDB.ini' 'Field 2' 'Right' '80'
WriteIniStr 'getDataTestDB.ini' 'Field 2' 'Top' '50'
WriteIniStr 'getDataTestDB.ini' 'Field 2' 'Bottom' '60'

WriteIniStr 'getDataTestDB.ini' 'Field 3' 'Type' 'Text'
WriteIniStr 'getDataTestDB.ini' 'Field 3' 'Left' '100'
WriteIniStr 'getDataTestDB.ini' 'Field 3' 'Right' '220'
WriteIniStr 'getDataTestDB.ini' 'Field 3' 'Top' '50'
WriteIniStr 'getDataTestDB.ini' 'Field 3' 'Bottom' '62'
WriteIniStr 'getDataTestDB.ini' 'Field 3' 'Flags' 'Disabled|notify'

WriteIniStr 'getDataTestDB.ini' 'Field 4' 'Type' 'Label'
WriteIniStr 'getDataTestDB.ini' 'Field 4' 'Text' 'TNS-Name Datenbank:'
WriteIniStr 'getDataTestDB.ini' 'Field 4' 'Left' '0'
WriteIniStr 'getDataTestDB.ini' 'Field 4' 'Right' '80'
WriteIniStr 'getDataTestDB.ini' 'Field 4' 'Top' '70'
WriteIniStr 'getDataTestDB.ini' 'Field 4' 'Bottom' '80'

WriteIniStr 'getDataTestDB.ini' 'Field 5' 'Type' 'Text'
WriteIniStr 'getDataTestDB.ini' 'Field 5' 'Left' '100'
WriteIniStr 'getDataTestDB.ini' 'Field 5' 'Right' '220'
WriteIniStr 'getDataTestDB.ini' 'Field 5' 'Top' '70'
WriteIniStr 'getDataTestDB.ini' 'Field 5' 'Bottom' '82'
WriteIniStr 'getDataTestDB.ini' 'Field 5' 'Flags' 'Disabled'

WriteIniStr 'getDataTestDB.ini' 'Field 6' 'Type' 'Label'
WriteIniStr 'getDataTestDB.ini' 'Field 6' 'Text' 'Datenbank SID:'
WriteIniStr 'getDataTestDB.ini' 'Field 6' 'Left' '0'
WriteIniStr 'getDataTestDB.ini' 'Field 6' 'Right' '80'
WriteIniStr 'getDataTestDB.ini' 'Field 6' 'Top' '90'
WriteIniStr 'getDataTestDB.ini' 'Field 6' 'Bottom' '100'

WriteIniStr 'getDataTestDB.ini' 'Field 7' 'Type' 'Text'
WriteIniStr 'getDataTestDB.ini' 'Field 7' 'Left' '100'
WriteIniStr 'getDataTestDB.ini' 'Field 7' 'Right' '220'
WriteIniStr 'getDataTestDB.ini' 'Field 7' 'Top' '90'
WriteIniStr 'getDataTestDB.ini' 'Field 7' 'Bottom' '102'
WriteIniStr 'getDataTestDB.ini' 'Field 7' 'Flags' 'Disabled'

WriteIniStr 'getDataTestDB.ini' 'Field 8' 'Type' 'Label'
WriteIniStr 'getDataTestDB.ini' 'Field 8' 'Text' 'Listenerport:'
WriteIniStr 'getDataTestDB.ini' 'Field 8' 'Left' '0'
WriteIniStr 'getDataTestDB.ini' 'Field 8' 'Right' '80'
WriteIniStr 'getDataTestDB.ini' 'Field 8' 'Top' '110'
WriteIniStr 'getDataTestDB.ini' 'Field 8' 'Bottom' '120'

WriteIniStr 'getDataTestDB.ini' 'Field 9' 'Type' 'Text'
WriteIniStr 'getDataTestDB.ini' 'Field 9' 'Left' '100'
WriteIniStr 'getDataTestDB.ini' 'Field 9' 'Right' '130'
WriteIniStr 'getDataTestDB.ini' 'Field 9' 'Top' '110'
WriteIniStr 'getDataTestDB.ini' 'Field 9' 'Bottom' '122'
WriteIniStr 'getDataTestDB.ini' 'Field 9' 'Flags' 'Disabled|only_numbers'

FunctionEnd


edit:
it works .... IT WORKS ..........IT WORKS

Thx

Try the code I've posted above, it should be work as expected.


Yes i see it, but i dont understand why this works. can you explain it me?


Well, I think would be better explanation to examine the included InstallOptions examples especially the one named test-notify.nsi :)

Also you could have the same functionality writing less code with nsDialogs.


ok i will do this, but i dont know why my code, with the same functionality not works.


Your code fails mainly because you're adding the label TestDB_nocheck: in the wrong place.
btw why not use logiclib? it's easier.


yes , that is one, what i not understand. TestDB_nocheck: is the labal, where nothing maust be done, and the function ends.

i fought, that if checkbox not "checked", he jumps to TestDB_nocheck: ond function end. now is TestDB_nocheck: before my readed text-fields and he ignores these fields, if checkbox not "checked". Dont understand me false, the code works and makes what i want, but i dont understand why he ignores them.

in my understand ( java, c, c++, php, ... etc.) , a function is read and done, line by line.


Either checked or unchecked the control sets the notify and here is the point where your code fails.

In the example I've posted above, I know the notify is set either by the checkbox or by the next button, so what I do is to check if the next button is pressed, and if it is pressed I jump to the label TestDB_nocheck:, otherwise I know it is the checkbox who triggered the notify and I set the state of the text fields regarding to the state of the check box.


ah ok i think i understand.

now i have the following Problem. test the script, the code works perfektly, but start te installer exe, he checks the textfields too, when the checkbox is not set.

but he shold only check the fields, if they are filled.


Might be beacuse text has added to the fileds so even if the field is disabled the text exists so the condition is true.

Try this:

!include WinMessages.nsh
Function getDataTestDBLeave

readinistr $0 'getDataTestDB.ini' 'Settings' 'State'
StrCmp $0 0 TestDB_nocheck

ReadIniStr $3 "getDataTestDB.ini" "Field 3" "HWND"
ReadIniStr $5 "getDataTestDB.ini" "Field 5" "HWND"
ReadIniStr $7 "getDataTestDB.ini" "Field 7" "HWND"
ReadIniStr $9 "getDataTestDB.ini" "Field 9" "HWND"

ReadIniStr $1 "getDataTestDB.ini" "Field 10" "state"

${If} $1 = 0
SendMessage $3 ${WM_SETTEXT} 0 "STR:"
SendMessage $5 ${WM_SETTEXT} 0 "STR:"
SendMessage $7 ${WM_SETTEXT} 0 "STR:"
SendMessage $9 ${WM_SETTEXT} 0 "STR:"
${EndIf}

EnableWindow $3 $1
EnableWindow $5 $1
EnableWindow $7 $1
EnableWindow $9 $1
Abort

TestDB_nocheck:

Readinistr '$TestDB_Hostname_state' 'getDataTestDB.ini' 'Field 3' 'State'
${If} $TestDB_Hostname_state == ''
MessageBox MB_OK "Hostname nicht gesetzt"
abort
${Endif}

Readinistr '$TestDB_TNSname_state' 'getDataTestDB.ini' 'Field 5' 'State'
${If} $TestDB_TNSname_state == ''
MessageBox MB_OK "TNS Name nicht gesetzt"
abort
${Endif}

Readinistr '$TestDB_DBSID_state' 'getDataTestDB.ini' 'Field 7' 'State'
${If} $TestDB_DBSID_state == ''
MessageBox MB_OK "DB SID nicht gesetzt"
abort
${Endif}

Readinistr '$TestDB_Listenerport_state' 'getDataTestDB.ini' 'Field 9' 'State'
${If} $TestDB_Listenerport_state == ''
MessageBox MB_OK "Listenerport nicht gesetzt"
abort
${Endif}

FunctionEnd

yes that was my idea too, but hoped there were a another idea.

Ok thx for help Red Wine.

Hope that the Tread helps other usere too.


I bet that several users will provide several methods, this is the way nsis works ;)
btw nsDialogs would save your effort for this project.


Originally posted by Red Wine
btw why not use logiclib? it's easier.
It would be even better if it was part of NSIS itself so we could get rid of the ugly ${} around the keywords...

Originally posted by TobbeSweden
It would be even better if it was part of NSIS itself so we could get rid of the ugly ${} around the keywords...
I absolutely agree here.
LogicLib should just become a basic part of the NSIS language.

It sure makes things a lot easier for us average joes. =)