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
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
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