Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 3rd May 2011, 05:19   #1
nsichildnew
Junior Member
 
Join Date: Apr 2011
Posts: 6
button event plugin not working for more than one button in mui nsis

In GetButtonID function, when more than one button event handler is given ,then it autoexits before showing the Directory MUI page dialog.
But, when only one button event handler is given , then the Directory page is displayed without any problems.

!include "MUI2.nsh"

!define IDC_BUTTON_CDRIVEPATH 1200
!define IDC_BUTTON_DDRIVEPATH 1201

;---------------------------------------
;Name and file
Name Remove_ERROR
OutFile solve_error.exe
; -------------------------------

!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\setup.ico" ;
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\pksicon.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP"${NSISDIR}\Contrib\Graphics\Wizard\img.bmp"
!define MUI_ABORTWARNING

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\licensefile.txt"

!define MUI_PAGE_CUSTOMFUNCTION_SHOW GetButtonID ;---in this function only one button event handler works, if two handlers are given , then installer crashes
!insertmacro MUI_PAGE_DIRECTORY

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; --------------------------------------------------
; Languages.

!insertmacro MUI_LANGUAGE English


# Called when the CDRIVEPATH button is pressed.
Function CDRIVEPATH

MessageBox MB_OK|MB_ICONEXCLAMATION "The Software will be installed in : C Drive"

FunctionEnd

Function DDRIVEPATH

MessageBox MB_OK|MB_ICONEXCLAMATION "The Software will be installed in : D Drive"

FunctionEnd
;--------------------------------

Function GetButtonID
# Create event handler for inner window button.

GetFunctionAddress $R2 CDRIVEPATH
ButtonEvent::AddEventHandler ${IDC_BUTTON_CDRIVEPATH} $R2

;when this second button handler is given ,then installer autoexits as soon as it has to show the Directory MUI Page dialog:

GetFunctionAddress $R3 DDRIVEPATH
ButtonEvent::AddEventHandler ${IDC_BUTTON_DDRIVEPATH} $R3

FunctionEnd

;------------------------------------------------------------------
Section "INSTALL MAIN SOFTWARE"

SetOutPath $INSTDIR

File /r "myfolder\*.*"

SectionEnd
;------------------------------------------------------------------
nsichildnew is offline   Reply With Quote
Old 3rd May 2011, 05:57   #2
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 555
Send a message via ICQ to T.Slappy
I tried ButtonEvent plugin with two buttons on the same page and it works perfectly

Cool looking installers with custom design: www.graphical-installer.com
Create Setup Pages easily: www.install-designer.com
Build installers in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.4 Sydney: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 3rd May 2011, 06:05   #3
nsichildnew
Junior Member
 
Join Date: Apr 2011
Posts: 6
Quote:
Originally Posted by T.Slappy View Post
I tried ButtonEvent plugin with two buttons on the same page and it works perfectly
can you please tell me the code, i am adding the screenshot of the Directory MUI Dialog here: i think i have added it on outer or inner dialog am not sure? please help
nsichildnew is offline   Reply With Quote
Old 3rd May 2011, 06:27   #4
nsichildnew
Junior Member
 
Join Date: Apr 2011
Posts: 6
sir, can you please tell me the error in my code? its not working, when i press the I AGREE button on License page, then the installer exits, but when i remove the handler of the second button from the GETBUTTONID function, then it works properly.
nsichildnew is offline   Reply With Quote
Old 3rd May 2011, 13:11   #5
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 555
Send a message via ICQ to T.Slappy
Strange, your code is not working.
Plugin crashes on second ButtonEvent::AddEventHandler.
There is probably bug in the plugin - I will ask Afrow.

In my Graphical Installer I used exactly this code:
PHP Code:
# Show Print button
!ifdef GRAPHICAL_INSTALLER_PRINT_LICENSE
  FindWindow 
$"#32770" "" $HWNDPARENT
  GetDlgItem 
$0 $HWNDPARENT 2895
  SendMessage 
$${WM_SETTEXT"STR:$(GraphicalInstallerButtonPrint)" 0
  ShowWindow 
$${SW_SHOW}

  
# Prepare function for printing license
  
GetFunctionAddress $R0 PrintLicenseFile
  ButtonEvent
::AddEventHandler 2895 $R0
!endif

# Show Save button
!ifdef GRAPHICAL_INSTALLER_SAVE_LICENSE
  FindWindow 
$"#32770" "" $HWNDPARENT
  GetDlgItem 
$0 $HWNDPARENT 2896
  SendMessage 
$${WM_SETTEXT"STR:$(GraphicalInstallerButtonSave)" 0
  ShowWindow 
$${SW_SHOW}

  
# Prepare function for saving license
  
GetFunctionAddress $R0 SaveLicenseFile
  ButtonEvent
::AddEventHandler 2896 $R0
!endif 
and everything was fine - both buttons worked at the same time.
One button was for printing license and second for saving license to hard disk - both on the same page License.

Cool looking installers with custom design: www.graphical-installer.com
Create Setup Pages easily: www.install-designer.com
Build installers in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.4 Sydney: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 3rd May 2011, 13:23   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Are you using Unicode NSIS or not? Be sure not to mix the plug-ins either.

Stu
Afrow UK is offline   Reply With Quote
Old 4th May 2011, 05:31   #7
nsichildnew
Junior Member
 
Join Date: Apr 2011
Posts: 6
sir, how do i come to know whether am using Unicode NSIS or not? please help
nsichildnew is offline   Reply With Quote
Old 4th May 2011, 07:32   #8
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
If you downloaded NSIS from the NSIS website, then you have ANSI (non-Unicode) NSIS. The Unicode version is a special build. If you didn't explicitly look for it, you probably don't have it.
MSG is offline   Reply With Quote
Old 4th May 2011, 07:57   #9
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 555
Send a message via ICQ to T.Slappy
I am sure about this, it some king of bug.
I have non-Unicode version of NSIS and non-Unicode plugin and installers crashes.
But it crashes only in nsichildnew's script! - in my script (in reply #5) two buttons are working correctly!
So I assume that plugin is OK, but some other thing (maybe incorrect order of some lines in script, etc) prevents it from working correctly.

There is no time for me to debug it, but If you have some time try to debug script above by yourself.

Cool looking installers with custom design: www.graphical-installer.com
Create Setup Pages easily: www.install-designer.com
Build installers in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.4 Sydney: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 4th May 2011, 08:45   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I'll look into this bug later today.

Stu
Afrow UK is offline   Reply With Quote
Old 4th May 2011, 10:32   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Crash fixed, thanks.

http://nsis.sourceforge.net/File:ButtonEvent.zip

Stu
Afrow UK is offline   Reply With Quote
Old 24th November 2011, 07:57   #12
T.Slappy
Major Dude
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 555
Send a message via ICQ to T.Slappy
Stu, could you add event for other controls to your plug-in?
E.g.: I added Label [Static text] in UI.exe and I would like to attach onClick event to it.
Is is possible?

Cool looking installers with custom design: www.graphical-installer.com
Create Setup Pages easily: www.install-designer.com
Build installers in Visual Studio 2005-2019: www.visual-installer.com
or RAD Studio 2009, 2010, XE-10.4 Sydney: www.rad-installer.com
T.Slappy is offline   Reply With Quote
Old 24th November 2011, 10:09   #13
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Sure it's possible but I would probably create a new plug-in that provides multiple event handlers. I will work on it when I have some free time.

Stu
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
mui nsis button plugin

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump