Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can WM_DROPFILES be used in a ListBox?
#1
Gintaras,
Can WM_DROPFILES (or similar eg. WS_EX_ACCEPTFILES) be used in a Dialog with a ListBox?

Wondering if say, I had a dialog with a List Box in it, and
the items in it were function names from my functions listed in QM_Editor.

Now I need to be able to drag a function from qm to this dialog with the listbox,
like auto adding an item to the  dialog with the listbox.

would that be possible?  hope this is not to confusing.

Thanks,
Scott
#2
You can drop files into a list box directly but qm items don't seem to work.. could use an edit control. It let's you drop qm items but doesn't register the drop. Read
https://www.quickmacros.com/forum/showth...6#pid33146
For an example on how to drop files into a listbox. Also search the forum
#3
QM items list control does not use standard drag and drop. And QM items are not files. WM_DROPFILES and other functions will not work.
To drop files (not QM items), can be used WM_DROPFILES, but UAC may block it. For this reason there is QmRegisterDropTarget. Look in QM help.
#4
Thank you guys for the response.
Basically what I'm trying to do is create sort of a favorites box to be able to
A) Run my favorite macros and,
b) Edit certain macros that are under construction.

So I've made a dialog with two listboxes, one to run and one to edit.
Now what I would like to do is easily drag a macro from qm and drop onto the listbox
instead of typing the macro's name etc. into the dialogs code. 

Would this be possible?

Scott
#5
You cant drag a QM item(macro,function,dialog ect.) from QM and drop onto a listbox.
You can however drop it in an edit control. It wont automatically add it to the list box but can easily add it.

a quick example its pretty self explanatory
just drag a macro/ function ect. from QM left side window and drop in the edit control

Function DialogExample
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 160 136 "Dialog" "4"
;4 Edit 0x54030080 0x200 4 4 96 14 "" "Drop Item or Type Then click add"
;3 ListBox 0x54230109 0x200 4 22 98 90 ""
;7 Button 0x54032000 0x0 104 4 48 14 "Find" "Finds the specified item"
;5 Button 0x54032000 0x0 104 20 48 14 "Add" "Adds the specified item"
;6 Button 0x54032000 0x0 104 36 48 14 "Remove" "Removes selected items"
;1 Button 0x54030001 0x4 23 116 48 14 "OK"
;2 Button 0x54030000 0x4 88 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "4 3"
str e4 lb3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,int hlb i; str s ss
,SendMessage id(4 hDlg) EM_SETCUEBANNER TRUE @"Drop Item here"
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
hlb=id(3 hDlg)
sel wParam
,case IDOK
,case IDCANCEL
,case 7 ;;Find
,LB_SelectItem(hlb -1 2) ;;deselect all
,s.getwintext(id(4 hDlg)); if(!s.len) ret
,i=LB_FindItem(hlb s 0 1); if(i<0) i=LB_FindItem(hlb s); if(i<0) ret ;;find exact or partial
,LB_SelectItem(hlb i 1)        
,case 5 ;;Add
,s.getwintext(id(4 hDlg)); if(!s.len) ret
,i=LB_FindItem(hlb s 0 1); if(i>=0 and mes("Already exists. Add anyway?" "" "YN?")!='Y') ret
,LB_Add hlb s    
,case 6 ;;Remove
,ARRAY(int) ai
,if(!LB_GetSelectedItems(hlb ai)) ret
,for(i ai.len-1 -1 -1) SendMessage(hlb LB_DELETESTRING ai[i] 0)
ret 1

will also need this function
Function LB_GetSelectedItems
Code:
Copy      Help
;/
function# hwnd [ARRAY(int)&ai] [ARRAY(str)&as]

;Gets selected items in a multisel listbox control.
;Returns number of selected items.

;hwnd - control handle.
;ai - array variable that receives indices of selected items. Optional, can be 0.
;as - array variable that receives text of selected items. Optional, can be 0.

;REMARKS
;The control must belong to current process. Use eg in dialog procedures.


if(&ai) ai=0
if(&as) as=0

