;NSIS ModelessBanner Test
;Written by Takhir Bedertdinov

;--------------------------------
;common

  !define APP_NAME "ModelessBanner"
  !include "MUI.nsh"
  Name "${APP_NAME}"
  OutFile "${APP_NAME}.exe"
  InstallDir "$PROGRAMFILES\${APP_NAME}"

;--------------------------------
;Pages

  !insertmacro MUI_PAGE_WELCOME
  !define MUI_PAGE_CUSTOMFUNCTION_PRE changeImage
  !insertmacro MUI_PAGE_DIRECTORY
  !insertmacro MUI_PAGE_INSTFILES
  
;--------------------------------
;Interface Settings

  !define MUI_ABORTWARNING
  
;--------------------------------
;Languages
 
  !insertmacro MUI_LANGUAGE "English"

  Var hwin
  Var hmci
;--------------------------------
;Installer Sections

Section "Dummy Section" SecDummy

  SendMessage $hwin 0x0010 0 0
  SendMessage $hmci 0x0010 0 0

SectionEnd

!define IMG1_NAME "tango1.bmp"
!define IMG2_NAME "tango2.bmp"
!define SND_NAME "09.mp3"

;--------------------------------
;Installer Functions

Function changeImage

  System::Call 'user32.dll::LoadImage(i r0, t "${IMG2_NAME}", i 0, i 0, i 0, i 0x0010) i .r1'
  SendMessage $2 0x0172 0 $1
  System::Call 'user32.dll::UpdateWindow(i r2) i .r3'
  StrCpy $hwin $2

FunctionEnd

Function .onInit

  InitPluginsDir
  SetOutPath $PLUGINSDIR
  File "${IMG1_NAME}"
  File "${IMG2_NAME}"
  File "${SND_NAME}"

; mci sound
  System::Call 'msvfw32.dll::MCIWndCreate(i 0, i 0,i 0x0070, t "$PLUGINSDIR\${SND_NAME}") i .r0'
  System::Call 'user32.dll::ShowWindow(i r0, i 0)' ; hide window
  SendMessage $0 0x0465 0 "STR:play repeat"
  StrCpy $hmci $0

; static topmost window with bmp image
  System::Call 'kernel32::GetModuleHandle(i 0) i .r0'
  System::Call 'user32.dll::CreateWindowEx(i 8, t "STATIC", t "", i 0x8000000E, i 50, i 50, i 200, i 200, i 0, i 0, i r0, i 0) i .r2'
  System::Call 'user32.dll::LoadImage(i r0, t "${IMG1_NAME}", i 0, i 0, i 0, i 0x0010) i .r1'
  SendMessage $2 0x0172 0 $1
  System::Call 'user32.dll::ShowWindow(i r2, i 1) i .r3'
  System::Call 'user32.dll::UpdateWindow(i r2) i .r3'
  StrCpy $hwin $2

FunctionEnd


;--------------------------------
;Descriptions

