Archive: NSDialogs Help


NSDialogs Help
Let me start off by saying I'm kind of a noob :P

I've made an installer for a program I've created. It's an addon for a game and it checks for certain files and copies them over from a CD if one is missing. I've got all the functions completed but trying to make a page strictly for this and it shows details and a dirrequest for the CD...

also I'm playing on adding a button to say start the CD copy function... and a text below showing witch CD they need and what file it found missing... I used installoptions first but most of this couln't be accomplished due to can't be called back.. well maybe :(

Var DIRREQ
Function MPQCheck
nsDialogs::Create /NOUNLOAD 1018

${NSD_CreateDirRequest} 0 0 75% 12u "$PROGRAMFILES\Awesom-O"
Pop $DIRREQ
GetFunctionAddress $0 DIREC
nsDialogs::OnChange /NOUNLOAD $DIRREQ $0

${NSD_CreateBrowseButton} 345 0 15% 12u "Browse"
Pop $DIRREQ
GetFunctionAddress $0 DIREC
nsDialogs::GetText /NOUNLOAD $DIRREQ $0

nsDialogs::Show
FunctionEnd

Function DIREC
Pop $0 # HWND

System::Call user32::GetWindowText(i$DIRREQ,t.r0,i${NSIS_MAX_STRLEN})

StrCpy $INSTDIR "$0"
FunctionEnd

That's what I tried and failing at trying to get the browse button to work and also getting it to show up in the DirRequest


Well, I can give you an example that I am using today...
Hopefully it doesn't cut/paste too badly...
(I basically leeched it from the InstallOptions -> nsdialog code)



${NSD_CreateDirRequest} 20 70 248 18 ""
Pop $DIGI.DestinationLocations.DirRequest1
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$ESP_LOCATION"

${NSD_CreateBrowseButton} 270 69 24 18 "..."
Pop $DIGI.DestinationLocations.Button1
${NSD_OnClick} $DIGI.DestinationLocations.Button1 OnDirBrowseButton



Function OnDirBrowseButton
Pop $R0

${If} $R0 == $DIGI.DestinationLocations.Button1

${NSD_GetText} $DIGI.DestinationLocations.DirRequest1 $R0

nsDialogs::SelectFolderDialog /NOUNLOAD "" $R0
Pop $R0

${If} $R0 != error
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$R0"
${EndIf}




In your "LEAVE" function, you can get the text by doing:
${NSD_GetText} $DIGI.DestinationLocations.DirRequest1 $R0


Well I added that to what I believed wut u meant but errors on compiling

specifically:
Pop $DIGI.DestinationLocations.DirRequest1

what i did:
Function MPQCheck
nsDialogs::Create /NOUNLOAD 1018

${NSD_CreateDirRequest} 20 70 248 18 ""
Pop $DIGI.DestinationLocations.DirRequest1
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$ESP_LOCATION"

${NSD_CreateBrowseButton} 270 69 24 18 "..."
Pop $DIGI.DestinationLocations.Button1
${NSD_OnClick} $DIGI.DestinationLocations.Button1 OnDirBrowseButton

nsDialogs::Show
FunctionEnd

Function OnDirBrowseButtonn
Pop $R0

${If} $R0 == $DIGI.DestinationLocations.Button1

${NSD_GetText} $DIGI.DestinationLocations.DirRequest1 $R0

nsDialogs::SelectFolderDialog /NOUNLOAD "" $R0
Pop $R0

${If} $R0 != error
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$R0"
${EndIf}
FunctionEnd

Function MPQCheckLeave
${NSD_GetText} $Text $Text_State
${NSD_GetState} $Checkbox $Checkbox_State
FunctionEnd


Yes, I didn't do too good of job cutting/pasting. =)

I assume you have declared the VARs, ie:
Var DIGI.DestinationLocations.Button1
Var DIGI.DestinationLocations.DirRequest1

?


Now I get no label logiclib sumden

what I have now:

