Archive: AnimGif HWNDPARENT switch blocks License Page


AnimGif HWNDPARENT switch blocks License Page
The sample script below displays an animated gif in the page dialogs respectively using animgif plugin .I'm using UMUI. The welcome page displays the gif properly whilst in the license agreement page ,it just flickers.I wanted to show the same animation on the left hand side of this license page . The problem happens since I'm using the /HWND switch to the animgif plugin in the showLicense function and passing the $HWNDPARENT . This causes the following behavior , clicking on Next in the license page doesn't take anywhere and on the second click only it moves to the next page . If I remove /HWND switch Next button works .
Please help



;NSIS Ultra Modern User Interface
;Background Image Example Script
;Written by SuperPat

;--------------------------------
;General

;Name and file
Name "******odernUI Test"
OutFile "PageBG.exe"

;Default installation folder
InstallDir "$LOCALAPPDATA\******odernUI Test"

;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\******odernUI Test" ""

;Request application privileges for Windows Vista
RequestExecutionLevel user

;--------------------------------
;Include ******odernUI

!include "UMUI.nsh"


;--------------------------------
;Interface Settings

; A unique background image
!define UMUI_UNIQUEBGIMAGE
!define UMUI_UNUNIQUEBGIMAGE

!define UMUI_PAGEBGIMAGE
!define UMUI_UNPAGEBGIMAGE
!define UMUI_PAGEBGIMAGE_BMP "${NSISDIR}\Contrib\******odernUI\Skins\blue\PageBG.bmp"


!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING

!define UMUI_USE_ALTERNATE_PAGE
!define UMUI_USE_UNALTERNATE_PAGE

!define MUI_LICENSEPAGE_RADIOBUTTONS
;--------------------------------
;Pages
!define MUI_PAGE_CUSTOMFUNCTION_SHOW showWelcome
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveWelcome
!insertmacro MUI_PAGE_WELCOME
!define MUI_PAGE_CUSTOMFUNCTION_SHOW showLicense
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveLicense
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\******odernUI\License.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY


Var STARTMENU_FOLDER
!insertmacro UMUI_PAGE_ALTERNATIVESTARTMENU Application $STARTMENU_FOLDER

!insertmacro UMUI_PAGE_CONFIRM

!insertmacro MUI_PAGE_INSTFILES


; !define MUI_FINISHPAGE_RUN "blabla.exe"
; !define MUI_FINISHPAGE_RUN_TEXT "run blabla"
!define MUI_FINISHPAGE_SHOWREADME "blabla.htm"
!define MUI_FINISHPAGE_SHOWREADME_TEXT "blabla readme"
!define MUI_FINISHPAGE_LINK "******odernUI Home Page"
!define MUI_FINISHPAGE_LINK_LOCATION "http://******odernui.sourceforge.net/"
!insertmacro MUI_PAGE_FINISH

!define UMUI_ABORTPAGE_LINK "******odernUI Home Page"
!define UMUI_ABORTPAGE_LINK_LOCATION "http://******odernui.sourceforge.net/"
!insertmacro UMUI_PAGE_ABORT


!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

!define MUI_FINISHPAGE_LINK "******odernUI Home Page"
!define MUI_FINISHPAGE_LINK_LOCATION "http://******odernui.sourceforge.net/"
!insertmacro MUI_UNPAGE_FINISH

!define UMUI_ABORTPAGE_LINK "******odernUI Home Page"
!define UMUI_ABORTPAGE_LINK_LOCATION "http://******odernui.sourceforge.net/"
!insertmacro UMUI_UNPAGE_ABORT

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "Dummy Section" SecDummy

SetOutPath "$INSTDIR"

;ADD YOUR OWN FILES HERE...

;Store installation folder
WriteRegStr HKCU "Software\******odernUI Test" "" $INSTDIR

;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"

SectionEnd

;--------------------------------
;Descriptions

;Language strings
LangString DESC_SecDummy ${LANG_ENGLISH} "A test section."

;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------
;Uninstaller Section

Section "Uninstall"

;ADD YOUR OWN FILES HERE...

Delete "$INSTDIR\Uninstall.exe"

RMDir "$INSTDIR"

DeleteRegKey /ifempty HKCU "Software\******odernUI Test"

SectionEnd
Function showWelcome

; for Back button - dll reset
AnimGif::stop
; left logo on the Welcome page
AnimGif::play /NOUNLOAD /HALIGN=RIGHT /VALIGN=TOP "$EXEDIR\tweety.gif"

FunctionEnd

Function leaveWelcome
AnimGif::stop
FunctionEnd

Function showLicense
; for Back button - dll reset
AnimGif::stop
; left logo on the Welcome page
AnimGif::play /NOUNLOAD /HWND=$HWNDPARENT /HALIGN=LEFT /VALIGN=TOP "$EXEDIR\tweety.gif"

FunctionEnd

Function leaveLicense
AnimGif::stop
FunctionEnd


Can anybody help ? If i don't pass /HWND=$HWNDPARENT to the AnimGif plugin , I'm able to navigate to the next dialog .If I do pass , I need to press Next Button twice to navigate to next page.


Is this a UMUI issue only? If no, can you prepare minimum size script reproducing the situation on MUI/MUI2?