int i n
n=SendMessage(hwnd LB_GETSELCOUNT 0 0); if(n<1) ret
if &ai or &as
,ARRAY(int) _ai; if(!&ai) &ai=_ai
,ai.create(n)
,n=SendMessage(hwnd LB_GETSELITEMS n &ai[0]); if(n<0) n=0
,if(n!ai.len) ai.redim(n)
,if &as
,,as.create(n)
,,for(i 0 n) LB_GetItemText(hwnd ai[i] as[i])
ret n
#6
Thanks for this example Kevin, I may be able to work with it.
Check out what I'm working with. (My example below)
The upper listbox clicking will run the function, and
the lower one, clicking will take you to the function in qm for editing.

What I'm hoping to accomplish with the drag and drop is to add another function to the existing listboxes
just with drag and drop and have the code inserted automatically, instead of editing the existing listbox with code manually.
I know I'm probably searching for the impossible, but I like a challenge.

Below: create Function100 and Function200, and Favorites_Example to understand my example.

Function Function100
Code:
Copy      Help
mes "This is Function100. Running" "Function100" "i"

Function Function200
Code:
Copy      Help
mes "This is Function200. Running" "Function200" "i"

Function Favorites_Example
Trigger Wff 0x4     Help - how to add the trigger to the macro
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CE0AC8 0x18 0 0 224 330 "Favorites_Example" "4"
;3 ListBox 0x54A30001 0x200 4 20 216 131 "Frequently Used:  (Run)"
;4 ListBox 0x54A30101 0x200 4 180 216 142 "Edit Function:"
;5 Static 0x54000000 0x0 12 8 198 12 "Run Function:"
;6 Static 0x54000000 0x0 12 168 198 12 "Edit Function:"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "3 4"
str lb3Fre lb4Edi

lb3Fre="&Function100[]Function200"
lb4Edi="Function100[]&Function200"

if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam


str s; int i ii;;we will use these local variables in several places. Note that local variables are created/destroyed on each message.
int-- t_initalizing t_timerCounter ;;use thread variables where need. They are destroyed when the dialog is closed and the thread ends.
str sX, sY, scx, scy 
int x y cx cy ix iy icx icy

sel message ;;Windows messages received by the dialog
,case WM_INITDIALOG
,DT_SetAutoSizeControls hDlg "3ms 4ms"
,x = 2773
,y = -69
,cx = 353
,cy = 576
,int w=win("Favorites_Example" "#32770")
,act w
,mov+ x y cx cy w        ;;   2773 -69 353 593
,
,t_initalizing=1
,
,t_timerCounter=0
,SetTimer hDlg 10 1000 0 ;;let this dialog receive WM_TIMER messages every 1000 ms, wParam=10
,t_initalizing=0
,
,case WM_TIMER
,sel wParam
,,case 10
,,t_timerCounter+1
,,s=t_timerCounter; s.setwintext(id(3 hDlg))
,
,case WS_CAPTION
,
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
if(t_initalizing) ret 1 ;;ignore all control notifications sent while we are in WM_INITDIALOG
;;; start
sel wParam ;;messages from controls of these classes: Button, Edit, ComboBox, ListBox, Static and some other
,case IDOK
,case IDCANCEL
,case LBN_SELCHANGE<<16|3
,_i=LB_SelectedItem(lParam)
,;out "ListBox1: item %i selected" _i
,if _i = 0
,,Function100()
,,;goto start
,if _i = 1
,,Function200()
,
,
,case LBN_SELCHANGE<<16|4
,_i=LB_SelectedItem(lParam)
,;out "ListBox2: item %i selected" _i
,if _i = 0
,,int wQM=win("Quick Macros" "QM_Editor")
,,act wQM; 0.13
,,'AL
,,key "Function100"
,if _i = 1
,,wQM=win("Quick Macros" "QM_Editor")
,,act wQM; 0.13
,,'AL
,,key "Function200"
,
,
,
ret 1



 
#7
You cant drag a QM item(macro,function,dialog ect.) from QM and drop onto a listbox.

That's why I showed you another way.
I have taken my example and your example and combined them and changed the functionality a little.
Instead of single left click to edit or run changed it to double left click so as it doesn't interfere with my addition.
I also made it so you can remove an item from the list box by using the delete key. It will delete whatever is selected.
Got rid of unneeded code as well.
Now simulates drag and drop of QM items on the edit control. Once and item is dropped onto the edit control it is added to the listbox automatically.
uses mac now to run or edit a QM item 
don't need to use keys  or use If i=0 ect ect

