After looking at this again i came up with a better version removed one button, got rid of the setprop/getprop/removeprop as that way of pausing had some limits.. now the buttons are dynamic and disable and enable depending on what mode your in. So when thread is paused can only resume. when list removal is complete can only refill ect ect.. also got rid of uneeded thread variables when not needed.
Function ListDialogRotate2b
Function ListDialogRotate2b
str appname="ListDialog Rotator"
str lb_items=
;item 1
;item 2
;item 3
;item 4
;item 5
;item 6
;item 7
str dd=
F
;BEGIN DIALOG
;0 "" 0x90CC0AC8 0x0 0 0 298 136 "{appname}" "4"
;3 ListBox 0x54230901 0x200 0 0 296 114 ""
;21 Button 0x54011F03 0x0 17 120 78 14 "START REMOVE" "From top, start removing items one by one[][SHIFT] + left click = starts from BOTTOM"
;23 Button 0x54037000 0x4 132 120 32 14 "REFILL"
;5 Button 0x54017003 0x0 202 120 78 14 "PAUSE"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C00 "*" "" "" ""
str controls = "3 21 5"
str lb3 c21STA c5PAU
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc v
function# hDlg message wParam lParam
double demo_wait_time=1.0
sel message
,case WM_INITDIALOG
,int- hThread
,sub.fill_lb(id(3 hDlg) lb_items)
,TO_Enable(hDlg "5 23" 0)
,case WM_DESTROY
,case WM_CLOSE
,if(hThread)
,,if !IsWindowEnabled(id(21 hDlg))
,,,out "Thread is paused ,Cannot close dialog"
,,,;but id(5 hDlg);; uncomment if your want to resume thread automatically
,,,ret 1
,,else
,,,out "Thread is running, cannot close dialog"
,,,ret 1
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 21 ;; START REMOVING ITEMS FROM LISTBOX
,if(but(lParam)) ;;checked
,,hThread= mac("sub.remove_item_and_process" "" id(3 hDlg) demo_wait_time hDlg)
,,TO_Enable(hDlg "5" 1)
,,TO_Enable(hDlg "23" 0)
,,_s="STOP" ;
,else
,,EndThread("" hThread)
,,hThread=!hThread
,,but- id(5 hDlg)
,,TO_Enable(hDlg "5" 0)
,,TO_Enable(hDlg "23" 1)
,,_s="START REMOVE"
,_s.setwintext(lParam)
,case 23 ;; REFILL THE LISTBOX
,,sub.fill_lb(id(3 hDlg) lb_items)
,,TO_Enable(hDlg "21" 1)
,,TO_Enable(hDlg "23" 0)
,case 5 ;; PAUSE/CONTINUE: ???
,if(but(lParam)) ;;checked
,,TO_Enable(hDlg "21" 0)
,,SuspendThread hThread
,,_s="CONTINUE"
,else
,,TO_Enable(hDlg "21" 1)
,,ResumeThread hThread
,,_s="PAUSE"
,_s.setwintext(lParam)
ret 1
#sub remove_item_and_process
function cid double'demo_wait_time hdlg
int amount i
amount=LB_GetCount(cid)
if(amount=0)
,mes(F"No content to process" F"test" "!")
,but- id(21 hdlg)
,TO_Enable(hdlg "21" 0)
,ret
rep amount
,LB_GetItemText(cid 0 _s)
,LB_SelectItem(cid 0 1)
,outt F"PROCESSING, {_s}, {i} -> ({i} index listbox content)"
,wait demo_wait_time
,SendMessage(cid LB_DELETESTRING 0 0)
,outt F"PROCESSED, REMOVED: {_s}, {i} -> ({i} index listbox content)"
,out "-"
,i=i+1
mes(F"Finished[]No more content to process" F"test" "i")
but- id(21 hdlg)
TO_Enable(hdlg "5 21" 0)
TO_Enable(hdlg "23" 1)
#sub fill_lb
function cid str'lb_items
SendMessage(cid LB_RESETCONTENT 0 0) ;; clear first then refill
foreach _s lb_items
,LB_Add cid _s