Skip to content
⌘ NSIS Forum Archive

Shadow effect

6 posts

Anders#
Top level window or child control?

The shadow on top level windows should be controlled by Windows.
Kuppy#
Only the edges of the window
I have an example but the shadow effect is only right and I would like if possible to all four sides.
Anders#
You can force the class style of the window to have the shadow style but I would not recommend doing it and you cannot control which edges the shadow is on nor the size of it.
Kuppy#
Name "Test Shadow"
OutFile "Test_Shadow_setup.exe"
InstallDir "$TEMP\Test Shadow"
!include "MUI.nsh"
!include "WinCore.nsh"
!include "nsDialogs.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"
SetCompressor lzma
RequestExecutionLevel user
ShowInstDetails show
ShowUninstDetails show
BrandingText /TRIMRIGHT " "
!define MUI_CUSTOMFUNCTION_GUIINIT "onGuiInit"
Page custom "nsDialogsPage" "" 
Page instfiles 
!insertmacro MUI_LANGUAGE "ENGLISH"
Var DROPSHADOW
!ifndef SPI_GETDROPSHADOW
!define SPI_GETDROPSHADOW   0x1024
!endif
!ifndef SPI_SETDROPSHADOW
!define SPI_SETDROPSHADOW   0x1025
!endif
Function ".onInit"
  System::Call "user32::SystemParametersInfo(i${SPI_GETDROPSHADOW},i0,*i.s,i0)"
  Pop $DROPSHADOW
  System::Call "user32::SystemParametersInfo(i${SPI_SETDROPSHADOW},i0,i1,i0)"
  System::Call "user32::SystemParametersInfo(i${SPI_SETDROPSHADOW},i0,i1,i0)"
FunctionEnd
Function onGuiInit
  System::Call 'user32::GetClassLong(i,i) i ($HWNDPARENT,-26) .s'
  Pop $R0
  System::Call 'user32::SetClassLong(i,i,i) i ($HWNDPARENT,-26,$R0|0x20000) .s'
  Pop $R0
FunctionEnd
var Welcome 
Function nsDialogsPage 
    nsDialogs::Create 1018 
    Pop $0 
    ${If} $0 == error 
        Abort 
    ${EndIf} 
    ${NSD_CreateLabel} 90u 60u 93% 25u "WELCOME!" 
    Pop $Welcome 
    CreateFont $0 "Calibri Light" "20" "800"
    SendMessage $Welcome  ${WM_SETFONT} $0 0 
    nsDialogs::Show 
FunctionEnd  
Section "" Main
SectionEnd
Function ".onGUIEnd"
  System::Call "user32::SystemParametersInfo(i${SPI_SETDROPSHADOW},i0,i$DROPSHADOW,i0)"
FunctionEnd 
Anders#
And this is a good example of what not to do. The user might have turned the shadow off for a reason and this code ignores that and forces the shadow on system wide!

Now think about what happens if you run another instance of this program or another program that does the same thing. You will mess up the users settings if you are unlucky with the timing! Or what if another program wants to turn it off? Shadow fight?

You should not use SPI_SET* unless you are some type of control panel applet!