Function Favorites_Example2
Trigger Wff 0x4     Help - how to add the trigger to the macro
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CA0AC8 0x0 0 0 265 328 "Favorites_Example" "4"
;4 Edit 0x54030000 0x200 8 17 96 14 "" "Drop Item or Type Then click add"
;3 ListBox 0x5423050B 0x200 8 32 248 120 "Frequently Used:  (Run)"
;5 Button 0x54032000 0x0 105 17 48 14 "Find" "Finds the specified item"
;6 Button 0x54032000 0x0 153 17 48 14 "Add" "Adds the specified item"
;7 Button 0x54032000 0x0 201 17 48 14 "Remove" "Removes selected items"
;9 Edit 0x54030080 0x204 8 176 96 14 "" "Drop Item or Type Then click add"
;8 ListBox 0x54230509 0x204 8 192 248 120 "Edit Function:"
;10 Button 0x54032000 0x4 105 176 48 14 "Find" "Finds the specified item"
;11 Button 0x54032000 0x4 153 176 48 14 "Add" "Adds the specified item"
;12 Button 0x54032000 0x4 201 176 48 14 "Remove" "Removes selected items"
;13 Static 0x54000000 0x0 8 5 55 13 "Run Function:"
;14 Static 0x54000000 0x0 8 163 55 13 "Edit Function:"
;1 Button 0x54030001 0x4 23 116 48 14 "OK"
;2 Button 0x54030000 0x4 88 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "4 3 9 8"
str e4 lb3Fre e9 lb8Edi
lb3Fre="&Function100[]Function200"
lb8Edi="Function100[]&Function200"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,int hlb hedit i; str s ss
,SendMessage id(4 hDlg) EM_SETCUEBANNER TRUE @"Drop Item here"
,SendMessage id(9 hDlg) EM_SETCUEBANNER TRUE @"Drop Item here"
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_VKEYTOITEM
,int lo=wParam&0xFFFF
,if lo=46;;if delete key in list box
,,if(GetDlgCtrlID(lParam)=3) but id(7 hDlg); else but id(12 hDlg)
ret
;messages2
if wParam=5 or wParam=6 or wParam=7
,hlb=id(3 hDlg)
,hedit=id(4 hDlg)
if wParam=10 or wParam=11 or wParam=12
,hlb=id(8 hDlg)
,hedit=id(9 hDlg)
sel wParam
,case IDOK
,case IDCANCEL
,case [5,10] ;;Find
,LB_SelectItem(hlb -1 2) ;;deselect all
,s.getwintext(hedit); if(!s.len) ret
,i=LB_FindItem(hlb s 0 1); if(i<0) i=LB_FindItem(hlb s); if(i<0) ret ;;find exact or partial
,LB_SelectItem(hlb i)    
,opt waitmsg 1
,act hlb
,case [6,11] ;;Add
,s.getwintext(hedit); if(!s.len) ret
,i=LB_FindItem(hlb s 0 1); if(i>=0 and mes("Already exists. Add anyway?" "" "YN?")!='Y') ret
,LB_Add hlb s
,LB_SelectItem(hlb -1 2) ;;deselect all
,LB_SelectString hlb s
,case [7,12] ;;Remove selected item or items
,ARRAY(int) ai
,if(!sub.LB_GetSelectedItems(hlb ai)) ret
,if(ai.len>1 and mes("Multiple Items Selected. Remove anyway?" "" "YN?")!='Y') ret
,for(i ai.len-1 -1 -1) SendMessage(hlb LB_DELETESTRING ai[i] 0)
,case [LBN_DBLCLK<<16|3,LBN_DBLCLK<<16|8];;run on double click,edit on double click
,i=LB_SelectedItem(lParam ss)
,if(GetDlgCtrlID(lParam)=3) mac ss; else mac+ ss
,case [EN_CHANGE<<16|4,EN_CHANGE<<16|9]
,ifa- hDlg
,,int Bcid=iif(GetDlgCtrlID(lParam)=4 6 11)
,,but id(Bcid hDlg)
ret 1

#sub LB_GetSelectedItems
;/
function# hwnd [ARRAY(int)&ai] [ARRAY(str)&as]

;Gets selected items in a multisel listbox control.
;Returns number of selected items.

;hwnd - control handle.
;ai - array variable that receives indices of selected items. Optional, can be 0.
;as - array variable that receives text of selected items. Optional, can be 0.

