2017-10-16 4 views
-1

여러분이 다시 나를 도울 수 있기를 바랍니다. 나는 커스텀 페이지를 만들었고, 그 페이지에는 텍스트 필드와 풀리스트가있다. 나는 또한 클리어 버튼을 누르면 화면상의 모든 필드가 지워진다.NSIS 버튼 누름시 텍스트 및 드롭리스트 다시 설정

참고 : 나는 예

내가 가진 문제에 TestNotify.nsu의 코드를 사용하더라도 분명한 값이 마지막 필드는 채우기를 사용하여 프로그램을 다시로드에 있도록 INI 파일에 기록을 압박 한 (이다 내가 분명히 누르면, ini 파일을 두 번 지워야 만합니다.)

둘째, 어떻게하면 리셋을 누를 때 선택한 드롭리스트를 기본값으로 재설정 할 수 있습니까?

내가 지금하고있는 유일한 부분은 clearbtn입니다. 그래서 어떻게 한 번만 droplists를 특정 값으로 재설정하고 한 번만 지울 때 ini에서 데이터를 지울 수 있습니다.

###Add Auto Start option 

SetCompressor lzma 
XPStyle on 


!define FolderImages "Included\Images" 

!define ImageIcon "Icon.ico" 
!define ImageHDR "HDR.bmp" 

!define PRODUCT_NAME "Test" 
!define PRODUCT_VERSION "1.0" 

!define MUI_ICON ".\${FolderImages}\${ImageIcon}" 
Icon ".\${FolderImages}\${ImageIcon}" 

!include WinVer.nsh 
!include LogicLib.nsh 
!include x64.nsh 
!include FileFunc.nsh 
!include MUI.nsh 
!include WinMessages.nsh 
!include InstallOptions.nsh 
!include Sections.nsh 
!include nsDialogs.nsh 

!define MUI_HEADERIMAGE 
!define MUI_HEADERIMAGE_BITMAP ".\${FolderImages}\${ImageHDR}" 

Page custom SetCustom ValidateCustom 

!insertmacro MUI_LANGUAGE "English" 

