Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'win' all windows same class, result = also stack order?
#1
I needed a quick way to get all totalcommander windows in an array with the topmost window beeing the first one in the array.
I used this example code:

Macro all_tcmd_and_topmost
Code:
Copy      Help
ARRAY(int) a; int i; str sc sn
win("" "TTOTAL_CMD" "" 0 0 0 a)
for(i 0 a.len)
,sc.getwinclass(a[i])
,sn.getwintext(a[i])
,out "%i '%s' '%s'" a[i] sc sn

It seems to work.
My question:
Can I assume that the code above indeed processes the windows in stack order?
Top-most window being the first one in the array?

I read this helpfile page: IDP_WIN.html
It states: win returns top-level window handle. If window not found, returns 0.
But according to the helpfile 'top-level' means:
A top-level window is a window that is not a part of other window.
#2
The array matches the Z order, and does not include child windows (controls). But handles of visible windows are placed before hidden windows, even if some hidden windows are on top of visible windows in the Z order.

To get exact Z order regardless of visible/hidden, use Windows API functions. Example:
Macro Macro2762
Code:
Copy      Help
str winClass="#32770"
int w pw
BSTR bwc=winClass
rep
,w=FindWindowExW(0 pw bwc 0)
,if(!w) break
,pw=w
,
,outw w
#3
Thank you for this!


Forum Jump:


Users browsing this thread: 1 Guest(s)