;REMARKS
;The control must belong to current process. Use eg in dialog procedures.

if(&ai) ai=0
if(&as) as=0

int i n
n=SendMessage(hwnd LB_GETSELCOUNT 0 0); if(n<1) ret
if &ai or &as
,ARRAY(int) _ai; if(!&ai) &ai=_ai
,ai.create(n)
,n=SendMessage(hwnd LB_GETSELITEMS n &ai[0]); if(n<0) n=0
,if(n!ai.len) ai.redim(n)
,if &as
,,as.create(n)
,,for(i 0 n) LB_GetItemText(hwnd ai[i] as[i])
ret n
#8
Exactly, Perfect!!   Cool

Thanks a GaZillion Kevin...

Dosen't remember items upon re-running dialog, will try writing to registry, but Awesome.
#9
Yeah didn't set that up there are several options saving to registry is one.
Check out
https://www.quickmacros.com/forum/showth...p?tid=3620
#10
Ok, so I tried with your suggestion above.
I may not be doing it right, below is modified code to implement the
Functions:
SaveDialogControlValues  ---> under     case IDOK  and   case IDCANCEL
LoadDialogControlValues  ---> under     case WM_INITDIALOG

Any other suggestions, or do you see what I may be doing wrong??
Thanks


Function Favorites_Example3
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CA0AC8 0x0 0 0 265 328 "Favorites_Example" "4"
;4 Edit 0x54030000 0x200 8 17 96 14 "" "Drop Item or Type Then click add"
;3 ListBox 0x5423050B 0x200 8 32 248 120 "Frequently Used:  (Run)"
;5 Button 0x54032000 0x0 105 17 48 14 "Find" "Finds the specified item"
;6 Button 0x54032000 0x0 153 17 48 14 "Add" "Adds the specified item"
;7 Button 0x54032000 0x0 201 17 48 14 "Remove" "Removes selected items"
;9 Edit 0x54030080 0x204 8 176 96 14 "" "Drop Item or Type Then click add"
;8 ListBox 0x54230509 0x204 8 192 248 120 "Edit Function:"
;10 Button 0x54032000 0x4 105 176 48 14 "Find" "Finds the specified item"
;11 Button 0x54032000 0x4 153 176 48 14 "Add" "Adds the specified item"
;12 Button 0x54032000 0x4 201 176 48 14 "Remove" "Removes selected items"
;13 Static 0x54000000 0x0 8 5 55 13 "Run Function:"
;14 Static 0x54000000 0x0 8 163 55 13 "Edit Function:"
;1 Button 0x54030001 0x4 23 116 48 14 "OK"
;2 Button 0x54030000 0x4 88 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "4 3 9 8"
str e4 lb3Fre e9 lb8Edi
lb3Fre="&Function100[]Function200"
lb8Edi="Function100[]&Function200"

if(!ShowDialog(dd &sub.DlgProc &controls)) ret

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,LoadDialogControlValues hDlg "\Test\SaveControls" "xml" "test password"
,int hlb hedit i; str s ss
,SendMessage id(4 hDlg) EM_SETCUEBANNER TRUE @"Drop Item here"
,SendMessage id(9 hDlg) EM_SETCUEBANNER TRUE @"Drop Item here"
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_VKEYTOITEM
,int lo=wParam&0xFFFF
,if lo=46;;if delete key in list box
,,if(GetDlgCtrlID(lParam)=3) but id(7 hDlg); else but id(12 hDlg)
ret
;messages2
if wParam=5 or wParam=6 or wParam=7
,hlb=id(3 hDlg)
,hedit=id(4 hDlg)
if wParam=10 or wParam=11 or wParam=12
,hlb=id(8 hDlg)
,hedit=id(9 hDlg)
sel wParam
,case IDOK
,SaveDialogControlValues hDlg "\Test\SaveControls" "xml" "3 8" "test password"
,case [5,10] ;;Find
,LB_SelectItem(hlb -1 2) ;;deselect all
,s.getwintext(hedit); if(!s.len) ret
,i=LB_FindItem(hlb s 0 1); if(i<0) i=LB_FindItem(hlb s); if(i<0) ret ;;find exact or partial
,LB_SelectItem(hlb i)
,opt waitmsg 1
,act hlb
,case [6,11] ;;Add
,s.getwintext(hedit); if(!s.len) ret
,i=LB_FindItem(hlb s 0 1); if(i>=0 and mes("Already exists. Add anyway?" "" "YN?")!='Y') ret
,LB_Add hlb s
,LB_SelectItem(hlb -1 2) ;;deselect all
,LB_SelectString hlb s
,case [7,12] ;;Remove selected item or items
,ARRAY(int) ai
,if(!sub.LB_GetSelectedItems(hlb ai)) ret
,if(ai.len>1 and mes("Multiple Items Selected. Remove anyway?" "" "YN?")!='Y') ret
,for(i ai.len-1 -1 -1) SendMessage(hlb LB_DELETESTRING ai[i] 0)
,case [LBN_DBLCLK<<16|3,LBN_DBLCLK<<16|8];;run on double click,edit on double click
,i=LB_SelectedItem(lParam ss)
,if(GetDlgCtrlID(lParam)=3) mac ss; else mac+ ss
,case [EN_CHANGE<<16|4,EN_CHANGE<<16|9]
,ifa- hDlg
,,int Bcid=iif(GetDlgCtrlID(lParam)=4 6 11)
,,but id(Bcid hDlg)
,case IDCANCEL
,SaveDialogControlValues hDlg "\Test\SaveControls" "xml" "3 8" "test password"
ret 1

