Example.nsi 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. Name "BgImage.dll test"
  2. OutFile "BgImage Test.exe"
  3. XPStyle on
  4. RequestExecutionLevel user
  5. !define DEBUG
  6. !macro GetReturnValue
  7. !ifdef DEBUG
  8. Pop $R9
  9. StrCmp $R9 success +2
  10. DetailPrint "Error: $R9"
  11. !endif
  12. !macroend
  13. Function .onGUIInit
  14. # the plugins dir is automatically deleted when the installer exits
  15. InitPluginsDir
  16. # lets extract some bitmaps...
  17. File /oname=$PLUGINSDIR\1.bmp "${NSISDIR}\Contrib\Graphics\Wizard\llama.bmp"
  18. File /oname=$PLUGINSDIR\2.bmp "${NSISDIR}\Contrib\Graphics\Checks\modern.bmp"
  19. !ifdef DEBUG
  20. # turn return values on if in debug mode
  21. BgImage::SetReturn on
  22. !endif
  23. # set the initial background for images to be drawn on
  24. # we will use a gradient from drak green to dark red
  25. BgImage::SetBg /GRADIENT 0 0x80 0 0x80 0 0
  26. !insertmacro GetReturnValue
  27. # add an image @ (150,0)
  28. BgImage::AddImage $PLUGINSDIR\2.bmp 150 0
  29. !insertmacro GetReturnValue
  30. # add the same image only transparent (magenta wiped) @ (150,16)
  31. BgImage::AddImage /TRANSPARENT 255 0 255 $PLUGINSDIR\2.bmp 150 16
  32. !insertmacro GetReturnValue
  33. # create the font for the following text
  34. CreateFont $R0 "Comic Sans MS" 50 700
  35. # add a blue shadow for the text
  36. BgImage::AddText "Testing 1... 2... 3..." $R0 0 0 255 48 48 798 198
  37. !insertmacro GetReturnValue
  38. # add a green shadow for the text
  39. BgImage::AddText "Testing 1... 2... 3..." $R0 0 255 0 52 52 802 202
  40. !insertmacro GetReturnValue
  41. # add the text
  42. BgImage::AddText "Testing 1... 2... 3..." $R0 255 0 0 50 50 800 200
  43. !insertmacro GetReturnValue
  44. # show our creation to the world!
  45. BgImage::Redraw
  46. # Refresh doesn't return any value
  47. FunctionEnd
  48. ShowInstDetails show
  49. Section
  50. # play some sounds
  51. FindFirst $0 $1 $WINDIR\Media\*.wav
  52. StrCmp $0 "" skipSound
  53. moreSounds:
  54. StrCmp $1 "" noMoreSounds
  55. BgImage::Sound /WAIT $WINDIR\Media\$1
  56. # Sound doesn't return any value either
  57. MessageBox MB_YESNO "Another sound?" IDNO noMoreSounds
  58. FindNext $0 $1
  59. Goto moreSounds
  60. noMoreSounds:
  61. FindClose $0
  62. skipSound:
  63. # change the background image to Mike, tiled
  64. BgImage::SetBg /TILED $PLUGINSDIR\1.bmp
  65. !insertmacro GetReturnValue
  66. # we have to redraw to reflect the changes
  67. BgImage::Redraw
  68. MessageBox MB_OK "Mike the llama"
  69. # clear everything
  70. BgImage::Clear
  71. # Clear doesn't return any value
  72. # set another gradient
  73. BgImage::SetBg /GRADIENT 0xFF 0xFA 0xBA 0xAA 0xA5 0x65
  74. !insertmacro GetReturnValue
  75. # add some text
  76. BgImage::AddText "A Desert for Mike" $R0 0 0 0 50 50 800 150
  77. !insertmacro GetReturnValue
  78. # add mike as an image
  79. BgImage::AddImage $PLUGINSDIR\1.bmp 50 150
  80. !insertmacro GetReturnValue
  81. # again, we have to call redraw to reflect changes
  82. BgImage::Redraw
  83. SectionEnd
  84. Function .onGUIEnd
  85. BgImage::Destroy
  86. # Destroy doesn't return any value
  87. FunctionEnd