Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can WM_DROPFILES be used in a ListBox?
#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


Messages In This Thread
RE: Can WM_DROPFILES be used in a ListBox? - by Kevin - 10-24-2020, 03:16 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)