Archive: How to create user defined directory page?


How to create user defined directory page?
!insertmacro MUI_PAGE_DIRECTORY

In the code can be used to display the built-in directory page.

Is possible to create user defined page directory? because i need to call many times this page.

How to create user defined page directory?


You can probably just use multiple built-in directory pages. Simply insert the macro multiple times. You can customize each page using these defines:
MUI_DIRECTORYPAGE_TEXT_TOP text
MUI_DIRECTORYPAGE_TEXT_DESTINATION
MUI_DIRECTORYPAGE_VARIABLE

See the MUI2 readme: http://nsis.sourceforge.net/Docs/Mod...02/Readme.html


Thanks MSG.
I have tried following way to create directory page manually.

!define MUI_PAGE_CUSTOMFUNCTION_PRE MyDir
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowDirectory
!insertmacro MUI_PAGE_DIRECTORY


Function MyDir
${DriveSpace} "C:\" "/D=F /S=G" $R0
${If} $R0 <= 2
MessageBox MB_OK "Going to display"
call ShowDirectoryPage
${EndIf}
Function ShowDirectory
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $1 $0 1020 ; IDC_SELDIRTEXT
StrCpy $2 "$(SelDirText)"
SendMessage $1 ${WM_SETTEXT} 0 "STR:$2"
GetDlgItem $1 $0 1006
StrCpy $2 "$(IntroText)"
SendMessage $1 ${WM_SETTEXT} 0 "STR:$2"
GetDlgItem $1 $HWNDPARENT 1037
StrCpy $2 "$(DirText)"
SendMessage $1 ${WM_SETTEXT} 0 "STR:$2"
GetDlgItem $1 $HWNDPARENT 1038
StrCpy $2 "$(DirSubText)"
SendMessage $1 ${WM_SETTEXT} 0 "STR:$2"
GetDlgItem $1 $0 1023 ; IDC_SPACEREQUIRED
System::Call 'user32.dll::ShowWindow(i, i) v($1, 0)'
GetDlgItem $1 $0 1024 ; IDC_SPACEAVAILABLE
System::Call 'user32.dll::ShowWindow(i, i) v($1, 0)'
FunctionEnd


but in the ShowDirectory function didnot display directory page.Also i got warning messages for this function.


You're missing a FunctionEnd after MyDir


oh sorry.Its my mistake i didnot copy the code properly.

define MUI_PAGE_CUSTOMFUNCTION_PRE MyDir
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowDirectory
!insertmacro MUI_PAGE_DIRECTORY


Function MyDir
${DriveSpace} "C:\" "/D=F /S=G" $R0
${If} $R0 <= 2
MessageBox MB_OK "Going to display"
call ShowDirectoryPage
${EndIf}
FunctionEnd

Function ShowDirectory
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $1 $0 1020 ; IDC_SELDIRTEXT
StrCpy $2 "$(SelDirText)"
SendMessage $1 ${WM_SETTEXT} 0 "STR:$2"
GetDlgItem $1 $0 1006
StrCpy $2 "$(IntroText)"
SendMessage $1 ${WM_SETTEXT} 0 "STR:$2"
GetDlgItem $1 $HWNDPARENT 1037
StrCpy $2 "$(DirText)"
SendMessage $1 ${WM_SETTEXT} 0 "STR:$2"
GetDlgItem $1 $HWNDPARENT 1038
StrCpy $2 "$(DirSubText)"
SendMessage $1 ${WM_SETTEXT} 0 "STR:$2"
GetDlgItem $1 $0 1023 ; IDC_SPACEREQUIRED
System::Call 'user32.dll::ShowWindow(i, i) v($1, 0)'
GetDlgItem $1 $0 1024 ; IDC_SPACEAVAILABLE
System::Call 'user32.dll::ShowWindow(i, i) v($1, 0)'
FunctionEnd


Following warnings displayed

LangString "SelDirText" is not set in language table of language English
LangString "IntroText" is not set in language table of language English
LangString "DirText" is not set in language table of language English
LangString "DirSubText" is not set in language table of language English


You need to !insertmacro MUI_LANGUAGE "English" after all (un)page macros are inserted.


I have already included this macro after all page macros are inserted.
!insertmacro MUI_LANGUAGE English

Is there need to insert before this page ShowDirectory load?


Maybe it is easier to create custom directory page (few labels, edit box and button with nsDialogs::SelectFolder function) with nsDialogs?

It can be shown many times with appropriate parameters without using a lot of code.