Looking through the open windows
Matthew Phillips (473) 721 posts |
I have a need, in an application I am writing, to look through the windows open on the machine to see if a certain window belonging to another task is still open, and I also need to try to spot the window being opened in the first place. I think the only way of doing this is to look through all the windows in the stack. Do you have to open a window at the back, and then work up the stack by using Wimp_GetWindowState to find out what window it is behind, and then repeat for that window, etc.? The RISC OS Select changes introduced three window stacks, but I’m hoping I can ignore all that and just look at the main stack. If I open a window at the back, do the iteration through the stack, and then close it again, I hope that the Wimp will not actually display my window. Is that roughly the right procedure? |
Steve Fryatt (216) 2105 posts |
I have a hazy recollection of seeing something in the Nested Wimp docs over Christmas about a proper way to do this, but I’m supposed to be doing other things with my evening1 so I don’t really have time to go and check whether I’m imagining that or not. Even if it does exist, that would tie you to Nested Wimp only, which may not be desirable. 1 https://www.riscosopen.org/forum/forums/1/topics/16776?page=1#posts-131666 |
Steve Fryatt (216) 2105 posts |
Looking quickly at the docs this morning, I may have been thinking of the Wimp_Extend calls for enumerating child windows. So probably not that useful. |
Rick Murray (539) 13840 posts |
Yes, it looks like you enumerate with GetWindowState – https://gitlab.riscosopen.org/RiscOS/Sources/Apps/Diversions/Madness/-/raw/master/bas/!RunImage You may need to check the window flags to filter out things that aren’t foreground windows? http://www.riscos.com/support/developers/riscos6/desktop/wimp/windowstacks.html |
Steve Pampling (1551) 8170 posts |
and off-screen windows? IIRC there’s something like that to allow keypress capture… |
Paolo Fabio Zaino (28) 1882 posts |
Yes to read key events and also a technique used by the various multi-desktop apps (when a window is assigned to a non-selected desktop, it’s actually moved off-screen). If I understand what Matthew wants to do correctly, then yes he should consider the off-screen windows too if a multi-desktop application is loaded. Matthew, welcome to the land I am in right now lol, many edge cases. But, oh well, it’s RISC OS :) |
Matthew Phillips (473) 721 posts |
Thank you for the advice: I just couldn’t believe this was the only way to do it. But then I suppose applications shouldn’t really have a need to do this kind of thing very much. I don’t think I need to worry too much about whether windows are off-screen or not. I am just wanting to look to see if there is a window owned by a certain task with a certain name. All this is to avoid opening a document in an editor if the editor already has that document open. This is all to do with mail merging via Impulse. (By the way, I’m not Matt.) |
Paolo Fabio Zaino (28) 1882 posts |
@ Matthew
Sorry, was typing that comment very late and very tired. Edited, so it’s Matthew now :) |
Matthew Phillips (473) 721 posts |
That’s very kind of you! |