Var DIGI.DestinationLocations.Button1
Var DIGI.DestinationLocations.DirRequest1

Function MPQCheck
nsDialogs::Create /NOUNLOAD 1018

${NSD_CreateDirRequest} 20 70 248 18 ""
Pop $DIGI.DestinationLocations.DirRequest1
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$ESP_LOCATION"

${NSD_CreateBrowseButton} 270 69 24 18 "..."
Pop $DIGI.DestinationLocations.Button1
${NSD_OnClick} $DIGI.DestinationLocations.Button1 OnDirBrowseButton

nsDialogs::Show
FunctionEnd

Function OnDirBrowseButton
Pop $R0

${If} $R0 == $DIGI.DestinationLocations.Button1

${NSD_GetText} $DIGI.DestinationLocations.DirRequest1 $R0

nsDialogs::SelectFolderDialog /NOUNLOAD "" $R0
Pop $R0

${If} $R0 != error
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$R0"
${EndIf}
FunctionEnd

Function MPQCheckLeave
${NSD_GetText} $DIGI.DestinationLocations.DirRequest1 $R0
FunctionEnd


Make sure you include logiclib at the top of your script:

!include "LogicLib.nsh"


Had that

compile error:

Error: could not resolve label "_LogicLib_Label_10" in function "OnDirBrowseButton"


Originally posted by Sheik
Make sure you include logiclib at the top of your script:

!include "LogicLib.nsh"
LogicLib.nsh is included by nsDialogs.nsh, when you use nsDialogs you don't have to "!include" LogicLib.nsh again.

Don

I think you are missing an $(EndIf}

Change this:

...
${If} $R0 != error
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$R0"
${EndIf}
FunctionEnd

To:

...
${If} $R0 != error
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$R0"
${EndIf}
${EndIf}
FunctionEnd

Too bad we can't see indents here, it would be more obvious. =)


Ok that worked perfectly... Now how do you refresh the Custom Page since when going through my functions it should add information into the Variables $MPQNFO and $DISC but yet after going through my function and pausing for the second one it does not update my label

Var DIGI.DestinationLocations.Button1
Var DIGI.DestinationLocations.DirRequest1
Var BUTTON
Var INFO

Function MPQCheck
ReadINIStr $MPQ "$PLUGINSDIR\Setup.ini" "Field 4" "State"
StrCmp $MPQ "1" yes no
yes:
cdrom::FindNext /NOUNLOAD .r0
cdrom::FindClose
nsDialogs::Create /NOUNLOAD 1018

${NSD_CreateDirRequest} 0 25 75% 12u ""
Pop $DIGI.DestinationLocations.DirRequest1
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$0"

${NSD_CreateBrowseButton} 340 25 8% 12u "..."
Pop $DIGI.DestinationLocations.Button1
${NSD_OnClick} $DIGI.DestinationLocations.Button1 OnDirBrowseButton

${NSD_CreateButton} 0 100 8% 12u Ok
Pop $BUTTON
GetFunctionAddress $0 OnClick
nsDialogs::OnClick /NOUNLOAD $BUTTON $0

${NSD_CreateLabel} 0 0u 75% 40u "$INFO"
Pop $0

nsDialogs::Show
no:
FunctionEnd

Function OnDirBrowseButton
Pop $R0

${If} $R0 == $DIGI.DestinationLocations.Button1

${NSD_GetText} $DIGI.DestinationLocations.DirRequest1 $R0

nsDialogs::SelectFolderDialog /NOUNLOAD "" $R0
Pop $R0

${If} $R0 != error
${NSD_SetText} $DIGI.DestinationLocations.DirRequest1 "$R0"
${EndIf}
${EndIf}
FunctionEnd

Function OnClick
Sleep 1000
Pop $0 # HWND
Call Controller
FunctionEnd

Function MPQCheckLeave
${NSD_GetText} $DIGI.DestinationLocations.DirRequest1 $R0
FunctionEnd