Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use of "EndThread" to end a sub-function in .exe ?
#1
Star 
Hello Smile

I'm struggling to use the EndThread function to stop a sub-function running in a separate thread, in an .exe. It works fine in QM but once it's in .exe the thread is not found, maybe it has a different name or i'm doing it wrong ?

Here is an example :

Macro EndThreadSub
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 132 84 "Dialog" "4"
;3 Static 0x54000000 0x0 40 10 56 12 "Text"
;4 Button 0x54032000 0x0 16 24 103 37 "Click here to stop count (works in QM but not in .exe, different thread name ?)"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C00 "*" "" "" ""

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


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,mac "sub.counting" hDlg
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,,case 4 ;;Click here to stop count
,,,EndThread("EndThreadSub:counting")
ret 1

#sub counting

str dlg_id=_command;int hDlg=val(dlg_id)

rep
,_i+1
,_s=F"{_i}";_s.setwintext(id(3 hDlg))
,1
#2
use thread handle instead 
Macro EndThreadSub
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 132 84 "Dialog" "4"
;3 Static 0x54000000 0x0 40 10 56 12 "Text"
;4 Button 0x54032000 0x0 16 24 103 37 "Click here to stop count (works in QM but not in .exe, different thread name ?)"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C00 "*" "" "" ""

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


#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,int- hThread=mac("sub.counting" "" hDlg)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4 ;;Click here to stop count
,EndThread("" hThread)
ret 1

#sub counting
function hdlg
rep
,_i+1
,_s=F"{_i}";_s.setwintext(id(3 hdlg))
,1
#3
Hello Kevin,

Thanks ! Smile


Forum Jump:


Users browsing this thread: 1 Guest(s)