Rain, thanks for the example. It's not exactly what I meant, but I am not sure I explained myself all that clearly. I wanted to move the selected item(s) up or down, not just the 'selector'.
Don't scream when you look at this, but feel free to laugh! This is what I came up with after a couple of days racking my brain. Ugly to be sure, but it works!!
One thing I ran into.. is there a way to preserve the multiple selections in the index value? Dialog.msListBox1.ItemIndex doesn't appear to hold more than just the last selected item.
Please feel free to make fun of me and suggest anything that would make this better.
Mondi
Code: Select all
Dialog>Dialog1
Caption=Dialog1
Width=336
Height=434
Top=238
Left=-846
ListBox=msListBox1,96,64,137,209,%vList%,true
Button=Up,80,296,75,25,6
Button=Down,168,296,75,25,7
Button=Exit,128,360,75,25,2
EndDialog>Dialog1
LET>vList=Item1%CRLF%Item2%CRLF%Item3%CRLF%Item4%CRLF%Item5%CRLF%Item6%CRLF%Item7%CRLF%Item8%CRLF%Item9%CRLF%Item10
SHOW>Dialog1
LABEL>lLoop1
GetDialogAction>Dialog1,vResult
IF>vResult=6
Let>VAREXPLICIT=0
//First lets get the existing list and seperate it
//for some reason I am gettting an extra item at the end so I am going to trip the crlf before I sep
Let>Dialog1.msListBox1.Items.Text={copy(%Dialog1.msListBox1.Items.Text%,1,length(%Dialog1.msListBox1.Items.Text%)-2)}
SEP>%Dialog1.msListBox1.Items.Text%,%CRLF%,vUnorderedList
//Now lets get the items that are selected
SEP>%Dialog1.msListBox1%,%CRLF%,vSelectedItems
//lets find what positions are selected items are in
LET>vI=0
REPEAT>vI
LET>vI=%vI%+1
LET>vI2=0
REPEAT>vI2
LET>vI2=%vI2%+1
IF>vUnorderedList_%vI2%=vSelectedItems_%vI%
//This actually creates variables vIndexValue_1..2..3 etc and assigns the current index value
//to the variable.. i.e. vIndexValue_1=2 first selected item is index 2
LET>vIndexValue_%vI%=%vI2%
GOTO>lResult6vI2END
ENDIF
UNTIL>vI2,vUnorderedList_count
LABEL>lResult6vI2END
UNTIL>vI,vSelectedItems_count
//Now lets re-order the list
LET>vI=0
REPEAT>vI
LET>vI=%vI%+1
//If the first item in the list is selected I want to skip it
//becuase it cant move any higher
IF>vIndexValue_%vI%<1>vTempIndex=vIndexValue_%vI%
LET>vTempItem=vUnorderedList_%vTempIndex%
LET>vTempNum=%vTempIndex%-1
LET>vUnorderedList_%vTempIndex%=vUnorderedList_%vTempNum%
LET>vUnorderedList_%vTempNum%=vTempItem
ENDIF
UNTIL>vI,vSelectedItems_count
//now lets reassemble our list
LET>vI=0
//clear the existing list
LET>Dialog1.msListBox1.Items.Text=
REPEAT>vI
LET>vI=%vI%+1
CON>Dialog1.msListBox1.Items.Text,vUnorderedList_%vI%
CON>%Dialog1.msListBox1.Items.Text%,%CRLF%
UNTIL>vI,vUnorderedList_count
//Now lets trim the last CRLF
Let>Dialog1.msListBox1.Items.Text={copy(%Dialog1.msListBox1.Items.Text%,1,length(%Dialog1.msListBox1.Items.Text%)-2)}
ResetDialogAction>Dialog1
ENDIF
IF>vResult=7
Let>VAREXPLICIT=0
//First lets get the existing list and seperate it
//for some reason I am gettting an extra item at the end so I am going to trip the crlf before I sep
Let>Dialog1.msListBox1.Items.Text={copy(%Dialog1.msListBox1.Items.Text%,1,length(%Dialog1.msListBox1.Items.Text%)-2)}
SEP>%Dialog1.msListBox1.Items.Text%,%CRLF%,vUnorderedList
//Now lets get the items that are selected
SEP>%Dialog1.msListBox1%,%CRLF%,vSelectedItems
//lets find what positions are selected items are in
LET>vI=0
REPEAT>vI
LET>vI=%vI%+1
LET>vI2=0
REPEAT>vI2
LET>vI2=%vI2%+1
IF>vUnorderedList_%vI2%=vSelectedItems_%vI%
//This actually creates variables vIndexValue_1..2..3 etc and assigns the current index value
//to the variable.. i.e. vIndexValue_1=2 first selected item is index 2
LET>vIndexValue_%vI%=%vI2%
GOTO>lResult7vI2END
ENDIF
UNTIL>vI2,vUnorderedList_count
LABEL>lResult7vI2END
UNTIL>vI,vSelectedItems_count
//Now lets re-order the list
LET>vI=%vSelectedItems_count%+1
REPEAT>vI
LET>vI=%vI%-1
//If the last item in the list is selected I want to skip it
//becuase it cant move any lower
IF>vIndexValue_%vI%<vUnorderedList_count>vTempIndex=vIndexValue_%vI%
LET>vTempItem=vUnorderedList_%vTempIndex%
LET>vTempNum=%vTempIndex%+1
LET>vUnorderedList_%vTempIndex%=vUnorderedList_%vTempNum%
LET>vUnorderedList_%vTempNum%=vTempItem
ENDIF
UNTIL>vI,1
//now lets reassemble our list
LET>vI=0
//clear the existing list
LET>Dialog1.msListBox1.Items.Text=
REPEAT>vI
LET>vI=%vI%+1
CON>Dialog1.msListBox1.Items.Text,vUnorderedList_%vI%
CON>%Dialog1.msListBox1.Items.Text%,%CRLF%
UNTIL>vI,vUnorderedList_count
//Now lets trim the last CRLF
Let>Dialog1.msListBox1.Items.Text={copy(%Dialog1.msListBox1.Items.Text%,1,length(%Dialog1.msListBox1.Items.Text%)-2)}
//trying to preserve the selected items
Let>Dialog1.msListBox1.ItemIndex=%list_item%
ResetDialogAction>Dialog1
ENDIF
ENDIF
IF>vResult=2
GOTO>lEndLoop1
ENDIF
//ResetDialogAction>Dialog1
GOTO>lLoop1
LABEL>lEndLoop1