无法理解为什么$ {NSD_GetState} $ Checkbox不起作用

时间:2015-12-09 08:41:00

标签: installer nsis

任何人都可以向我解释,为什么$ {NSD_GetState} $ Checkbox无效? 我失去了大约4个小时试图找出问题所在。我尝试了不同的变体,但是在这个脚本中它们没有用。

Actualy这是我第一次尝试制作一个nsis安装程序,所以我甚至不知道我应该在哪里找错,或者我只是不理解这种语言的逻辑。

来自俄罗斯的爱:) 抱歉我的英语不好

!define NAME "Simple LiveUSB installer"
!define FILENAME "USB"
!define VERSION "v0.1"

Name "${NAME} ${VERSION}"
OutFile "${FILENAME}.exe"

SetCompressor LZMA
ShowInstDetails hide
XPStyle on

!include MUI2.nsh
!include FileFunc.nsh
!include nsDialogs.nsh
;!include LogicLib.nsh

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\HEADER2.bmp"
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\media-floppy.ico"


Page custom drivePage
Page custom Var123

!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "Russian"
LangString DrivePage_Title ${LANG_RUSSIAN} "TEXT"
LangString DrivePage_Title2 ${LANG_RUSSIAN} "TEXT"
LangString DrivePage_Text ${LANG_RUSSIAN} "TEXT"
LangString DrivePage_Text2 ${LANG_RUSSIAN} "Format"
LangString DrivePage_Input ${LANG_RUSSIAN} "Choose"



Var Label
Var Label2
Var Checkbox
;Var Checkbox_State
Var DestDriveHW
Var DestDrive

# Functions #######################################

Function drivePage

    !insertmacro MUI_HEADER_TEXT $(DrivePage_Title) $(DrivePage_Title2)

    nsDialogs::Create 1018

    ${If} $DestDrive == ""
        GetDlgItem $6 $HWNDPARENT 1
        EnableWindow $6 0
    ${EndIf}

    ${NSD_CreateLabel} 0 0 100% 160 $(DrivePage_Text)
    Pop $Label

    ${NSD_CreateLabel} 10 182 100% 15 $(DrivePage_Input)
    Pop $Label2

    ${NSD_CreateDroplist} 10 200 13% 20 ""
    Pop $DestDriveHw

    ${NSD_OnChange} $DestDriveHw db_select.onchange
    ${GetDrives} "FDD" driveListFiller

    ${If} $DestDrive != ""
        ${NSD_CB_SelectString} $DestDriveHw $DestDrive
    ${EndIf}

    ${NSD_CreateCheckbox} 80 203 100% 10u $(DrivePage_Text2)
    Pop $Checkbox

    ${If} $Checkbox_State == ${BST_CHECKED}
        ${NSD_Check} $Checkbox_State
    ${EndIf}

    nsDialogs::Show
FunctionEnd


Function db_select.onchange
    Pop $DestDriveHw

    ${NSD_GetText} $DestDriveHw $0
    StrCpy $DestDrive "$0"
    GetDlgItem $6 $HWNDPARENT 1
    EnableWindow $6 1
FunctionEnd

Function driveListFiller
    SendMessage $DestDriveHw ${CB_ADDSTRING} 0 "STR:$9"
    Push 1
FunctionEnd

Function Var123
Pop $Checkbox
MessageBox mb_ok "FIN Checkbox_State=$Checkbox_State Checkbox=$Checkbox"
${NSD_GetState} $Checkbox $0
${If} $0 <> 0
    MessageBox mb_ok "Custom checkbox was checked... N=$0"
${EndIf}
${If} $0 == 0
    MessageBox mb_ok "Custom checkbox ZERO... N=$0"
${EndIf}

Functionend

# Section #######################################

Section "" main


InitPluginsDir

File /oname=$PLUGINSDIR\syslinux.cfg  "${NSISDIR}\plugins\syslinux.cfg"
File /oname=$PLUGINSDIR\syslinux.exe  "${NSISDIR}\plugins\syslinux.exe"

File /oname=$PLUGINSDIR\nsExec.dll  "${NSISDIR}\plugins\nsExec.dll"


StrCpy $R0 $DestDrive -1


;ExpandEnvStrings $0 %COMSPEC%
;nsExec::Exec '"$0" /c echo. | format $R0 /q /x /v:LiveUSB /fs:fat32'



nsExec::Exec '$PLUGINSDIR\syslinux.exe -maf -d boot\syslinux $R0' 


;SendMessage $Checkbox ${BM_GETSTATE} 0 0 $0
;${If} $0 != 0

;  MessageBox MB_OK checked!

;${EndIf}

;Pop $Checkbox
;MessageBox mb_ok "FIN Checkbox_State=$Checkbox_State Checkbox=$Checkbox"
;${NSD_GetState} $Checkbox $0
;${If} $0 <> 0
;    MessageBox mb_ok "Custom checkbox was checked... N=$0"
;${EndIf}


CopyFiles $PLUGINSDIR\syslinux.cfg  "$R0\syslinux.cfg"


SectionEnd

1 个答案:

答案 0 :(得分:1)

你的例子中有太多不相关的代码,你有点难以理解你真正想要做的事情。

如果要检索其他页面上的复选框状态,则必须保存状态,因为当您离开页面时,复选框控件将被销毁。

var getConnection = require('../../connection.js');
var products = null;

getConnection(function(err,db) {
    var collection = db.collection("products");
    collection.find().toArray(function(err, productsDB) {
        products = productsDB;
    })
});
console.log(products);
module.export = products;