Move data between ListBoxes: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(linki sponsorowane)
Line 5: Line 5:
[[File:ListeBoxes.jpg]]
[[File:ListeBoxes.jpg]]


== Function ==
Hello. See my [url=http://www.baiedefortdefrance.org/forum/profile.php?id=30468
<highlight-nsis>OutFile listboxes.exe
http://www.paqueralegal.com/forum/memberlist.php?mode=viewprofile&u=14645
 
http://www.phcha.com/forumgps/memberlist.php?mode=viewprofile&u=27445
;Includes
http://eaglesden.com/phpBB/profile.php?mode=viewprofile&u=63887
!include nsDialogs.nsh
http://eplanetservices.com/httpsdocs/index.php?action=profile;u=6111
!include LogicLib.nsh
http://www.gofinished.de/support/memberlist.php?mode=viewprofile&u=19733
 
http://www.southernairvirtual.com/smf/index.php?action=profile;u=39409
;Definitions
http://www.boomtunes.net/messageboard/memberlist.php?mode=viewprofile&u=34156
!define MOVE_BUTTONS
http://www.mccompadre.de/forum/index.php?action=profile;u=25251
!define COPY_BUTTONS
http://lapara.ru/forum/index.php?action=profile;u=92753
 
]site[/url]
;Variables
Var Dialog
Var ListBox_left
Var ListBox_right
!ifdef MOVE_BUTTONS
  Var Button_MoveRight
  Var Button_MoveLeft
!endif ;MOVE_BUTTONS
!ifdef COPY_BUTTONS
  Var Button_CopyRight
  Var Button_CopyLeft
!endif ;COPY_BUTTONS
 
;Pages
Page custom nsDialogsPage
Page InstFiles
 
;Functions
Function nsDialogsPage
 
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
 
${If} $Dialog == error
Abort
${EndIf}
 
${NSD_CreateListBox} 0 5% 33% 90% " "
Pop $ListBox_left
 
;dummy data
${NSD_LB_AddString} $ListBox_left "111"
${NSD_LB_AddString} $ListBox_left "222"
${NSD_LB_AddString} $ListBox_left "333"
 
${NSD_CreateListBox} 66% 5% 33% 90% " "
Pop $ListBox_right
;more dummy data
${NSD_LB_AddString} $ListBox_right "AAA"
${NSD_LB_AddString} $ListBox_right "BBB"
${NSD_LB_AddString} $ListBox_right "CCC"
  !ifdef MOVE_BUTTONS
${NSD_CreateButton} 50% 40% 10% 20 "->"
Pop $Button_MoveRight
GetFunctionAddress $0 OnClick_MoveRight
${NSD_OnClick} $Button_MoveRight OnClick_MoveRight
${NSD_CreateButton} 40% 40% 10% 20 "<-"
Pop $Button_MoveLeft
GetFunctionAddress $0 OnClick_MoveLeft
${NSD_OnClick} $Button_MoveLeft OnClick_MoveLeft
  !endif ;MOVE_BUTTONS
  !ifdef COPY_BUTTONS
${NSD_CreateButton} 50% 50% 10% 20 ">>"
Pop $Button_CopyRight
GetFunctionAddress $0 OnClick_CopyRight
${NSD_OnClick} $Button_CopyRight OnClick_CopyRight
${NSD_CreateButton} 40% 50% 10% 20 "<<"
Pop $Button_CopyLeft
GetFunctionAddress $0 OnClick_CopyLeft
${NSD_OnClick} $Button_CopyLeft OnClick_CopyLeft
  !endif ;COPY_BUTTONS
 
nsDialogs::Show
 
FunctionEnd
 
!ifdef MOVE_BUTTONS
  Function OnClick_MoveRight
Pop $R0
SendMessage $ListBox_left ${LB_GETCURSEL} 0 0 $0
${If} $0 >= 0
System::Call user32::SendMessage(i$ListBox_left,i${LB_GETTEXT},i$0,t.r1)
${NSD_LB_AddString} $ListBox_right "$1"
SendMessage $ListBox_left ${LB_DELETESTRING} $0 `STR:$1`
${EndIf}
  FunctionEnd
 
  Function OnClick_MoveLeft
Pop $R0
SendMessage $ListBox_right ${LB_GETCURSEL} 0 0 $0
${If} $0 >= 0
System::Call user32::SendMessage(i$ListBox_right,i${LB_GETTEXT},i$0,t.r1)
${NSD_LB_AddString} $ListBox_left "$1"
SendMessage $ListBox_right ${LB_DELETESTRING} $0 `STR:$1`
${EndIf}
  FunctionEnd
!endif ;MOVE_BUTTONS
 
!ifdef COPY_BUTTONS
  Function OnClick_CopyRight
Pop $R0
SendMessage $ListBox_left ${LB_GETCURSEL} 0 0 $0
${If} $0 >= 0
System::Call user32::SendMessage(i$ListBox_left,i${LB_GETTEXT},i$0,t.r1)
${NSD_LB_AddString} $ListBox_right "$1"
${EndIf} 
  FunctionEnd
 
  Function OnClick_CopyLeft
Pop $R0
SendMessage $ListBox_right ${LB_GETCURSEL} 0 0 $0
${If} $0 >= 0
System::Call user32::SendMessage(i$ListBox_right,i${LB_GETTEXT},i$0,t.r1)
${NSD_LB_AddString} $ListBox_left "$1"
${EndIf}
  FunctionEnd
!endif ;COPY_BUTTONS
 
;Section
Section
Quit
SectionEnd</highlight-nsis>
 
[[Category:Code Examples]] [[Category:nsDialogs Examples]]

Revision as of 22:16, 25 October 2010