01-10-2017, 09:07 PM
Given a qm-generated window I need to get its thread-id and also its thread name. I wonder whether there exists a standardized way to do it. Therefore, I have written the following function. Any comments or advice is mostly welcome. Many thanks in advance.
Function WindowToThreadName
Function WindowToThreadName
;---> Comment 10-01-2017 22:35:46 : It needs Dialog44 running
int w=win("Dialog Header" "#32770")
if w=0; ret
int thrd=GetWindowThreadProcessId(w 0)
out F"Thread id : {thrd}"
int i n j
n=EnumQmThreads(0 0 0 0)
ARRAY(QMTHREAD) a.create(n)
for i 0 EnumQmThreads(&a[0] n 0 0)
,j=j+1
;,out F"{i} {a[i].threadid} {a[i].qmitemid} {a[i].threadhandle}"
,if a[i].threadid=thrd
,,out F"Thread name : {_s.getmacro(a[i].qmitemid 1)}"
,,break
if i=j
,out "Thread not found"
,