Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Save or delete item in editable combobox
#4
saves to registry

Code:
Copy      Help
str cb3t Mname
Mname.getmacro("" 1)
rget cb3t "cb3t" F"\{Mname}"
if cb3t.len=0
,cb3t=
,;AAA
,;BBB
,;Save the current value to the list
,;Delete the current list item

ARRAY(str) a
a=cb3t;;add items into arra
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 ComboBox 0x54230242 0x0 16 8 144 213 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str cb3
cb3=cb3t

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


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,Mname.getmacro("" 1)
,cb3t=a; cb3t.trim
,rset cb3t "cb3t" F"\{Mname}"
,case IDCANCEL
,Mname.getmacro("" 1)
,cb3t=a; cb3t.trim
,rset cb3t "cb3t" F"\{Mname}"    
,case CBN_SELENDOK<<16|3
,_i=CB_SelectedItem(lParam)
,int i n; str s
,n=CB_GetCount(lParam)
,s.getwintext(child("" "Edit" lParam))
,if(empty(s) or s="Save the current value to the list" or s=" Delete the current list item") ret
,if _i=n-1 ;;Delete
,,for(i a.len-1 -1 -1) if(a[i]=s) a.remove(i)
,,SendMessage(lParam CB_RESETCONTENT 0 0)
,,for(i 0 a.len) CB_Add(lParam a[i].trim) 
,,CB_SelectItem(lParam 0)
,if _i=n-2 ;;Save
,,for(i 0 a.len) if(a[i]=s) ret;;prevent adding identical entry
,,int index=a.insert(a.len-2)
,,a[index]=s
,,SendMessage(lParam CB_RESETCONTENT 0 0)
,,for(i 0 a.len) CB_Add(lParam a[i].trim) 
,,CB_SelectItem(lParam index)
ret 1


Messages In This Thread
RE: Save or delete item in editable combobox - by Kevin - 03-04-2023, 05:28 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)