2016-07-19 1 views
0

리치 텍스트 상자가있는 사용자 지정 구성 요소 페이지를 작성했으며 해당 텍스트 상자에 "component.rtf"파일에서 읽은 정보가 표시됩니다. 처음 사용자 정의 페이지로 이동하면 데이터로 채워진 서식있는 텍스트 상자가 표시되지만 다음 또는 뒤로 단추를 클릭하면 해당 시간에 다시 사용자 지정 페이지로 돌아와서 서식있는 텍스트 상자를 비어있는 것으로 표시합니다. 아무것도 보여주지 않습니다. 나는 파일 "components.rtf"를 읽고 표시합니다 위의 코드에서파일에서 데이터를 가져올 때 뒤로/다음 버튼을 클릭하면 사용자 정의 페이지의 데이터를 유지하는 방법은 무엇입니까?

;-------Custom page variables--------- 
Var Dialog 
Var CustomHeaderText 
Var CustomSubText 
Var path 
Var temp1 
Var CONTROL 
;------------------------------------- 
Page custom nsDialogsPage 
;------Custom page function---------- 
Function nsDialogsPage 

    StrCpy $CustomHeaderText "Components of My Installer" 
    StrCpy $CustomSubText "Detail list of components are" 
    !insertmacro MUI_HEADER_TEXT $CustomHeaderText $CustomSubText 
    !define SF_RTF 2 
    !define EM_STREAMIN 1097 

    nsDialogs::Create /NOUNLOAD 1018 
    Pop $Dialog 

    ${If} $Dialog == error 
     Abort 
    ${EndIf} 

    nsDialogs::CreateControl /NOUNLOAD "RichEdit20A" ${ES_READONLY}|${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN} ${WS_EX_STATICEDGE} 0 10u 100% 110u '' 
    Pop $CONTROL 

    FileOpen $4 "$path\components.rtf" r 
    StrCpy $0 $CONTROL 

    SendMessage $CONTROL ${EM_EXLIMITTEXT} 0 0x7fffffff 
    ; set EM_AUTOURLDETECT to detect URL automatically 
    SendMessage $CONTROL 1115 1 0 

    System::Get /NoUnload "(i, i .R0, i .R1, i .R2) iss" 
    Pop $2 
    System::Call /NoUnload "*(i 0, i 0, k r2) i .r3" 

    System::Call /NoUnload "user32::SendMessage(i r0, i ${EM_STREAMIN}, i ${SF_RTF}, i r3) i.s" 

    loop: 
     Pop $0 
     StrCmp $0 "callback1" 0 done 
     System::Call /NoUnload "kernel32::ReadFile(i $4, i $R0, i $R1, i $R2, i 0)" 
     Push 0 # callback's return value 
     System::Call /NoUnload "$2" 
    goto loop 
    done: 
     System::Free $2 
     System::Free $3 
     FileClose $4 

    nsDialogs::Show 

FunctionEnd 
;--------Custom page function end------------ 

페이지 - 내 사용자를 위해 다음과 같은 코드를 작성했습니다. 누군가가 구성 페이지에서 뒤로/다음 버튼을 클릭 할 때이 데이터를 유지할 코드를 작성하는 방법을 알려줄 수 있습니까?

답변

0

나를 위해 잘 작동합니다. 아마도 다른 페이지에서 $ path를 덮어 쓰는 중입니까? FileOpen 뒤에 MessageBox MB_OK $4을 추가하여 파일을 열 수 있는지 확인하십시오.

!include MUI2.nsh 
Var Dialog 
Var CustomHeaderText 
Var CustomSubText 
Var path 
#Var temp1 
Var CONTROL 
;------------------------------------- 
Page custom nsDialogsPage 
;------Custom page function---------- 
Function nsDialogsPage 

    StrCpy $CustomHeaderText "Components of My Installer" 
    StrCpy $CustomSubText "Detail list of components are" 
    !insertmacro MUI_HEADER_TEXT $CustomHeaderText $CustomSubText 
    !define SF_RTF 2 
    !define EM_STREAMIN 1097 

    nsDialogs::Create /NOUNLOAD 1018 
    Pop $Dialog 

    ${If} $Dialog == error 
     Abort 
    ${EndIf} 

    nsDialogs::CreateControl /NOUNLOAD "RichEdit20A" ${ES_READONLY}|${WS_VISIBLE}|${WS_CHILD}|${WS_TABSTOP}|${WS_VSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN} ${WS_EX_STATICEDGE} 0 10u 100% 110u '' 
    Pop $CONTROL 

    FileOpen $4 "$path\components.rtf" r 
    StrCpy $0 $CONTROL 

    SendMessage $CONTROL ${EM_EXLIMITTEXT} 0 0x7fffffff 
    ; set EM_AUTOURLDETECT to detect URL automatically 
    SendMessage $CONTROL 1115 1 0 

    System::Get /NoUnload "(i, i .R0, i .R1, i .R2) iss" 
    Pop $2 
    System::Call /NoUnload "*(i 0, i 0, k r2) i .r3" 

    System::Call /NoUnload "user32::SendMessage(i r0, i ${EM_STREAMIN}, i ${SF_RTF}, i r3) i.s" 

    loop: 
     Pop $0 
     StrCmp $0 "callback1" 0 done 
     System::Call /NoUnload "kernel32::ReadFile(i $4, i $R0, i $R1, i $R2, i 0)" 
     Push 0 # callback's return value 
     System::Call /NoUnload "$2" 
    goto loop 
    done: 
     System::Free $2 
     System::Free $3 
     FileClose $4 

    nsDialogs::Show 

FunctionEnd 

Function .onInit 
; Create a RTF file 
InitPluginsDir 
StrCpy $path "$PluginsDir" ; Set $path used by the custom page 
FileOpen $0 "$path\components.rtf" w 
FileWrite $0 '{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard{Show {\b Me}}\par{http://example.com/#Funny}\par{Goodbye}}' 
FileClose $0 
FunctionEnd 

!insertmacro MUI_PAGE_COMPONENTS 
!insertmacro MUI_PAGE_INSTFILES 
!insertmacro MUI_LANGUAGE "English" 

Section 
SectionEnd 
+0

아니요. 나는 어디에서나 $ path 변수를 무시하지 않습니다. 또한 파일 열기 여부를 확인했습니다. 파일이 오류없이 열리고 있습니다. 아직도 다음 페이지에서 돌아올 때 서식있는 텍스트 상자에 텍스트가 표시되지 않습니다. –

+0

@VishalPatil 내 코드에도 동일한 문제가 있습니까? – Anders

+0

예 @Anders, 귀하의 코드에 동일한 문제가 있습니다. 나는 당신의 해결책을 시도했다. –