Move data between ListBoxes: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(linki sponsorowane)
m (Reverted edits by 91.201.66.205 to last version by Anders)
Line 5: Line 5:
[[File:ListeBoxes.jpg]]
[[File:ListeBoxes.jpg]]


Hello. See my [url=http://thefivesolas.phpbb3now.com/memberlist.php?mode=viewprofile&u=15627
== Function ==
http://www.washingtonpublishers.com/phpbb3/memberlist.php?mode=viewprofile&u=37456
<highlight-nsis>OutFile listboxes.exe
http://hokefamily.net/forum/index.php?action=profile;u=75181
 
http://www.victorpopov.com/forum/index.php?action=profile;u=57341
;Includes
http://faqactivewear.com/faqclubforums/index.php?action=profile;u=95082
!include nsDialogs.nsh
http://www.consiliulelevilor.ro/forum/profile.php?mode=viewprofile&u=112251
!include LogicLib.nsh
http://elvendreams.com/wartales/index.php?action=profile;u=76667
 
http://www.elsa.cz/forum/memberlist.php?mode=viewprofile&u=11342
;Definitions
http://fatherpeter.us/smf/index.php?action=profile;u=88608
!define MOVE_BUTTONS
http://lord-yachting.com/forums/memberlist.php?mode=viewprofile&u=32659
!define COPY_BUTTONS
]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 16:10, 26 October 2010

Author: Jan (talk, contrib)


Description

A custom page using nsDialogs to move (or copy) data between controls, in this case two listboxes

ListeBoxes.jpg

Function

OutFile listboxes.exe
 
;Includes
!include nsDialogs.nsh
!include LogicLib.nsh
 
;Definitions
!define MOVE_BUTTONS
!define COPY_BUTTONS
 
;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