Takhir,
Thanks for replying.
It isn't an UMUI issue only. The reason why I want to pass $HWNDPARENT to /HWND switch is because I need to show the animation on extreme left corner of the dialog.The default only points to child window.

Here is a sample script that uses MUI2. To demonstrate , please have any two gif files "WelcomeAnimate.gif" and "Banner.gif" in the current NSI file location.Now compile and run the installer . In component page Next button press , it takes you to the same component page.Again press Next , now it moves into directory page .
This is a flaw since I'm having /HWND=$HWNDPARENT in the "showComponents" function. Now remove the /HWND switch in the same function, recompile and run , the navigation works as expected .This is applicable to any page . not just License Page as I mentioned earlier in my post.



!include "MUI2.nsh"
Name "AnimaionTest"
OutFile "Animation.exe"
InstallDir "$LOCALAPPDATA\AnimationTest"
RequestExecutionLevel user
!define MUI_ABORTWARNING
!define MUI_PAGE_CUSTOMFUNCTION_SHOW showLicense
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveLicense
!insertmacro MUI_PAGE_LICSENSE "{NSISDIR}\Docs\Modern UI\License.txt"
!define MUI_PAGECUSTOMFUNCTION_SHOW showComponents
!define MUI_PAGECUSTOMFUNCTION_LEAVE leaveComponents
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

Section "Dummy" Dummy
SetOutPath "$INSTDIR"
SectionEnd

Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\WelcomeAnimate.gif WelcomeAnimate.gif
File /oname=$PLUGINSDIR\Banner.gif Banner.gif
FunctionEnd

Function un.onInit
FunctionEnd

Function showComponents
AnimGif::play /NOUNLOAD /HWND=$HWNDPARENT /VALIGN=CENTER /HALIGN=RIGHT "$PLUGINSDIR\WelcomeAnimate.gif"
FunctionEnd

Function leaveComponents
AnimGif::stop
FunctionEnd

Function showLicense
AnimGif::play /NOUNLOAD /VALIGN=TOP /HALIGN=CENTER "$PLUGINSDIR\Banner.gif"
FunctionEnd

Function leaveLicense
AnimGif::stop
FunctionEnd


First of all about flickering - you cannot draw image on the window part which is already occupied by other 'child' window (and it covers parent), this case you should draw on the 'child' window.

Function showComponents
AnimGif::play /NOUNLOAD /HWND=$HWNDPARENT /VALIGN=CENTER /HALIGN=RIGHT "$PLUGINSDIR\sonic.gif"
FunctionEnd

As you can see on the attached image central part of NSIS dialog is another dialog with controls which are child relative to this dialog. Another words - you can use animated gifs on the free part of top level 'child'. By default target is a child dialog (Spy++ shows it's border on attached image). Clear understanding of windows hierarchy required :).
I could not reproduce 'Next' problem with your script (with few fixes like MUI_PAGECUSTOMFUNCTION_SHOW and MUI_PAGE_LICSENSE wording), but I remember that I had such situation long ago... You can try to use SetFocus to the Next button if problem will not be resolved with correct target windows (see AnimGif and AnimGifPe included samples).

Sorry for the typo.

Here is the corrected script. Never mind about the flickering since I will be using UMUI large dialog, which has enough space around the child dialog.To reproduce I have it simulated in the following MUI code . I still face issue with the Next button, it needs to be pressed twice .



!include "MUI2.nsh"
Name "AnimaionTest"
OutFile "Animation.exe"
InstallDir "$LOCALAPPDATA\AnimationTest"
RequestExecutionLevel user
!define MUI_ABORTWARNING
!define MUI_PAGE_CUSTOMFUNCTION_SHOW showLicense
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveLicense
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW showComponents
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveComponents
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

Section "Dummy" Dummy
SetOutPath "$INSTDIR"
SectionEnd

Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\tweety.gif tweety.gif
FunctionEnd

Function un.onInit
FunctionEnd

Function showComponents
AnimGif::play /NOUNLOAD /HWND=$HWNDPARENT /VALIGN=CENTER /HALIGN=RIGHT "$PLUGINSDIR\tweety.gif"
FunctionEnd

Function leaveComponents
AnimGif::stop
FunctionEnd

Function showLicense
AnimGif::play /NOUNLOAD /HWND=$HWNDPARENT /VALIGN=TOP /HALIGN=RIGHT "$PLUGINSDIR\tweety.gif"

FunctionEnd

Function leaveLicense
AnimGif::stop
FunctionEnd


Thanks, Alfaromeo, with your last script I could reproduce and understand :) situation. Catched main dlg messages should be re-send for correct click handling. Please test attached dll.


Takhir,

Excellent that fixes it.
Can we also have some switches like /LEFT /BOTTOM , wherein I can specify the co-ordinates for positioning the animation.With the existing positioning switches , I cannot fine tune the position coordinates . With the one I mentioned I could possibly pass any integer values to specify the position.


I had a free minute and updated wiki' plug-in sources and binaries: $HWNDPARENT buttons click fix. Positioning in percents of width/height now. Unicode version added.


Takhir,

You are the dude. Thanks ,please consider this solved.