Sorting Components: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
(Fix script (there were errors and it was not compatible with Unicode)) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
The following script shows how to sort components in the components page under a certain group. It was written for [http://forums.winamp.com/showthread.php?s=&threadid=227483 theAdib in the forums]. His intention was to keep sections sorted for all available languages.<highlight-nsis>!define TVGN_ROOT 0 | {{PageAuthor|KiCHiK}} | ||
The following script shows how to sort components in the components page under a certain group. It was written for [http://forums.winamp.com/showthread.php?s=&threadid=227483 theAdib in the forums]. His intention was to keep sections sorted for all available languages. | |||
<highlight-nsis> | |||
!define TVGN_ROOT 0 | |||
!define TVGN_NEXT 1 | !define TVGN_NEXT 1 | ||
!define TVGN_NEXTVISIBLE 6 | !define TVGN_NEXTVISIBLE 6 | ||
Line 6: | Line 11: | ||
!define TVM_GETNEXTITEM 4362 | !define TVM_GETNEXTITEM 4362 | ||
!define | !define TVM_GETITEMA 4364 | ||
!define TVM_GETITEMW 4414 | |||
!define TVM_SORTCHILDREN 4371 | !define TVM_SORTCHILDREN 4371 | ||
!define TVITEM '(i, i, i, i, i, i, i, i, i, i)' | !define TVITEM '(i, i, i, i, i, i, i, i, i, i)' | ||
!ifdef NSIS_UNICODE | |||
!define TVM_GETITEM ${TVM_GETITEMW} | |||
!else | |||
!define TVM_GETITEM ${TVM_GETITEMA} | |||
!endif | |||
Page components "" compShow | Page components "" compShow | ||
Line 44: | Line 57: | ||
System::Alloc ${NSIS_MAX_STRLEN} | System::Alloc ${NSIS_MAX_STRLEN} | ||
Pop $2 | Pop $2 | ||
loop: | loop: | ||
System::Call '*${TVITEM}(${TVIF_TEXT}, r1,,, r2, ${NSIS_MAX_STRLEN},,,,) i .r3' | |||
SendMessage $0 ${TVM_GETITEM} 0 $3 | SendMessage $0 ${TVM_GETITEM} 0 $3 | ||
System::Call '*$2(&t${NSIS_MAX_STRLEN} .r4)' | System::Call '*$2(&t${NSIS_MAX_STRLEN} .r4)' | ||
Line 53: | Line 66: | ||
SendMessage $0 ${TVM_GETNEXTITEM} ${TVGN_NEXTVISIBLE} $1 $1 | SendMessage $0 ${TVM_GETNEXTITEM} ${TVGN_NEXTVISIBLE} $1 $1 | ||
StrCmp $1 loop | StrCmp 0 $1 done loop | ||
found: | found: | ||
Line 61: | Line 74: | ||
done: | done: | ||
FunctionEnd</highlight-nsis> | System::Free $2 | ||
System::Free $3 | |||
FunctionEnd | |||
</highlight-nsis> | |||
[[Category:Tutorials]] | |||
[[Category:Code Examples]] | [[Category:Code Examples]] | ||
[[Category:System Plugin Examples]] | [[Category:System Plugin Examples]] |
Latest revision as of 20:10, 14 January 2017
Author: KiCHiK (talk, contrib) |
The following script shows how to sort components in the components page under a certain group. It was written for theAdib in the forums. His intention was to keep sections sorted for all available languages.
!define TVGN_ROOT 0 !define TVGN_NEXT 1 !define TVGN_NEXTVISIBLE 6 !define TVIF_TEXT 1 !define TVM_GETNEXTITEM 4362 !define TVM_GETITEMA 4364 !define TVM_GETITEMW 4414 !define TVM_SORTCHILDREN 4371 !define TVITEM '(i, i, i, i, i, i, i, i, i, i)' !ifdef NSIS_UNICODE !define TVM_GETITEM ${TVM_GETITEMW} !else !define TVM_GETITEM ${TVM_GETITEMA} !endif Page components "" compShow Page instfiles XPStyle on Name "test" OutFile "test.exe" Section ztest SectionEnd SectionGroup /e test Section c SectionEnd Section b SectionEnd Section a SectionEnd SectionGroupEnd Function compShow FindWindow $0 "#32770" "" $HWNDPARENT GetDlgItem $0 $0 1032 SendMessage $0 ${TVM_GETNEXTITEM} ${TVGN_ROOT} 0 $1 System::Alloc ${NSIS_MAX_STRLEN} Pop $2 loop: System::Call '*${TVITEM}(${TVIF_TEXT}, r1,,, r2, ${NSIS_MAX_STRLEN},,,,) i .r3' SendMessage $0 ${TVM_GETITEM} 0 $3 System::Call '*$2(&t${NSIS_MAX_STRLEN} .r4)' StrCmp $4 "test" 0 +2 ### CHANGE ME Goto found SendMessage $0 ${TVM_GETNEXTITEM} ${TVGN_NEXTVISIBLE} $1 $1 StrCmp 0 $1 done loop found: SendMessage $0 ${TVM_SORTCHILDREN} 0 $1 # recursive - SendMessage $0 ${TVM_SORTCHILDREN} 1 $1 done: System::Free $2 System::Free $3 FunctionEnd