Archive: custom page with additional button


custom page with additional button
Hi all,

I want to make a custom page with additional button, next to the next button which will go do something and then will invoke next.

this is what I tried:



nsDialogs::create /NOUNLOAD 1018
pop $Dialog
${If} $Dialog == error
Abort
${EndIf}

;hide back
GetDlgItem $0 $HWNDPARENT 3
ShowWindow $0 ${SW_HIDE}

;add the another button
GetDlgItem $0 $HWNDPARENT 4 ;I added this button with resource hacker
ShowWindow $0 ${SW_SHOW}
EnableWindow $0 1
SendMessage $0 ${WM_SETTEXT} 1 "STR:$(BUTTON_TEXT)"
getFunctionAddress $1 doSomething
nsDialogs::onClick $0 $1

;show the dialog
nsDialogs::Show

...


Function doSomething
messagebox MB_OK "did something, going next!"
SendMessage $HWNDPARENT "0x408" "1" ""
FunctionEnd




the button shows with the correct text, but nothing happens on click, I think this is because "nsDialogs::create /NOUNLOAD 1018" was called on 1018 and the button is not a child window on that window, how do I set the callback correctly?

Thanks,

J

Ok - problem solved, I found the ButtonEvent plugin which does exactly what I was looking for...

The "Afrow conjecture" still holds: "Every NSIS problem that you can think of, has already been solved by Afrow, with a nifty plugin. Most likely you will find that plugin right after you gave up looking for it and posted a question"


Originally posted by zenpoy
The "Afrow conjecture" still holds:
"Every NSIS problem that you can think of, has already been solved by Afrow, with a nifty plugin. Most likely you will find that plugin right after you gave up looking for it and posted a question"
This is really nice! :):):)

BTW - for some reason, if I have two custom pages both using the same button with ButtonEvent (it's actually the same page, with different content), the second one doesn't work, I debugged the code and it seems that the second time it doesn't change the ParentDlgProcOld :

ParentDlgProcOld = (DLGPROC)SetWindowLongPtr(hWndParent, DWLP_DLGPROC, (LONG)ParentDlgProc);


because it already been set on the first time but it's a different page now..

I removed the check for if ParentDlgProcOld already been set and recompiled. Although it works now, I don't think this is the right way to go. can anyone help me get the correct way to use this plugin?

If the button is on the outer window you should set up the event onGUIInit.

Stu


Thanks! I'll try that


hi, i have problem with button event plugin, i have following code:



!define MUI_CUSTOMFUNCTION_GUIINIT fckGUIInit

!define IDC_DECL 1300

Function fckGUIInit
System::Alloc 56
Pop $9
System::Call "*$9(i56)"
System::Call "user32::GetWindowInfo(i$HWNDPARENT,ir9)"
IntOp $R9 $9 + 20
System::Call "*$R9(i.R8,i.R7,i.R6,i.R4)"
System::Free $9
IntOp $R8 $R6 - $R8
!insertmacro GetDlgItemRect $R9 $R7 $R6 $R4 $HWNDPARENT 2
IntOp $R8 $R8 - $R6
IntOp $R6 $R6 - $R9
IntOp $R4 $R4 - $R7
System::Call 'kernel32::GetModuleHandle(i0)i.r9'
System::Call 'user32::CreateWindowEx(i0,t"Button",t"Decline",i${BS_PUSHBUTTON}|${WS_CHILD}|${WS_VISIBLE}|${WS_TABSTOP},iR8,iR7,iR6,iR4,i$HWNDPARENT,i${IDC_DECL},ir9,i0)i.R9'
StrCpy $button_decl $R9
System::Call 'kernel32::FreeLibrary(ir9)'
CreateFont $9 '$(^Font)' '$(^FontSize)'
SendMessage $button_decl ${WM_SETFONT} $9 0
GetFunctionAddress $9 FuncDecline
ButtonEvent::AddEventHandler /NoUnload ${IDC_DECL} $9
ShowWindow $button_decl ${SW_HIDE}
FunctionEnd

Function FuncDecline
MessageBox MB_OK "Decline working"
StrCpy $current_app_install "0"
StrCpy $R9 "1" ;Relative page number. See below.
Call RelGotoPage
FunctionEnd




in result i have error (look in attached screenshot)

i also can't use button handle for later show on page where it needed, "ShowWindow $button_decl ${SW_SHOW}" does nothing on custom page where decline should be shown, and pointed function does not called on button press also...

i also tried another method, call code whic is in guiinit function before custom pages block without adding eventhandler, and add event handler on required custom page(s), but as said above it worked for only on page, i also modified plugin similar, as said above (to always replace dlgproc to plugin own) and this worked, but it have random crashes on windows xp, so my question is:

How i can add decline button in left bottom corner with custom text and custom function which must be shown on few custom pages, i have completely dynamic custom pages which is generating in runtime.

If you look at the ButtonEvent examples, the custom buttons are already in the UI(s). I added them using Resource Hacker and applied the UI with the MUI_UI define. I would recommend the same approach.

Stu


thx for reply, it worked, i was away from my pc for sometime and unable to reply earlier