Archive: Make installer topmost window.


Make installer topmost window.
The 'powers at be' asked that we make the installer a topmost window (in windows one would use the API) :

SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE

This keeps the application (the installer in this case) always on top of other windows (like TaskManager...) so it won't get lost. (I think marketing feels that users are loosing the installer for some reason...)

Search didn't really get me anything, so if anyone has suggestions...
;)


Use System plug-in.

Stu


Originally posted by Afrow UK
Use System plug-in.

Stu
Thanks Stu. For others later looking at this thread, here is the final result:


!include "${NSISDIR}\Examples\System\System.nsh"
# --- Define and make accessible the system plugin.
# before 2.07 !include "${NSISDIR}\Contrib\System\System.nsh"

# --- The function to force a window to be topmost.

Function WindowToTop
;Save existing register values to the stack
Push $0
Push $1
Push $2
Push $3
Push $4
Push $5
Push $6
Push $7

; HWND_TOPMOST not defined in the system plugin, so we define it here instead.
!define HWND_TOPMOST -1

; SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE) 'These two lines bring the window

System::Call "User32::SetWindowPos(i, i, i, i, i, i, i) b ($HWNDPARENT, ${HWND_TOPMOST}, 0, 0, 0, 0, ${SWP_NOMOVE}|${SWP_NOSIZE})"

;Restore register values from the stack
Pop $7
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd



The WindowToTop function then can be called from within the NSIS script as needed.

you don't have to save the registers if you are not using any of them ;)


Good point... (Teach me to cut-n-paste!)