yeah, alright... ${SW_SHOW} and ${SW_HIDE}. Don't forget to include WinMessages.nsh .
( Note that as far as controls are concerned SW_SHOW or SW_SHOWNORMAL have the same effect. The only time you get a difference if it's actually a window. Why 'hide' is zero and 'show is -not- one, and why showwindow is what one uses on -controls- in the first place is beyond me. Microsoft, right? )
nsDialogs
173 posts
How does one get a Handle to a specific control on a custom page?
It's returned from ${NSD_Create*} or nsDialogs::CreateItem on the stack.
Originally posted by AnimaetherThat is an excellent idea. In fact, I'm going to modify the registration component to use nsDialog and implement that feature. Thanks for the idea. Kichik, thanks for putting this extension out.
just get a handle to that checkmark and, in the callback function of the nsdialog item, use showwindow <hwnd> 0|1 to hide / unhide it?
Getting used to the nsDialogs plugin.
Another quick question.
1) I want to show a page with some text.
2) Show animated .gif
3) Run function (function handles moving to the next page)
Currently I can't figure out how to do this.
#Start Connecting Page
Function ConnectingPage
;Create page
nsDialogs::Create /NOUNLOAD 1018
Pop $0
;(*Update)
!insertmacro MUI_HEADER_TEXT "Connecting to the Activation Server" "Please wait while we activate $(^NameDA)."
${NSD_CreateLabel} 0 10 100% 50u "Please wait while we activate $(^NameDA)."
Pop $0
nsDialogs::Show
Call StartActivation
FunctionEnd
#End Connecting Page
Using the above code: "StartActivation" is not run until after the NEXT, BACK or CANCEL buttons are clicked.
If I move "Call StartActivation" before "nsDialogs::Show" then the function is run before the text is displayed.
Any help would be much appreciated.
Thanks.
Another quick question.
1) I want to show a page with some text.
2) Show animated .gif
3) Run function (function handles moving to the next page)
Currently I can't figure out how to do this.
#Start Connecting Page
Function ConnectingPage
;Create page
nsDialogs::Create /NOUNLOAD 1018
Pop $0
;(*Update)
!insertmacro MUI_HEADER_TEXT "Connecting to the Activation Server" "Please wait while we activate $(^NameDA)."
${NSD_CreateLabel} 0 10 100% 50u "Please wait while we activate $(^NameDA)."
Pop $0
nsDialogs::Show
Call StartActivation
FunctionEnd
#End Connecting Page
Using the above code: "StartActivation" is not run until after the NEXT, BACK or CANCEL buttons are clicked.
If I move "Call StartActivation" before "nsDialogs::Show" then the function is run before the text is displayed.
Any help would be much appreciated.
Thanks.
Got it.
Just changed it so the user had to click next to progress.
#Start Connecting Page
Function ConnectingPage
;Create page
nsDialogs::Create /NOUNLOAD 1018
Pop $0
!insertmacro MUI_HEADER_TEXT "Connect to the Activation Server" "Please continue to activate $(^NameDA)."
${NSD_CreateLabel} 0 10 100% 50u "Please click next to activate $(^NameDA).$\n$\n\
Please be patient as activation may take up to 30 seconds."
Pop $0
nsDialogs::Show
FunctionEnd
Function PostConnecting
Call StartAnimation
Call StartActivation
FunctionEnd
#End Connecting Page
Just changed it so the user had to click next to progress.
#Start Connecting Page
Function ConnectingPage
;Create page
nsDialogs::Create /NOUNLOAD 1018
Pop $0
!insertmacro MUI_HEADER_TEXT "Connect to the Activation Server" "Please continue to activate $(^NameDA)."
${NSD_CreateLabel} 0 10 100% 50u "Please click next to activate $(^NameDA).$\n$\n\
Please be patient as activation may take up to 30 seconds."
Pop $0
nsDialogs::Show
FunctionEnd
Function PostConnecting
Call StartAnimation
Call StartActivation
FunctionEnd
#End Connecting Page
Hi!
Have been spending quite a bit of time rewriting my custom pages to using nsDialogs and must say its a much better way of doing things...
One thing I am having problems with though is the link control.
For example, I have this:
Regards,
Brad.
Have been spending quite a bit of time rewriting my custom pages to using nsDialogs and must say its a much better way of doing things...
One thing I am having problems with though is the link control.
For example, I have this:
The problem is setting the text colour of the link. For some reason, no text is displayed at all. (Clicking on the link's bounding rectangle works, the OnLinkClick function is called fine.) Any ideas?
${NSD_CreateLink} 29u 125u 96u 10u "http://nsis.sourceforge.net/"
Pop $LINKCONTROL
${NSD_OnClick} $LINKCONTROL OnLinkClick
SetCtlColors $LINKCONTROL ${BLUE} ${WHITE}
Regards,
Brad.
Links are not yet supported.
I got the links to work by just putting a link and label in the same area and changing the label text to blue and underlined.
It is a very major pain if the link is in the middle of a sentence but oh well.
It is a very major pain if the link is in the middle of a sentence but oh well.
How does one set the focus to a control on a nsDialogs page?
Check out the win32 API SetFocus()
Yeah I got it to work nicely.
How about password character masking? 🙂
Thanks.
How about password character masking? 🙂
Thanks.
I am having trouble getting FileRequest working, I've tried to modify the function as it won't be read from an ini file, but I'm not having much luck.
Does anyone have an example of it working?
Does anyone have an example of it working?
Can someone throw together a quick example? I'm not sure how you guys figured this thing out, unless it was just by reading the .nsh and trial and error.
Just something like:
Custom "enter a message" page with a text box, a check box, a button.
Button pops up a message box saying "You pushed the button".
One section that just does a DetailPrint "Contents of text box: " and whatever you typed into the box, and "The check box [was | was not] checked." with whether it was checked or not.
Thanks...
Just something like:
Custom "enter a message" page with a text box, a check box, a button.
Button pops up a message box saying "You pushed the button".
One section that just does a DetailPrint "Contents of text box: " and whatever you typed into the box, and "The check box [was | was not] checked." with whether it was checked or not.
Thanks...
sab0tage, add an OnClick handler to your browse button and call SelectFileDialog to get the user's selection. Then put the result in the text box.
System::Call user32::GetWindowText(i$TEXT_HWND,t.r0,i${NSIS_MAX_STRLEN})
nsDialogs::SelectFileDialog /NOUNLOAD save $0 "All Files|*.*"
Pop $0
${If} $0 != ""
SendMessage $TEXT_HWND ${WM_SETTEXT} 0 STR:$0
${EndIf}jeffadams78, there are examples in Examples\nsDialogs. From there on, it's trial and error for now.
Duh, nevermind... just found the examples installed under /NSIS/Examples/nsDialogs if you install the new version of NSIS.
Originally posted by jeffadams78
Can someone throw together a quick example?
Heh, and it would appear I failed to refresh the page before posting. Thanks anyway though!
Originally posted by kichik
jeffadams78, there are examples in Examples\nsDialogs. From there on, it's trial and error for now.
Thanks kichik, I will give that a go.
I've put together the following macros, I'm pretty new with trying to put these together but they work for me.
It might be of some use to somebody.
I've put together the following macros, I'm pretty new with trying to put these together but they work for me.
I'm not sure if I need to push $R0 in the macro or pop it after it's called, but it works...
!macro _NSD_ENABLE NAME TOGGLE
SendMessage ${NAME} ${WM_ENABLE} ${TOGGLE} 0 $R0
Push $R0
!macroend
!define NSD_ENABLE `!insertmacro _NSD_ENABLE`
!macro _NSD_CHECKSTATE NAME
SendMessage ${NAME} ${BM_GETCHECK} 0 0 $R0
Push $R0
!macroend
!define NSD_CHECKSTATE `!insertmacro _NSD_CHECKSTATE`
${NSD_CHECKSTATE} checks the value of the checkbox and the returned value is used to disable a textbox with ${NSD_ENABLE}.
Function CheckboxEvent
${NSD_CHECKSTATE} $CHECKBOX_ID
Pop $0
${NSD_ENABLE} $TEXTBOX_ID $0
FunctionEnd
It might be of some use to somebody.
Hmm, so the FileRequest function really isn't for use in new totally nsDialog-driven stuff, just for working with ini files?
jeffadams78, it's for everything including completely nsDialogs-driven dialogs.
How is ${NSD_CreateFileRequest} different from ${NSD_CreateText}?
OK I thought I had it figured out, but I don't, so I'm going to put back the question I asked before but then erased...
If I want to create a page with nsDialogs that looks like:
Label1: [TextBoxForAFilePath1] [BrowseButton1...]
Label2: [TextBoxForAFilePath2] [BrowseButton2...]
What is the easiest way to do it?
P.S. and is there a built-in macro that does what the "welcome" example does, where it tries to complete filenames/paths as you type them in? Or would I have to cut-n-paste all the code from that example?
If I want to create a page with nsDialogs that looks like:
Label1: [TextBoxForAFilePath1] [BrowseButton1...]
Label2: [TextBoxForAFilePath2] [BrowseButton2...]
What is the easiest way to do it?
P.S. and is there a built-in macro that does what the "welcome" example does, where it tries to complete filenames/paths as you type them in? Or would I have to cut-n-paste all the code from that example?
I've chopped one of my scripts to bits for this example!
The file box is looking for a file named sdat1234.exe for instance (just create and rename a txt file to play).
As you can see the code is a bit messy, if anyone can recommend a script formatter that will make it nicer to read I would love to know!
Also if anyone can see where I improve on the code, I'd love to know that too, I'm quite new with NSIS.
The file box is looking for a file named sdat1234.exe for instance (just create and rename a txt file to play).
As you can see the code is a bit messy, if anyone can recommend a script formatter that will make it nicer to read I would love to know!
Also if anyone can see where I improve on the code, I'd love to know that too, I'm quite new with NSIS.
!include "MUI.nsh"
!include nsDialogs.nsh
!include LogicLib.nsh
!include winmessages.nsh
!insertmacro MUI_LANGUAGE English
Name "test"
OutFile "guitest.exe"
XPStyle on
Page custom SettingsPage
!insertmacro MUI_PAGE_INSTFILES
Var INST_SDAT
Var INST_SDAT_LOC
VAR TEXT_SDAT_LOC
Var INST_SDAT_BTN
VAR NEXT_BUTTON
!macro _NSD_ENABLE NAME TOGGLE
SendMessage ${NAME} ${WM_ENABLE} ${TOGGLE} 0 $R0
Push $R0
!macroend
!define NSD_ENABLE `!insertmacro _NSD_ENABLE`
!macro _NSD_CHECKSTATE NAME
SendMessage ${NAME} ${BM_GETCHECK} 0 0 $R0
Push $R0
!macroend
!define NSD_CHECKSTATE `!insertmacro _NSD_CHECKSTATE`
Function SettingsPage
GetDlgItem $NEXT_BUTTON $HWNDPARENT 1
nsDialogs::Create /NOUNLOAD 1018
Pop $0
${NSD_CreateCheckbox} 20 170 90 8u "Install SDAT"
Pop $INST_SDAT
GetFunctionAddress $0 OnSDAT
nsDialogs::OnClick /NOUNLOAD $INST_SDAT $0
${NSD_CreateBrowseButton} 410 170 25 12u ...
Pop $INST_SDAT_BTN
nsDialogs::SetUserData /NOUNLOAD $INST_SDAT_BTN FileRequest # remember field id
GetFunctionAddress $0 SDATFileBrowseButton
nsDialogs::OnClick /NOUNLOAD $INST_SDAT_BTN $0
${NSD_CreateFileRequest} 110 170 300 12u ""
Pop $INST_SDAT_LOC
${NSD_ENABLE} $INST_SDAT_LOC 0
GetFunctionAddress $0 ValidateNext
nsDialogs::OnChange /NOUNLOAD $INST_SDAT_LOC $0
nsDialogs::Show
FunctionEnd
Function SDATFileBrowseButton
${NSD_CHECKSTATE} $INST_SDAT
Pop $0
${If} $0 == 1
System::Call user32::GetWindowText(i$INST_SDAT_LOC,t.r1,i${NSIS_MAX_STRLEN})
nsDialogs::SelectFileDialog /NOUNLOAD open $2 "sdatXXXX.exe|sdat*.exe"
Pop $2
${If} $2 == $INST_SDAT_BTN
${OrIf} $2 == ""
SendMessage $INST_SDAT_LOC ${WM_SETTEXT} 0 STR:$1
${Else}
SendMessage $INST_SDAT_LOC ${WM_SETTEXT} 0 STR:$2
${EndIf}
${EndIF}
FunctionEnd
Function ValidateNext
System::Call user32::GetWindowText(i$INST_SDAT_LOC,t.R0,i${NSIS_MAX_STRLEN})
StrCpy $TEXT_SDAT_LOC $R0
GetDlgItem $NEXT_BUTTON $HWNDPARENT 1
${NSD_CHECKSTATE} $INST_SDAT
Pop $R1
EnableWindow $NEXT_BUTTON 1
${If} $R0 == 1
${If} $R1 == 1
${AndUnless} ${FileExists} $TEXT_SDAT_LOC
EnableWindow $NEXT_BUTTON 0
${EndIf}
${EndIf}
FunctionEnd
Function OnSDAT
${NSD_CHECKSTATE} $INST_SDAT
Pop $0
${NSD_ENABLE} $INST_SDAT_LOC $0
${NSD_ENABLE} $INST_SDAT_BTN $0
Call ValidateNext
FunctionEnd
Section
SectionEnd
jeffadams78, you must also create a browse button for a file request field. Use ${NSD_CreateBrowseButton}. Underneath it all, FileRequest is actually a Text field and BrowseButton is a actually Button field, so you can also use those if it makes it clearer.
There's no built in macro for SHAutoComplete, you have to call it yourself.
sab0tage, you shouldn't use WM_ENABLE. Use EnableWindow instead. The message is just a notification message and as you can see, doesn't really work for the button.
There's no built in macro for SHAutoComplete, you have to call it yourself.
sab0tage, you shouldn't use WM_ENABLE. Use EnableWindow instead. The message is just a notification message and as you can see, doesn't really work for the button.
I'd like to trigger a callback function when my TextBox receives focus. I've found it's the EN_SETFOCUS notification message, but I don't know how to make nsDialogs recognize it. Is it supported yet?
If not, is there another way to do it? Basically I have a text box with some initial text in it, and I want the box to go blank the first time a user clicks into it.
If not, is there another way to do it? Basically I have a text box with some initial text in it, and I want the box to go blank the first time a user clicks into it.
That's not possible yet. Please submit a feature request.
Sure thing. Where/how should I submit a feature request?
couldn't find anything in the docs or this forum.. will there be a droplist substitute?