#sub LB_GetSelectedItems
;/
function# hwnd [ARRAY(int)&ai] [ARRAY(str)&as]

;Gets selected items in a multisel listbox control.
;Returns number of selected items.

;hwnd - control handle.
;ai - array variable that receives indices of selected items. Optional, can be 0.
;as - array variable that receives text of selected items. Optional, can be 0.

;REMARKS
;The control must belong to current process. Use eg in dialog procedures.

if(&ai) ai=0
if(&as) as=0

int i n
n=SendMessage(hwnd LB_GETSELCOUNT 0 0); if(n<1) ret
if &ai or &as
,ARRAY(int) _ai; if(!&ai) &ai=_ai
,ai.create(n)
,n=SendMessage(hwnd LB_GETSELITEMS n &ai[0]); if(n<0) n=0
,if(n!ai.len) ai.redim(n)
,if &as
,,as.create(n)
,,for(i 0 n) LB_GetItemText(hwnd ai[i] as[i])
ret n
#11
sorry seems that only saves selected listbox items

this will work for what you need

Function Favorites_Example4
Trigger Wff 0x4     Help - how to add the trigger to the macro
Code:
Copy      Help
str lb3 lb8 Mname
Mname.getmacro("" 1)
rget lb3 "lb3" F"\{Mname}"
if lb3.len=0
,lb3="&Function100[]Function200"
rget lb8 "lb8" F"\{Mname}"
if lb8.len=0
,lb8="Function100[]&Function200"

str dd=
;BEGIN DIALOG
;0 "" 0x90CA0AC8 0x0 0 0 265 328 "Favorites_Example" "4"
;4 Edit 0x54030000 0x200 8 17 96 14 "" "Drop Item or Type Then click add"
;3 ListBox 0x5423050B 0x200 8 32 248 120 "Frequently Used:  (Run)"
;5 Button 0x54032000 0x0 105 17 48 14 "Find" "Finds the specified item"
;6 Button 0x54032000 0x0 153 17 48 14 "Add" "Adds the specified item"
;7 Button 0x54032000 0x0 201 17 48 14 "Remove" "Removes selected items"
;9 Edit 0x54030080 0x204 8 176 96 14 "" "Drop Item or Type Then click add"
;8 ListBox 0x54230509 0x204 8 192 248 120 "Edit Function:"
;10 Button 0x54032000 0x4 105 176 48 14 "Find" "Finds the specified item"
;11 Button 0x54032000 0x4 153 176 48 14 "Add" "Adds the specified item"
;12 Button 0x54032000 0x4 201 176 48 14 "Remove" "Removes selected items"
;13 Static 0x54000000 0x0 8 5 55 13 "Run Function:"
;14 Static 0x54000000 0x0 8 163 55 13 "Edit Function:"
;1 Button 0x54030001 0x4 23 116 48 14 "OK"
;2 Button 0x54030000 0x4 88 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

