Skip to content
⌘ NSIS Forum Archive

Hide a dialog window (N00b Question)

7 posts

inmytime3021#

Hide a dialog window (N00b Question)

(I am new to NSIS so do pardon me.)

I simply want to hide a dialog window. I found several topics discussing in a round-about way, but nothing that directly/simply showed how to do this. In particular, I'm trying to hide the Finish dialog window inside .onInstSuccess.

This is what I tried:

Function .onInstSuccess
;FindWindow $0 $HWNDPARENT
;FindWindow $0 "" "${PRODUCT_NAME} ${PRODUCT_VERSION} Setup" 0 0
;HideWindow

FindWindow $0 '#32770'
;FindWindow $0 '#32770' '' 0 $0

ShowWindow $0 ${SW_HIDE}
;ShowWindow $MUI_HWND ${SW_HIDE}
FunctionEnd

I cannot get any of these methods to work. Am I doing my ShowWindow line wrong?

Thanks,

Timex
kichik#
HideWindow hides the installer. But if you don't want the finish page, simply don't use the finish page. Remove its macro insertion.
inmytime3021#
kichik,

Thanks for your help (again) :P.

Well, I want to show the finish dialog.

I'm running my SQL script once they click finish, and while it runs, I'm using the NotifyIcon plugin to show a balloon in the task bar while the script runs. Then when complete, I show success or failure in my NotifyIcon.

However, I discovered that if I call NotifyIcon (or anything else GUI-related), that my NotifyIcon doesn't stay in the task bar when the mouse hovers over - the only thing keeping it open is the baloon message. SO, I moved my code up to .onInstSuccess to fix that. I thus want to hide the dialog while it continues to run, keeping my NotfyIcon in the task bar. Then I tear it down after it completes. I thought it was going to be a slick'n'quick solution, arg!

WHY doesn't this work?

FindWindow $0 '#32770' '' 0 $0
ShowWindow $0 ${SW_HIDE}


-Timex
kichik#
That last piece of code doesn't work because you're trying to hide the internal dialog and not the whole dialog. Just use HideWindow which does all that for you.
inmytime3021#
kichik,

Yeah, that's what I thought. I tried it earlier and didn't seem to work (so I thought) so I moved on to others things. However, when I simplified my code down and tried it again as you suggested, it DOES work. But for some reason, the window paints again once I call NotifyIcon and launch my script. I'm guessing NotfiyIcon is causing it. For example:


Function .onInstSuccess
HideWindow

;...build my script from input of my custom dialog

;show our 'job starting' balloon
NotifyIcon::Icon /NOUNLOAD "fy" "${NSISDIR}\Contrib\Graphics\Icons\modern-install-colorful.ico"

;now run the script
${LogAction} $CommandLine
nsExec::ExecToStack $CommandLine

Pop $0 # return value/error/timeout
Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}

${If} $0 != 0
;show our job failure balloon
NotifyIcon::Icon /NOUNLOAD ".fb" "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" "TraCS Data Warehouse Installer" "Warehouse job failed!"
Sleep 4000
${Else}
;Use login method used by installer and read results from our job table(s)
${If} $IsSQLLogon == '1'
StrCpy $CommandLine 'sqlcmd -Q $\"SELECT BatchType AS Type, BatchTimeLapse AS [Time Taken], BatchAffectedRows AS [Affected Rows] FROM dbo.BatchStatus;$\" \
-d $\"$DatabaseName$\" \
-b -r 0 -V 11 \
-S $\"$ServerName$\" \
-U $\"$UserName$\" \
-P $\"$Password$\" -Y 13'
${Else}
StrCpy $CommandLine 'sqlcmd -Q $\"SELECT BatchType AS Type, BatchTimeLapse AS [Time Taken], BatchAffectedRows AS [Affected Rows] FROM dbo.BatchStatus;$\" \
-d $\"$DatabaseName$\" \
-b -r 0 -V 11 \
-S $\"$ServerName$\" -Y 13'
${EndIf}

${LogAction} $CommandLine
nsExec::ExecToStack $CommandLine
Pop $R0 # return value/error/timeout
Pop $R1 # printed text, up to ${NSIS_MAX_STRLEN}

;display our initial success balloon
NotifyIcon::Icon /NOUNLOAD ".fb" "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" "TraCS Data Warehouse Installer" "Warehouse job finished successfully!"
Sleep 8000 ;sleep, for testing only

;now show our job results as gotten from out table (formatted)
NotifyIcon::Icon /NOUNLOAD ".fb" "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" "TraCS Data Warehouse Installer" $R1
Sleep 8000
${EndIf}

;now we tell NotifyIcon to destroy our balloon; we're done.
NotifyIcon::Icon "r"

end:
FunctionEnd
Sorry about the formatting and length. But I am finding that I should post or show the full logic in order for my scenario to make sense. So here it is.

-Timex
kichik#
You can attach script files to avoid formatting issues.

This problem can be solved just like the other one. Create another installer, make it silent, make it use whatever pop-ups it needs and execute it from the main installer. This way, you'll have no dialogs to handle.
inmytime3021#
Thanks for the suggestion. I just might give in! I just can't seem to get it to work the way I want here otherwise. The thing is, I KNOW there is a way to do it given all the nifty abilities of NSIS (and contributions). I think it has something to do with the /NOUNLOAD with the NotfiyIcon plugin, or how it interacts with the dialog.

Anyway, I think I'm just gonna write a quick bootstrap exe to do what I want: Then I have ultimate control. I'll leave NSIS to do what it does best: install stuff.

Thanks for the reminder, kichik. Your idea of splitting it off is gonna be the best approach.

Cheers!

-Timex