03-14-2008, 10:38 AM
If number of controls is unknown, you can create them at run time with CreateControl or CreateWindowEx, and destroy with DestroyWindow or clo.
Or you can use a tree view control with check boxes.
Example dialog with treeview with checkboxes.
Function Dialog54
Function TvAddWindows
Function TvGetItems
Function TvIsChecked
Or you can use a tree view control with check boxes.
Example dialog with treeview with checkboxes.
Function Dialog54
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("Dialog54" &Dialog54)) ret
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 203 "Dialog"
;3 SysTreeView32 0x54030000 0x0 2 2 164 178 ""
;4 Button 0x54032000 0x0 172 6 48 14 "Refresh"
;5 Button 0x54032000 0x0 172 30 48 22 "Flash Selected"
;6 Button 0x54032000 0x0 172 58 48 22 "Activate Selected"
;1 Button 0x54030001 0x4 118 186 48 14 "OK"
;2 Button 0x54030000 0x4 170 186 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2020105 "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,TvAddWindows id(3 hDlg)
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case 4 ;;Refresh
,TvAddWindows id(3 hDlg)
,
,case [5,6] ;;flash or activate selected
,ARRAY(int) ah; int i
,TvGetItems id(3 hDlg) 0 ah 1
,for i 0 ah.len
,,sel wParam
,,,case 5 FlashWindow ah[i] 1
,,,case 6 act ah[i]; err
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 3 ;;treeview
,sel nh.code
,,case TVN_SELCHANGED ;;treeview item selected
,,NMTREEVIEW* ntv=+nh
,,int h=ntv.itemNew.lParam ;;window handle (set by TvAdd)
,,out "item selected: %s" _s.getwintext(h)Function TvAddWindows
;/
function htv
SetWinStyle htv TVS_CHECKBOXES 1
SendMessage htv TVM_DELETEITEM 0 0 ;;delete all
ARRAY(int) a; int i
win "" "" "" 0 0 0 a
for i 0 a.len
,int h=a[i]
,if(GetWinStyle(h 1)&WS_EX_TOOLWINDOW) continue
,str s.getwintext(h); if(!s.len) continue
,;out s
,TvAdd htv 0 s h
,Function TvGetItems
;/
function htv ARRAY(int)&ahi [ARRAY(int)&apar] [flags] ;;flags: 1 only checked
;Gets handles and/or lParams of tree view items, only those at root.
if(&ahi) ahi.redim
if(&apar) apar.redim
int hi=SendMessage(htv TVM_GETNEXTITEM TVGN_ROOT 0)
rep
,if(!hi) break
,if(flags&1 and !TvIsChecked(htv hi)) goto next
,if(&ahi) ahi[]=hi
,if(&apar) apar[]=TvGetParam(htv hi)
,;next
,hi=SendMessage(htv TVM_GETNEXTITEM TVGN_NEXT hi)Function TvIsChecked
