Skip to content
⌘ NSIS Forum Archive

DlgProc plugin by gfm688 - Set call back functions for dialogs

3 posts

jiake#

DlgProc plugin by gfm688 - Set call back functions for dialogs

The member named gfm688 from the Chinese NSIS forum "Dreams8" writes a plugin.
It allows you to add callback funtions for dialogs in your script.

example code:
Function .onGUIInit
    GetFunctionAddress $0 onGUICallback
    DlgProc::onCallback $HWNDPARENT $0
FunctionEnd
Function onGUICallback
    ${If} $MUI.Msg = ${WM_COMMAND}
        ${If} $MUI.wParam = 1034
            MessageBox MB_OK|MB_ICONINFORMATION "This is the example of header link."
        ${EndIf}
    ${EndIf}
FunctionEnd 
It can be also used for custom control, and you can handle the page the pages and controls more easily.
jiake#
I don't know the plugin you said before, now I just know there is such one, and the author may not know. In 2004, bluenet compile a Chinese (Simplified) version of NSIS 2.14. It is called a classic version of NSIS, because the dialog call back funtions support feature was built-in. Here is some example script that can be compiled directly using the version, but do not need any plugin:
!define IDC_ABOUT 1300
!define IDC_LINK 1301
!define IDM_ABOUT 1
Function .onPageCallback
  ${If} $MSG = ${WM_INITDIALOG}
    Push $0
    Push $1
    Push $2
    Push $3
    ${GetDlgItemRect} $0 $1 $2 $3 $HWNDPARENT ${IDC_CANCEL}
    IntOp $0 $2 - $0
    IntOp $2 $3 - $1
    ${CreateButton} "关于(&A)" 20 $1 $0 $2 $HWNDPARENT ${IDC_ABOUT}
    IntOp $3 $0 + 30
    IntOp $1 $1 + 3
    IntOp $2 $2 - 2
    ${CreateLink} $3 $1 130 $2 $HWNDPARENT ${IDC_LINK}
    ${GetSystemMenu} $0 $HWNDPARENT
    ${AppendMenu} $0 ${MF_SEPARATOR} 0 0
    ${AppendMenu} $0 ${MF_STRING} ${IDM_ABOUT} "关于(&A)"
    Pop $3
    Pop $2
    Pop $1
    Pop $0
  ${ElseIf} $MSG = ${WM_COMMAND}
    ${If} $WPARAM = ${IDC_ABOUT}
    ${MessageBox2} `${PRODUCT_NAME}$\n版权所有 (C) ${PRODUCT_PUBLISHER}.$\n$\n我的主页:$\n${PRODUCT_WEB_SITE}` `关于` ${MB_OK}|${MB_ICONINFORMATION}
    ${ElseIf} $WPARAM = ${IDC_LINK}
        ExecShell open `${PRODUCT_WEB_SITE}`
    ${EndIf}
  ${ElseIf} $MSG = ${WM_DRAWITEM}
    ${DrawLink} `访问 ${PRODUCT_PUBLISHER} 的网站` ${IDC_LINK} $LPARAM
  ${ElseIf} $MSG = ${WM_SYSCOMMAND}
    ${If} $WPARAM = ${IDM_ABOUT}
        ${MessageBox2} `${PRODUCT_NAME}$\n版权所有 (C) ${PRODUCT_PUBLISHER}.$\n$\n我的主页:$\n${PRODUCT_WEB_SITE}` `关于` ${MB_OK}|${MB_ICONINFORMATION}
    ${EndIf}
  ${EndIf}
  
FunctionEnd 
The script also needs the header "UsefulLib.nsh" (in the above attachment) written by bluenet.

The idea of author is to make the dialog call back funtion be independent of NSIS 2.14.