str controls = "4 3 9 8"
str e4 lb3Fre e9 lb8Edi
lb3Fre=lb3
lb8Edi=lb8
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,int hlb hedit i; str s ss
,SendMessage id(4 hDlg) EM_SETCUEBANNER TRUE @"Drop Item here"
,SendMessage id(9 hDlg) EM_SETCUEBANNER TRUE @"Drop Item here"
,case WM_DESTROY
,case WM_CLOSE
,but+ id(1 hDlg);err    
,case WM_COMMAND goto messages2
,case WM_VKEYTOITEM
,int lo=wParam&0xFFFF
,if lo=46;;if delete key in list box
,,if(GetDlgCtrlID(lParam)=3) but id(7 hDlg); else but id(12 hDlg)
ret
;messages2
if wParam=5 or wParam=6 or wParam=7
,hlb=id(3 hDlg)
,hedit=id(4 hDlg)
if wParam=10 or wParam=11 or wParam=12
,hlb=id(8 hDlg)
,hedit=id(9 hDlg)
sel wParam
,case IDOK
,str Mname.getmacro("" 1)
,hlb=id(8 hDlg)
,i=0; s.fix(0); ss.fix(0);
,for i 0 LB_GetCount(hlb)
,,if(LB_GetItemText(hlb i s) and s.len) ss.addline(s)
,rset ss "lb8" F"\{Mname}"
,hlb=id(3 hDlg)
,i=0; s.fix(0); ss.fix(0);
,for i 0 LB_GetCount(hlb)
,,if(LB_GetItemText(hlb i s) and s.len) ss.addline(s)
,rset ss "lb3" F"\{Mname}"
,case IDCANCEL
,case [5,10] ;;Find
,LB_SelectItem(hlb -1 2) ;;deselect all
,s.getwintext(hedit); if(!s.len) ret
,i=LB_FindItem(hlb s 0 1); if(i<0) i=LB_FindItem(hlb s); if(i<0) ret ;;find exact or partial
,LB_SelectItem(hlb i)    
,opt waitmsg 1
,act hlb
,case [6,11] ;;Add
,s.getwintext(hedit); if(!s.len) ret
,i=LB_FindItem(hlb s 0 1); if(i>=0 and mes("Already exists. Add anyway?" "" "YN?")!='Y') ret
,LB_Add hlb s
,LB_SelectItem(hlb -1 2) ;;deselect all
,LB_SelectString hlb s
,case [7,12] ;;Remove selected item or items
,ARRAY(int) ai
,if(!sub.LB_GetSelectedItems(hlb ai)) ret
,if(ai.len>1 and mes("Multiple Items Selected. Remove anyway?" "" "YN?")!='Y') ret
,for(i ai.len-1 -1 -1) SendMessage(hlb LB_DELETESTRING ai[i] 0)
,case [LBN_DBLCLK<<16|3,LBN_DBLCLK<<16|8];;run on double click,edit on double click
,i=LB_SelectedItem(lParam ss)
,if(GetDlgCtrlID(lParam)=3) mac ss; else mac+ ss
,case [EN_CHANGE<<16|4,EN_CHANGE<<16|9]
,ifa- hDlg
,,int Bcid=iif(GetDlgCtrlID(lParam)=4 6 11)
,,but id(Bcid hDlg)
ret 1

#sub LB_GetSelectedItems
;/
function# hwnd [ARRAY(int)&ai] [ARRAY(str)&as]

;Gets selected items in a multisel listbox control.
;Returns number of selected items.

;hwnd - control handle.
;ai - array variable that receives indices of selected items. Optional, can be 0.
;as - array variable that receives text of selected items. Optional, can be 0.

;REMARKS
;The control must belong to current process. Use eg in dialog procedures.

if(&ai) ai=0
if(&as) as=0

int i n
n=SendMessage(hwnd LB_GETSELCOUNT 0 0); if(n<1) ret
if &ai or &as
,ARRAY(int) _ai; if(!&ai) &ai=_ai
,ai.create(n)
,n=SendMessage(hwnd LB_GETSELITEMS n &ai[0]); if(n<0) n=0
,if(n!ai.len) ai.redim(n)
,if &as
,,as.create(n)
,,for(i 0 n) LB_GetItemText(hwnd ai[i] as[i])
ret n
#12
SOLVED!
Yep, that did it. Thank you problem solver.  Smile

Really, thanks for all your help on this Kevin I really do appreciate it.


Forum Jump:


Users browsing this thread: 1 Guest(s)