Function SetCustom 

    !insertmacro MUI_HEADER_TEXT "Licence Key Generator" "Create or Read Licence Keys" 


    #Hides the close button 
    GetDlgItem $R0 $HWNDPARENT 1 
    ShowWindow $R0 ${SW_HIDE} 


    InstallOptions::initDialog ".\UserProfiles.ini" 
    ; In this mode InstallOptions returns the window handle so we can use it 
    Pop $0 
    ; Now show the dialog and wait for it to finish 
    InstallOptions::show 
    ; Finally fetch the InstallOptions status value (we don't care what it is though) 
    Pop $0 
FunctionEnd 

Function ValidateCustom 

    # At this point the user has either pressed cancel or one of our custom buttons 
    # We find out which by reading from the INI file 
    ReadINIStr $0 ".\UserProfiles.ini" "Settings" "State" 
    StrCmp $0 0 cancelbtn 
    StrCmp $0 19 createbtn 
    StrCmp $0 20 readbtn 
    StrCmp $0 21 comparebtn 
    StrCmp $0 22 clearbtn 
    Abort # Return to the page 

createbtn: 
Abort # Return to the page 

readbtn: 
Abort # Return to the page 

comparebtn: 
Abort # Return to the page 

clearbtn: 

    #Text Field 
    ReadINIStr $1 ".\UserProfiles.ini" "Field 6" "HWND" 
    SendMessage $1 ${WM_SETTEXT} 0 "STR:" 

    #Text Field 
    ReadINIStr $1 ".\UserProfiles.ini" "Field 8" "HWND" 
    SendMessage $1 ${WM_SETTEXT} 0 "STR:" 

    #Text Field 
    ReadINIStr $1 ".\UserProfiles.ini" "Field 10" "HWND" 
    SendMessage $1 ${WM_SETTEXT} 0 "STR:" 

    #Drop List ------------------------------------------------------------<<<< 
    ReadINIStr $1 ".\UserProfiles.ini" "Field 12" "HWND" 
    SendMessage $1 ${WM_SETTETX} 0 "STR:" 

    #Text Field 
    ReadINIStr $1 ".\UserProfiles.ini" "Field 14" "HWND" 
    SendMessage $1 ${WM_SETTEXT} 0 "STR:" 

    #Drop List ------------------------------------------------------------<<<< 
    ReadINIStr $1 ".\UserProfiles.ini" "Field 16" "HWND" 
    SendMessage $1 ${WM_SETTEXT} 0 "STR:" 

    #Text Field 
    ReadINIStr $1 ".\UserProfiles.ini" "Field 18" "HWND" 
    SendMessage $1 ${WM_SETTEXT} 0 "STR:" 

    Abort # Return to the page 

cancelbtn: 

FunctionEnd 

Section Dummy 
SectionEnd 
+0

최소한의 UserProfiles.ini를 게시하면 도움이됩니다. – Anders

+0

WM_SETTETX는 오타입니다. – Anders

답변

1

당신은 CB_RESETCONTENT 메시지를 전송하여 droplist을 취소 할 수 있습니다

당신은 상대 .INI 경로를 사용해서는 안
Var MyDir 
Function .onInit 
; Create example .ini 
InitPluginsDir 
StrCpy $MyDir $Temp ; Use something else in a real application, or use $PluginsDir. 
WriteIniStr "$MyDir\UserProfiles.ini" "Settings" NumFields 4 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 1" Type Button 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 1" Left 0 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 1" Right 50 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 1" Top 0 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 1" Bottom 14 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 1" Text "&Clear" 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 1" Flags NOTIFY 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 2" Type Text 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 2" Left 0 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 2" Right 100 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 2" Top 15 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 2" Bottom 30 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 3" Type Droplist 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 3" Left 0 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 3" Right 100 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 3" Top 35 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 3" Bottom 99 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 4" Type Button 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 4" Left 55 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 4" Right 105 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 4" Top 0 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 4" Bottom 14 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 4" Text "&Add" 
WriteIniStr "$MyDir\UserProfiles.ini" "Field 4" Flags NOTIFY 
FunctionEnd 

Function SetCustom 
InstallOptions::initDialog "$MyDir\UserProfiles.ini" 
; In this mode InstallOptions returns the window handle so we can use it 
Pop $0 
; Now show the dialog and wait for it to finish 
InstallOptions::show 
; Finally fetch the InstallOptions status value (we don't care what it is though) 
Pop $0 
FunctionEnd 

Function ValidateCustom 
# At this point the user has either pressed cancel or one of our custom buttons 
# We find out which by reading from the INI file 
ReadINIStr $0 "$MyDir\UserProfiles.ini" "Settings" "State" 

StrCmp $0 1 clearbtn 
StrCmp $0 4 addbtn 
Abort # Return to the page 


clearbtn: 
    #Text Field 
    ReadINIStr $1 "$MyDir\UserProfiles.ini" "Field 2" "HWND" 
    SendMessage $1 ${WM_SETTEXT} 0 "STR:" 

    #Droplist Field 
    ReadINIStr $2 "$MyDir\UserProfiles.ini" "Field 3" "HWND" 
    SendMessage $2 ${CB_RESETCONTENT} 0 0 
    DeleteIniStr "$MyDir\UserProfiles.ini" "Field 3" "ListItems" 
    DeleteIniStr "$MyDir\UserProfiles.ini" "Field 3" "State" 

    Abort # Return to the page 

addbtn: 
    ReadINIStr $1 "$MyDir\UserProfiles.ini" "Field 2" "State" 
    ReadINIStr $2 "$MyDir\UserProfiles.ini" "Field 3" "HWND" 
    SendMessage $2 ${CB_ADDSTRING} 0 "STR:$1" 
    SendMessage $2 ${CB_SELECTSTRING} 0 "STR:$1" 

    Abort # Return to the page 

FunctionEnd 

, 즉 자초되어, 전체 경로를 사용!

+0

이것은 상대적인 경로를 사용하고 있었는데, 테스트 도구 였기 때문에 실제 애플 리케이션으로 옮겨서 옮길 수있었습니다. 내 애플 리케이션에서 $ pluginsdir을 사용할 것이다. –

+0

설치 프로그램을 종료 할 때 $ pluginsdir이 삭제되므로 매번 .ini 파일을 새로 만들지 않아서 추가 버그가 생성됩니다. – Anders